[bwm-tools-devel] COMMIT - r53 - in branch/bwmd-tosclassify: . bwm_firewall bwmd doc include lib
Brought to you by:
nkukard
From: SVN C. <sv...@li...> - 2005-01-21 06:42:45
|
Author: nkukard Date: 2005-01-21 08:42:26 +0200 (Fri, 21 Jan 2005) New Revision: 53 Modified: branch/bwmd-tosclassify/aclocal.m4 branch/bwmd-tosclassify/bwm_firewall/bwm_firewall.c branch/bwmd-tosclassify/bwmd/autoclass.c branch/bwmd-tosclassify/bwmd/bwmd.c branch/bwmd-tosclassify/bwmd/flow.c branch/bwmd-tosclassify/bwmd/ipq.c branch/bwmd-tosclassify/configure branch/bwmd-tosclassify/configure.ac branch/bwmd-tosclassify/doc/bwmtools.texi branch/bwmd-tosclassify/include/autoclass.h branch/bwmd-tosclassify/include/flow.h branch/bwmd-tosclassify/lib/Makefile.am branch/bwmd-tosclassify/lib/Makefile.in branch/bwmd-tosclassify/lib/xmlConf.c Log: * current work on TOS and optimization Modified: branch/bwmd-tosclassify/aclocal.m4 =================================================================== --- branch/bwmd-tosclassify/aclocal.m4 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/aclocal.m4 2005-01-21 06:42:26 UTC (rev 53) @@ -32,6 +32,9 @@ gmodule) pkg_config_args="$pkg_config_args gmodule-2.0" ;; + gmodule-no-export) + pkg_config_args="$pkg_config_args gmodule-no-export-2.0" + ;; gobject) pkg_config_args="$pkg_config_args gobject-2.0" ;; Modified: branch/bwmd-tosclassify/bwm_firewall/bwm_firewall.c =================================================================== --- branch/bwmd-tosclassify/bwm_firewall/bwm_firewall.c 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/bwm_firewall/bwm_firewall.c 2005-01-21 06:42:26 UTC (rev 53) @@ -237,7 +237,7 @@ // Check if we piping to iptables aswell if (piptables_restore) { - fprintf(piptables_restore, "%s", data); + fprintf(piptables_restore, "%s", (char *) data); // Check for IO error if (ferror(piptables_restore)) { Modified: branch/bwmd-tosclassify/bwmd/autoclass.c =================================================================== --- branch/bwmd-tosclassify/bwmd/autoclass.c 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/bwmd/autoclass.c 2005-01-21 06:42:26 UTC (rev 53) @@ -22,86 +22,204 @@ */ #include "autoclass.h" +#include "flow.h" -// Band calculation functions, tcp -long int tcpPortToBand(long int bandNum, u_int16_t port) + +// Auto classify by port +static unsigned char autoClassify_port(struct ip_packet_t *ip_packet, unsigned char prioClassifier) { - long int ret = bandNum; + unsigned char prio = 0; + + + // Priority calculation functions, tcp + static unsigned char tcpPortToPrio(u_int16_t port) + { + unsigned char ret = 0; + + + // Decide band to pump packet into + switch (port) + { + // AUTH + case 113: + ret = 20; + break; + // SSH + case 22: + // TELNET + case 23: + ret = 25; + break; + // HTTP + case 80: + // PROXY? + case 8080: + case 3128: + case 3130: + // HTTPS + case 443: + ret = 65; + break; + // CVS + case 2401: + ret = 70; + break; + // POP3 + case 110: + // IMAP + case 143: + ret = 75; + break; + // FTP + case 20: + case 21: + ret = 80; + break; + }; + + return ret; + } + + + // Priority calculation functions, udp + static unsigned char udpPortToPrio(u_int16_t port) + { + unsigned char ret = 0; - // Decide band to pump packet into - switch (port) + // Decide band to pump packet into + switch (port) + { + // DNS + case 53: + ret = 10; + break; + // NTP + case 123: + ret = 15; + break; + // RADIUS + case 1645: + case 1646: + case 1812: + case 1813: + ret = 30; + break; + default: + // Traceroute + if (port >= 33434 && port <= 33465) + ret = 5; + break; + }; + + return ret; + } + + + // Process a TCP packet + if (ip_packet->protocol == IPPROTO_TCP) { - // AUTH - case 113: - ret = 20; - break; - // SSH - case 22: - // TELNET - case 23: - ret = 25; - break; - // HTTP - case 80: - // PROXY? - case 8080: - case 3128: - case 3130: - // HTTPS - case 443: - ret = 65; - break; - // CVS - case 2401: - ret = 70; - break; - // POP3 - case 110: - // IMAP - case 143: - ret = 75; - break; - // FTP - case 20: - case 21: - ret = 80; - break; - }; + struct tcphdr *tcph = (struct tcphdr *) (ip_packet + (ip_packet->ihl * 4)); +/* + fprintf(stderr," tcp -> sport = %i, dport = %i, prec = 0x%x\n", ntohs(tcph->source), + ntohs(tcph->dest), IPTOS_PREC(ip_packet->tos)); +*/ + if (!(prio = tcpPortToPrio(ntohs(tcph->dest)))) + prio = tcpPortToPrio(ntohs(tcph->source)); + } - return ret; + // Process a ICMP packet + else if (ip_packet->protocol == IPPROTO_ICMP) + { +// struct icmphdr *icmph = (struct icmphdr *) (ip_packet + (ip_packet->ihl * 4)); + +/* + fprintf(stderr,"something: icmp = %i, type = %i\n", icmph->code, icmph->type); +*/ + prio = 5; + } + + // Process a UDP packet + else if (ip_packet->protocol == IPPROTO_UDP) + { + struct udphdr *udph = (struct udphdr *) (ip_packet + (ip_packet->ihl * 4)); +/* + fprintf(stderr," udp -> sport = %i, dport = %i\n", ntohs(udph->source), + ntohs(udph->dest)); +*/ + if (!(prio = udpPortToPrio(ntohs(udph->dest)))) + prio = udpPortToPrio(ntohs(udph->source)); + } + + return prio; } + -// Band calculation functions, udp -long int udpPortToBand(long int bandNum, u_int16_t port) +// Auto classify by ip header TOS value +static unsigned char autoClassify_tos(struct ip_packet_t *ip_packet, unsigned char prioClassifier) { - long int ret = bandNum; - - - // Decide band to pump packet into - switch (port) + unsigned char prio = 0; + // Get type of service + unsigned char tos = IPTOS_TOS(ip_packet->tos); + + + // Decide what we doing... + if (tos == IPTOS_LOWDELAY) { - // DNS - case 53: - ret = 10; - break; - // NTP - case 123: - ret = 15; - break; - // RADIUS - case 1645: - case 1646: - case 1812: - case 1813: - ret = 30; - break; - }; - - if (port >= 33434 && port <= 33465) - ret = 5; - - return ret; +/* + * 1. LOW DELAY + * - PRIO 10 + * - high drop probability + */ + } + else if (tos == IPTOS_THROUGHPUT) + { +/* + * 2. THROUGHPUT + * - long queue? + * - low drop probability + */ + } + else if (tos == IPTOS_RELIABILITY) + { +/* + * 3. RELIABILITY + * - low drop probability + */ + } + else if (tos == IPTOS_MINCOST) + { +/* + * 4. MIN COST + * - PRIO 90 + * - high drop probability + */ + } + + return prio; } + +// Auto classify packet and return priority (1 - best, 100 - worst) +unsigned char autoClassify(struct ip_packet_t *ip_packet, unsigned char prioClassifier) +{ + unsigned char prio; + + + // Classify by port + if (prioClassifier == AUTOCLASS_PORT) + prio = autoClassify_port(ip_packet,prioClassifier); + // Classify by TOS + else if (prioClassifier == AUTOCLASS_TOS) + prio = autoClassify_tos(ip_packet,prioClassifier); + // Default - this will basically match if we have AUTOCLASS_NONE + else + prio = 50; + + return prio; +} + + + + Modified: branch/bwmd-tosclassify/bwmd/bwmd.c =================================================================== --- branch/bwmd-tosclassify/bwmd/bwmd.c 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/bwmd/bwmd.c 2005-01-21 06:42:26 UTC (rev 53) @@ -36,7 +36,11 @@ #include "flowControl.h" #include "xmlConf.h" +// Initialize syslog - This single function header doesn't call for a headerfile +extern void initSyslog(const char *ident, int prioMask); + +// Load a module.. void modprobe(gpointer key, gpointer value, gpointer user_data) { char buffer[4096]; Modified: branch/bwmd-tosclassify/bwmd/flow.c =================================================================== --- branch/bwmd-tosclassify/bwmd/flow.c 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/bwmd/flow.c 2005-01-21 06:42:26 UTC (rev 53) @@ -186,8 +186,8 @@ // Differences in queue when we done int acceptLen = 0, queuedLen = 0; int acceptSize = 0, queuedSize = 0; + - // Lock, hijack packets, unlock g_mutex_lock(pktQueue->lock); packets = pktQueue->packets; @@ -286,7 +286,9 @@ } } - // If packet is still ok to pass through, do our stuff + /* If packet is still ok to pass through + * Update our parent threshold stuff so we can calculate parent_th above + */ if (ok) { struct timeval curTime; @@ -319,8 +321,26 @@ // 2 seconds if (flow->curThroughputAge >= 2000000) { - flow->curThroughputAge -= 2000000; - flow->curThroughput = flow->curThroughputAge / 1000000.0 * flow->curThroughput; + float delta; + + // flow->curThroughputAge -= 2000000; + + // Get the fraction of time passed since last update + delta = flow->curThroughputAge / 1000000.0; + + // Calculate throughput + flow->curThroughput /= delta; + + // Calculate average queue size + flow->avgQueueSize = (flow->avgQueueSize + flow->curQueueSize) / delta; + /* + fprintf(stderr,"%s: curThroughput: %f, avgQueueSize: %li, delta: %f\n", + flow->flowName, + flow->curThroughput, + flow->avgQueueSize, + delta); + */ + flow->curThroughputAge = 0; } // Set this as the last time we updated our throughput @@ -381,7 +401,7 @@ // Lock everything g_mutex_lock(nextPktQueue->lock); g_mutex_lock(flow->lock); - // Add packet to parent queue & remove from child + // Append to parent nextPktQueue->packets = g_list_append(nextPktQueue->packets,packet); // Update next queue stats nextPktQueue->curLen++; @@ -417,7 +437,9 @@ g_mutex_lock(pktQueue->lock); if (packets) { + // Merge the rest in pktQueue->packets = g_list_concat(packets,pktQueue->packets); + // Signal that we just added to the queue g_mutex_lock(runnerData->bandSignalLock); // Check if we havn't already gotten the queue listed @@ -427,12 +449,13 @@ g_cond_signal(runnerData->bandSignalCond); g_mutex_unlock(runnerData->bandSignalLock); } + pktQueue->curLen -= (acceptLen + queuedLen); pktQueue->curSize -= (acceptSize + queuedLen); g_mutex_unlock(pktQueue->lock); - return(acceptLen); + return acceptLen; } @@ -441,9 +464,6 @@ void *flowRunner(void *data) { struct runnerData_t *runnerData = (struct runnerData_t*) data; - GList *queueChangeList[NUM_PRIO_BANDS]; - int i, pktsProcessed = 0; - GTimeVal mytime; // Our processing function @@ -454,19 +474,21 @@ // Check if we found a flow with a queue - pktsProcessed += processPktQueue(aRunnerData,pktQueue); + // NOTE: The function below returns the number of packets processed + processPktQueue(aRunnerData,pktQueue); } - // Allocate queue change list - for (i = 0; i < NUM_PRIO_BANDS; i++) - queueChangeList[i] = NULL; - logMessage(LOG_DEBUG, "Flow runner started...\n"); // Loop when we get a signal while (1) { + GTimeVal mytime; + unsigned char i; + GList *queueChangeList = NULL; + + g_mutex_lock(runnerData->bandSignalLock); // If the queue has changed proceed @@ -481,15 +503,14 @@ // Hijack the queue change list items for (i = 0; i < NUM_PRIO_BANDS; i++) { - // Copy list item over - queueChangeList[i] = runnerData->queueChangeList[i]; // Zero runner data if it is non-NULL if (runnerData->queueChangeList[i]) { - runnerData->queueChangeList[i] = NULL; + // Copy list item over + queueChangeList = g_list_concat(queueChangeList,runnerData->queueChangeList[i]); + // Blank used list... copy uses directly + runnerData->queueChangeList[i] = NULL; } - else - queueChangeList[i] = NULL; } runnerData->queueChanged = 0; @@ -497,15 +518,11 @@ g_mutex_unlock(runnerData->bandSignalLock); - // Process all list - for (i = 0; i < NUM_PRIO_BANDS; i++) + // Process list if it is non-NULL + if (queueChangeList) { - // Process list if it is non-NULL - if (queueChangeList[i]) - { - g_list_foreach(queueChangeList[i],processQueue,runnerData); - g_list_free(queueChangeList[i]); - } + g_list_foreach(queueChangeList,processQueue,runnerData); + g_list_free(queueChangeList); } } Modified: branch/bwmd-tosclassify/bwmd/ipq.c =================================================================== --- branch/bwmd-tosclassify/bwmd/ipq.c 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/bwmd/ipq.c 2005-01-21 06:42:26 UTC (rev 53) @@ -22,6 +22,7 @@ */ +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -31,7 +32,10 @@ #include "libipq.h" +#define QUEUE_HEAD 1 +#define QUEUE_TAIL 2 + // Destroy the ipq handle static void destroyIPQHandle(struct ipq_handle *h) { @@ -91,6 +95,8 @@ int status; int result; int drop = 0; + // Default to inserting at queue tail + unsigned char queuePos = QUEUE_TAIL; // Our find functions @@ -137,94 +143,171 @@ if (!foundQueue) { struct ip_packet_t *ip_packet = (struct ip_packet_t *) packet->payload->payload; - long int bandNum = -1; - + unsigned char prio = 0; + /* fprintf(stderr,"auto packet queue -> protocol = %i, src = %i.%i.%i.%i, dest = %i.%i.%i.%i, tos = 0x%x\n", ip_packet->protocol, ip_packet->u_saddr.addr.a, ip_packet->u_saddr.addr.b, ip_packet->u_saddr.addr.c, ip_packet->u_saddr.addr.d, ip_packet->u_daddr.addr.a, ip_packet->u_daddr.addr.b, ip_packet->u_daddr.addr.c, ip_packet->u_daddr.addr.d, IPTOS_PREC(ip_packet->tos)); -*/ - // Process a TCP packet - if (ip_packet->protocol == IPPROTO_TCP) - { - struct tcphdr *tcph = (struct tcphdr *) (packet->payload->payload + (ip_packet->ihl * 4)); -/* - fprintf(stderr," tcp -> sport = %i, dport = %i, prec = 0x%x\n", ntohs(tcph->source), - ntohs(tcph->dest), IPTOS_PREC(ip_packet->tos)); */ - bandNum = tcpPortToBand(bandNum,ntohs(tcph->dest)); - if (bandNum == -1) - bandNum = tcpPortToBand(bandNum,ntohs(tcph->source)); + + prio = autoClassify(ip_packet,foundFlow->prioClassifier); + + // If we didn't get anything set band number to 50, 50/50 + if (prio == 0) + prio = 50; + foundQueue = foundFlow->pktQueues[prio]; + } + + + // Lock flow before we fuck with it + g_mutex_lock(foundQueue->lock); + g_mutex_lock(P_FLOW(foundQueue,lock)); + + +/* This is my current work on implementing RED - nk...@lb... */ +#if 0 + { + /* Saved variables */ + unsigned int avg; // Average queue size + unsigned long int q_time; // Last time a packet was received + unsigned int count; // Packets since last one marked + /* Fixed params */ + Wq; // Weight of queue + min_th; // Min threshold of queue + max_th; // Max threshold of queue + max_p; // Max value for Pb + /* Other */ + float Pa; // Current packet marking probability + q; // Current queue size + time; // Current time + float Pb; + + + avg = 0; + count = -1; + + + LOOP WITH PACKETS + + calculate new average + + if queue is non empty + { + // Exponential weighted moving average (EWMA) + avg = (1 - Wq) * avg + Wq * q; } + else + { + } - // Process a ICMP packet - if (ip_packet->protocol == IPPROTO_ICMP) + if (min_th <= avg && avg < max_th) { -/* - struct icmphdr *icmph = (struct icmphdr *) (packet->payload->payload + (ip_packet->ihl * 4)); + count++; - fprintf(stderr,"something: icmp = %i, type = %i\n", icmph->code, icmph->type); -*/ - bandNum = 5; + Pb = max_p * (avg - min_p) / (max_th - min_th); + // Favour small packets + Pb = Pb * (packet_size / max_packet_size); + + Pa = Pb / (1 - count & Pb); + + // FIXME - mark packet with Pa + mark packet + count = 0; } - - // Process a UDP packet - if (ip_packet->protocol == IPPROTO_UDP) + else if (max_th <= avg) { - struct udphdr *udph = (struct udphdr *) (packet->payload->payload + (ip_packet->ihl * 4)); -/* - fprintf(stderr," udp -> sport = %i, dport = %i\n", ntohs(udph->source), - ntohs(udph->dest)); -*/ - bandNum = udpPortToBand(bandNum,ntohs(udph->dest)); - if (bandNum == -1) - bandNum = udpPortToBand(bandNum,ntohs(udph->source)); + // FIXME - mark packet; + count = 0; } - - // If we didn't get anything set band number to 50, 50/50 - if (bandNum == -1) - bandNum = 50; + else + count = -1; - foundQueue = foundFlow->pktQueues[bandNum]; + if queue is empty + q_time = time(); + + CONTINUE LOOP + + + } +#endif + + + + + + - - // Lock flow before we fuck with it - g_mutex_lock(foundQueue->lock); - g_mutex_lock(P_FLOW(foundQueue,lock)); - // Check first of all if we fucked over our one of our queue limits if (will_exceed_pkt_queue(foundQueue,PKT_SIZE(packet)) || will_exceed_flow_queue(foundQueue->parentFlow,PKT_SIZE(packet))) drop = 1; + // Or checkif we fell over our soft curve, slow start algo + else + { + long int maxQueueSize, curQueueSize, avgQueueSize; + /* Check if we must use our queue's size or parent flow queue size */ #if 0 - // Check second of all if we fucked our min threshold over - else if (TH_EXCEEDED(foundQueue,min_th)) - { - int j = 1 + (int) (10.0 * rand() / (RAND_MAX + 1.0)); - - if (TH_EXCEEDED(foundQueue,max_th)) + if (foundQueue->maxSize) { - if (j > 5) - drop = 1; + maxQueueSize = foundQueue->maxSize; + curQueueSize = foundQueue->curSize; } else { - if (j < 3) - drop = 1; +#endif + maxQueueSize = P_FLOW(foundQueue,maxQueueSize); + curQueueSize = P_FLOW(foundQueue,curQueueSize); + avgQueueSize = P_FLOW(foundQueue,avgQueueSize); +#if 0 } - } #endif + + // Check if we have limits to exceed + if (maxQueueSize && curQueueSize > 0 && avgQueueSize > 0) + { + float avgProb = 0, curProb = 0, prob = 0; + int min_th = 10; + double drand = drand48(); + + // nice soft curve flow based on average queue size, starts slow, increases fast will hit 100% probability at 75% + // FIXME - this is based on the flow's queue size, it should be configurable to the queue's queue size + //avgProb = powf((P_FLOW(foundQueue,avgQueueSize) / maxQueueSize * 1.25),3); + avgProb = powf((((float) avgQueueSize / (float) maxQueueSize) * 1.25),3); + // current queue size & threshold curve... sort of flatish, but starting slowish + curProb = powf(((float) curQueueSize / (float) maxQueueSize) + powf(((float) min_th / (float) 150),3),2) / 2; + prob = avgProb + curProb; + // Check if we should drop packet + drop = drand < prob; +/* + logMessage(LOG_DEBUG, "%s: Packet Drop Probability: %f (%li:%li) %f (%li:%li)\t%f\t%i\n", + P_FLOW(foundQueue,flowName), + avgProb,avgQueueSize,maxQueueSize, + curProb,curQueueSize,maxQueueSize, + avgProb + curProb, + drop); +*/ + } + + } + // Check if we must pass the packet if (!drop) { // Lock, queue... adjust stats - foundQueue->packets = g_list_append(foundQueue->packets,packet); + if (queuePos == QUEUE_TAIL) + foundQueue->packets = g_list_append(foundQueue->packets,packet); + else if (queuePos == QUEUE_HEAD) + { + // FIXME - APPEND TO LAST QUEUE + } + foundQueue->curSize += PKT_SIZE(packet); P_FLOW(foundQueue,curQueueSize) += PKT_SIZE(packet); foundQueue->curLen++; @@ -326,7 +409,6 @@ break; case IPQM_PACKET: - // Get packet details... g_mutex_lock(runnerData->IPQLock); m = ipq_get_packet(buf); Modified: branch/bwmd-tosclassify/configure =================================================================== --- branch/bwmd-tosclassify/configure 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/configure 2005-01-21 06:42:26 UTC (rev 53) @@ -22753,7 +22753,7 @@ done -# Check for glib 2.4.0 +# Check for glib 2.2.0 # Check whether --enable-glibtest or --disable-glibtest was given. if test "${enable_glibtest+set}" = set; then enableval="$enable_glibtest" @@ -22769,6 +22769,9 @@ gmodule) pkg_config_args="$pkg_config_args gmodule-2.0" ;; + gmodule-no-export) + pkg_config_args="$pkg_config_args gmodule-no-export-2.0" + ;; gobject) pkg_config_args="$pkg_config_args gobject-2.0" ;; @@ -22833,7 +22836,7 @@ no_glib=yes fi - min_glib_version=2.4.0 + min_glib_version=2.2.0 echo "$as_me:$LINENO: checking for GLIB - version >= $min_glib_version" >&5 echo $ECHO_N "checking for GLIB - version >= $min_glib_version... $ECHO_C" >&6 @@ -23077,11 +23080,11 @@ then echo echo "* - ERROR -" - echo "* glib >= 2.4.0 required, this includes the development libraries and headers" + echo "* glib >= 2.2.0 required, this includes the development libraries and headers" exit 1 fi -# Check for libxml 2.6.0 +# Check for libxml 2.5.0 # Check whether --with-xml-prefix or --without-xml-prefix was given. @@ -23160,7 +23163,7 @@ echo "${ECHO_T}no" >&6 fi - min_xml_version=2.6.0 + min_xml_version=2.5.0 echo "$as_me:$LINENO: checking for libxml - version >= $min_xml_version" >&5 echo $ECHO_N "checking for libxml - version >= $min_xml_version... $ECHO_C" >&6 no_xml="" @@ -23390,11 +23393,14 @@ then echo echo "* - ERROR -" - echo "* libxml >= 2.6.0 required, this includes the development libraries and headers" + echo "* libxml >= 2.5.0 required, this includes the development libraries and headers" exit 1 fi -XML_CFLAGS=$XML_CPPFLAGS +if test x"$XML_CFLAGS" = x +then + XML_CFLAGS=$XML_CPPFLAGS +fi Modified: branch/bwmd-tosclassify/configure.ac =================================================================== --- branch/bwmd-tosclassify/configure.ac 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/configure.ac 2005-01-21 06:42:26 UTC (rev 53) @@ -26,7 +26,7 @@ AC_GNU_SOURCE -AM_INIT_AUTOMAKE(1.8) +AM_INIT_AUTOMAKE(1.7) # Checks for programs. @@ -95,27 +95,30 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS([gettimeofday inet_ntoa memset select socket strcasecmp strchr strdup strerror strncasecmp strndup]) -# Check for glib 2.4.0 -AM_PATH_GLIB_2_0(2.4.0,have_glib=yes,have_glib=no,gthread) +# Check for glib 2.2.0 +AM_PATH_GLIB_2_0(2.2.0,have_glib=yes,have_glib=no,gthread) if test x"$have_glib" = x"no" then echo echo "* - ERROR -" - echo "* glib >= 2.4.0 required, this includes the development libraries and headers" + echo "* glib >= 2.2.0 required, this includes the development libraries and headers" exit 1 fi -# Check for libxml 2.6.0 -AM_PATH_XML2(2.6.0,have_xml=yes,have_xml=no) +# Check for libxml 2.5.0 +AM_PATH_XML2(2.5.0,have_xml=yes,have_xml=no) if test x"$have_xml" = x"no" then echo echo "* - ERROR -" - echo "* libxml >= 2.6.0 required, this includes the development libraries and headers" + echo "* libxml >= 2.5.0 required, this includes the development libraries and headers" exit 1 fi -XML_CFLAGS=$XML_CPPFLAGS +if test x"$XML_CFLAGS" = x +then + XML_CFLAGS=$XML_CPPFLAGS +fi AC_SUBST(XML_CFLAGS) Modified: branch/bwmd-tosclassify/doc/bwmtools.texi =================================================================== --- branch/bwmd-tosclassify/doc/bwmtools.texi 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/doc/bwmtools.texi 2005-01-21 06:42:26 UTC (rev 53) @@ -78,12 +78,48 @@ As long as your iptables supports the @option{-j QUEUE} target, traffic shaping will work. +@menu +* Features::BWM Tools Features +@end menu +@node Features +@section BWM Tools Features +@cindex features +This section lists a few features which make BWM Tools a good solution +for small to large enterprises@dots{} +@* +@itemize +@item Traffic Shaping +@itemize +@item Hierarchical flows +Allows you to embed flows within flows to form complex traffic shaping rules. +@item Parent burst thresholds +Parent burst thresholds allow child flows to burst until their parent flow +has reached a specific utilization threshold. +@end itemize +@item Graphing +@itemize +@item RRD Tool file support +Generation of rrdtool files which can be used to create custom graphs. +@item Builtin RRD Tool graphing support +BWM Tools can generate pretty looking graphs all by itself. Parameters for +graphing are discussed in the Graphing section. +@end itemize +@item Logging +@itemize +@item Logging of traffic +BWM Tools logs can log traffic stats to file at pre-defined intervals +for use in reporting or graphing. +@end itemize +@end itemize + + + @node Installation @chapter Installing BWM Tools Modified: branch/bwmd-tosclassify/include/autoclass.h =================================================================== --- branch/bwmd-tosclassify/include/autoclass.h 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/include/autoclass.h 2005-01-21 06:42:26 UTC (rev 53) @@ -26,12 +26,17 @@ #include <stdlib.h> +#include "flow.h" -// Band calculation functions, tcp -long int tcpPortToBand(long int bandNum, u_int16_t port); -// Band calculation functions, udp -long int udpPortToBand(long int bandNum, u_int16_t port); +// Classificaiton types... +#define AUTOCLASS_NONE 0 +#define AUTOCLASS_PORT 1 +#define AUTOCLASS_TOS 2 +// Auto classify packet and return priority (1 - best, 100 - worst) +unsigned char autoClassify(struct ip_packet_t *ip_packet, unsigned char prioClassifier); + + #endif Modified: branch/bwmd-tosclassify/include/flow.h =================================================================== --- branch/bwmd-tosclassify/include/flow.h 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/include/flow.h 2005-01-21 06:42:26 UTC (rev 53) @@ -59,7 +59,7 @@ { GMutex *lock; - long int prio; + unsigned char prio; struct flow_t *parentFlow; // void* because we cannot ref below? @@ -69,7 +69,7 @@ long int curLen; long int maxSize; long int maxLen; - + GList *packets; }; @@ -90,7 +90,7 @@ // Shaping struct flow_t *parent; // STATIC, not specified, determined - pointer to parent - int prio; // STATIC - Flow priority + unsigned char prioClassifier; // STATIC - Flow priority auto classifier long int nfmark; // STATIC - nfmark value i must match auto to queues long int maxQueueSize; // STATIC - max length in bytes of queue long int maxQueueLen; // STATIC - and/or length in items @@ -118,6 +118,7 @@ float curThroughput; // Current throughput unsigned int curThroughputAge; // How many microseconds since last throughput update + unsigned int avgQueueSize; // Average queue size struct timeval lastThroughputUpdate; // Last time the throughput was updated unsigned int accumMs; // Accumulated number of microseconds Modified: branch/bwmd-tosclassify/lib/Makefile.am =================================================================== --- branch/bwmd-tosclassify/lib/Makefile.am 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/lib/Makefile.am 2005-01-21 06:42:26 UTC (rev 53) @@ -26,6 +26,6 @@ lib_LTLIBRARIES = libbwm.la libbwm_la_SOURCES = xmlConf.c misc.c -libbwm_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) $(GMIME_CFLAGS) $(AM_CFLAGS) -libbwm_la_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) $(GMIME_LIBS) -version-info 1:0:0 +libbwm_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) $(AM_CFLAGS) +libbwm_la_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) -version-info 1:0:0 Modified: branch/bwmd-tosclassify/lib/Makefile.in =================================================================== --- branch/bwmd-tosclassify/lib/Makefile.in 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/lib/Makefile.in 2005-01-21 06:42:26 UTC (rev 53) @@ -204,8 +204,8 @@ target_alias = @target_alias@ lib_LTLIBRARIES = libbwm.la libbwm_la_SOURCES = xmlConf.c misc.c -libbwm_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) $(GMIME_CFLAGS) $(AM_CFLAGS) -libbwm_la_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) $(GMIME_LIBS) -version-info 1:0:0 +libbwm_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) $(AM_CFLAGS) +libbwm_la_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) -version-info 1:0:0 all: all-am .SUFFIXES: Modified: branch/bwmd-tosclassify/lib/xmlConf.c =================================================================== --- branch/bwmd-tosclassify/lib/xmlConf.c 2005-01-21 06:38:35 UTC (rev 52) +++ branch/bwmd-tosclassify/lib/xmlConf.c 2005-01-21 06:42:26 UTC (rev 53) @@ -29,6 +29,7 @@ #include <time.h> #include <libxml/xmlmemory.h> #include <libxml/parser.h> +#include "autoclass.h" #include "common.h" #include "flow.h" #include "xmlConf.h" @@ -415,6 +416,8 @@ done = 1; if (!done && !xmlStrcmp(key,"report-timeout")) done = 1; + if (!done && !xmlStrcmp(key,"prio-classifier")) + done = 1; if (!done && !xmlStrcmp(key,"burst-rate")) done = 1; if (!done && !xmlStrcmp(key,"max-rate")) @@ -645,6 +648,7 @@ long int maxRate, long int burstRate, long int nfmark, + unsigned char prioClassifier, float parent_th, int reportTimeout) { @@ -676,6 +680,9 @@ flow->burstRate = burstRate; flow->nfmark = nfmark; + // Set the priority classifier + flow->prioClassifier = prioClassifier; + flow->parent_th = parent_th; flow->counterTimeout = reportTimeout; @@ -720,6 +727,7 @@ gettimeofday(&flow->lastThroughputUpdate,NULL); flow->curThroughputAge = 0; flow->curThroughput = 0; + flow->avgQueueSize = 0; // Set last time we calculated credit and the rest... flow->accumMs = 0; gettimeofday(&flow->lastCreditCalc,NULL); @@ -746,22 +754,18 @@ if (flow->maxQueueLen == -1) { if (flow->maxRate != 0) - flow->maxQueueLen = 5; // Seems an OK value for normal use? + flow->maxQueueLen = ((flow->burstRate + flow->maxRate) / 2 / 750) * 2; // Seems an OK value for normal use? else flow->maxQueueLen = 0; } if (flow->maxQueueSize == -1) { if (flow->maxRate != 0) - flow->maxQueueSize = 4096; // Let us queue at least 2 big packets and some small ones + flow->maxQueueSize = (flow->burstRate + flow->maxRate); // Normal use, this should be ok? else flow->maxQueueSize = 0; } - // Calculate our thresholds - //flow->min_th = (flow->maxRate / 750); - //flow->max_th = (flow->maxRate / 750) * 4; - // Blank all queues for (i = 0; i < NUM_PRIO_BANDS; i++) { @@ -927,6 +931,7 @@ { char *p; long int statsLen, maxQueueSize, maxQueueLen, maxRate, burstRate, reportTimeout, nfmark; + unsigned char prioClassifier = AUTOCLASS_PORT; float parent_th; @@ -967,9 +972,24 @@ reportTimeout = 30; } + // Work out automatic classifier to use + if ((p = g_hash_table_lookup(tagProperties,"prio-classifier")) != NULL) + { + if (strcasecmp(p,"tos") == 0) + prioClassifier = AUTOCLASS_TOS; + else if (strcasecmp(p,"port") == 0) + prioClassifier = AUTOCLASS_PORT; + else if (strcasecmp(p,"none") == 0) + prioClassifier = AUTOCLASS_NONE; + else + fprintf(stderr,"ERROR: %s - Tag value for \"prio-classifier\" is invalid, please read manual\n",flowName); + } + else + prioClassifier = AUTOCLASS_NONE; + // Create our flow newFlow = createFlow(flowName,parentFlow,statsLen,maxQueueSize,maxQueueLen,maxRate,burstRate,nfmark, - parent_th,reportTimeout); + prioClassifier,parent_th,reportTimeout); flows = g_list_append(flows,newFlow); } |