[ns] [PATCH] Queue/PI validation failed
Joerg Diederich
dieder@ibr.cs.tu-bs.de
Mon Aug 4 09:55:03 2003
Hi,
I looked a bit deeper into the problem why the validation of Queue/PI
fails on certain platforms (including mine :-)
As far as I could find out, it is some sort of a namespace problem,
which maybe related to the compiler (gcc 2.95.4 in my case).
The problem is that 'struct edv' and 'struct edp' in pi.h are already
defined in red.h Renaming both to 'struct edv_pi' and 'struct edp_pi'
solved the problem with segmentation faults in my case. A patch
against the today's snapshot is attached.
BTW: the validation script is also buggy: There are two links
(duplex...) between r1 and r2 in the 'net3' scenario. Patch is also
attached.
The patch also contains a fix against a standard mistake when dealing
with strings ('\0' also needs space in the traceType string and
strlen() returns the length excluding '\0'...)
Best regards,
/Jörg
Index: queue/pi.cc
===================================================================
RCS file: /ibr/cvs/ns-2/queue/pi.cc,v
retrieving revision 1.1.1.1
diff -u -b -B -r1.1.1.1 pi.cc
--- queue/pi.cc 31 Jul 2003 17:45:52 -0000 1.1.1.1
+++ queue/pi.cc 4 Aug 2003 16:47:00 -0000
@@ -67,7 +67,7 @@
qib_(0), de_drop_(NULL), EDTrace(NULL), tchan_(0), curq_(0),
edp_(), edv_(), first_reset_(1)
{
- if (strlen(trace) >=20) {
+ if (strlen(trace) >=19) {
printf("trace type too long - allocate more space to traceType in pi.h and recompile\n");
exit(0);
}
Index: queue/pi.h
===================================================================
RCS file: /ibr/cvs/ns-2/queue/pi.h,v
retrieving revision 1.1.1.1
diff -u -b -B -r1.1.1.1 pi.h
--- queue/pi.h 31 Jul 2003 17:45:52 -0000 1.1.1.1
+++ queue/pi.h 4 Aug 2003 16:28:11 -0000
@@ -57,7 +57,7 @@
/*
* Early drop parameters, supplied by user
*/
-struct edp {
+struct edp_pi {
/*
* User supplied.
*/
@@ -67,18 +67,18 @@
double a, b; /* parameters to pi controller */
double w; /* sampling frequency (# of times per second) */
double qref; /* desired queue size */
- edp(): mean_pktsize(0), bytes(0), setbit(0), a(0.0), b(0.0), w(0.0), qref(0.0) { }
+ edp_pi(): mean_pktsize(0), bytes(0), setbit(0), a(0.0), b(0.0), w(0.0), qref(0.0) { }
};
/*
* Early drop variables, maintained by PI
*/
-struct edv {
+struct edv_pi {
TracedDouble v_prob; /* prob. of packet drop before "count". */
int count; /* # of packets since last drop */
int count_bytes; /* # of bytes since last drop */
int qold;
- edv() : v_prob(0.0), count(0), count_bytes(0), qold(0) { }
+ edv_pi() : v_prob(0.0), count(0), count_bytes(0), qold(0) { }
};
class LinkDelay;
@@ -124,8 +124,8 @@
TracedInt curq_; /* current qlen seen by arrivals */
void trace(TracedVar*); /* routine to write trace records */
- edp edp_; /* early-drop params */
- edv edv_; /* early-drop variables */
+ edp_pi edp_; /* early-drop params */
+ edv_pi edv_; /* early-drop variables */
int first_reset_; /* first time reset() is called */
Index: tcl/test/test-suite-pi.tcl
===================================================================
RCS file: /ibr/cvs/ns-2/tcl/test/test-suite-pi.tcl,v
retrieving revision 1.1.1.1
diff -u -b -B -r1.1.1.1 test-suite-pi.tcl
--- tcl/test/test-suite-pi.tcl 29 Jul 2003 20:37:24 -0000 1.1.1.1
+++ tcl/test/test-suite-pi.tcl 4 Aug 2003 16:42:44 -0000
@@ -135,7 +135,6 @@
$ns duplex-link $node_(s1) $node_(r1) 10Mb 0ms DropTail
$ns duplex-link $node_(s2) $node_(r1) 10Mb 1ms DropTail
$ns duplex-link $node_(r1) $node_(r2) 1.5Mb 10ms PI
- $ns duplex-link $node_(r2) $node_(r1) 1.5Mb 10ms PI
$ns queue-limit $node_(r1) $node_(r2) 100
$ns queue-limit $node_(r2) $node_(r1) 100
$ns duplex-link $node_(s3) $node_(r2) 10Mb 2ms DropTail