nse.patch 72.4 KB
Newer Older
1
2
--- dist-ns-allinone-2.26/install	Wed Feb 26 16:07:51 2003
+++ ns-allinone-2.26/install	Thu Jun  5 16:55:16 2003
3
@@ -41,301 +41,47 @@
4
5
 # Get current path
 CUR_PATH=`pwd`
6
7
8
 
-# Check if we are using Cygwin, and if so, if it is a bona fide install
-# Cygwin patches contributed by Nicolas Christin <nicolas@cs.virginia.edu>
9
10
11
12
13
+if [ -x /usr/local/tcl8.3.2/bin/tclsh8.3 ] ; then
+  V_TCLSH=/usr/local/tcl8.3.2/bin/tclsh8.3 
+  export V_TCLSH
+  WITHTCL_PATH=/usr/local/tcl8.3.2
+  export WITHTCL_PATH
14
 
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
-echo "============================================================"
-echo "* Testing for Cygwin environment"
-echo "============================================================"
-
-if [ -x /usr/bin/uname ]; then
-        # it may be a Cygwin install
-        test_cygwin=`uname | tr [a-z] [A-Z] | sed -e 's|.*CYGWIN.*|true|'`;
-        if  [ "${test_cygwin}" = "true" ]; then
-                echo "Cygwin detected";
-                echo "Note: Cygwin install is still considered EXPERIMENTAL";
-                echo "";
-                echo -n "Checking Cygwin version is >=1.3.12... "
-                cmaj=` uname -r | sed -e 's/^\([0-9]*\)\.\([0-9]*\).\([0-9]*\).*/\1/'`;
-                echo $cmaj | grep -v [0-9] >/dev/null 2>&1
-                if [ "$?" -eq "0" ]; then
-                        cmaj=0;
-                fi;
-                cmin=` uname -r | sed -e 's/^\([0-9]*\)\.\([0-9]*\).\([0-9]*\).*/\2/'`;
-                echo $cmin | grep -v [0-9] >/dev/null 2>&1
-                if [ "$?" -eq "0" ]; then
-                        cmin=0;
-                fi;
-                cpat=` uname -r | sed -e 's/^\([0-9]*\)\.\([0-9]*\).\([0-9]*\).*/\3/'`;
-                echo $cpat | grep -v [0-9] >/dev/null 2>&1
-                if [ "$?" -eq "0" ]; then
-                        cpat=0;
-                fi;
-                echo -n "$cmaj.$cmin.$cpat ";
-                if ([ "$cmaj" -gt "1" ]) || ([ "$cmaj" -eq "1" ] && [ $cmin -gt "3" ]) || ([ "$cmaj" -eq 1 ] && [ $cmin -eq "3" ] && [ "$cpat" -ge "12" ]); then
-                        echo "should be ok";
-                else
-                        echo "*** POSSIBLE PROBLEM ***";
-                        echo "";
-                        echo "ns-allinone-${NSVER} has not been tested under versions of Cygwin older than";
-                        echo "1.3.12. Your version ($cmaj.$cmin.$cpat) appears to be older than that. Success of";
-                        echo "the install process is therefore NOT GUARANTEED.";
-                        echo "";
-                        cygversion="failed";                
-		fi;
-                echo -n "Checking filesystems are mounted as UNIX filetype... ";
-                mount | grep "textmode" >/dev/null 2>&1;
-                if [ "$?" -eq "0" ]; then
-                        echo "*** NO! ***";
-                        mount_test="failed";
-                        echo "";
-                        echo "It appears that some of your Cygwin shares are mounted as DOS file";
-                        echo "type. This has not been tested, but is likely to result in failure of";
-                        echo "validation tests. Success of the install process is also NOT";
-                        echo "GUARANTEED.";
-                        echo "";
-                        echo "Refer to the Cygwin user guide for how to install Cygwin with the UNIX";
-                        echo "file text mode.";
-                        echo "";
-                else
-                        echo "yes";
-                        echo -n "Checking default mode is binmode... ";
-                        echo ${CYGWIN} | grep "nobinmode" >/dev/null 2>&1;
-                        if [ "$?" -eq "0" ]; then
-                                cyg_env_var="failed";
-                                echo "*** NO! ***";
-                                echo "";
-                                echo "Your \$CYGWIN environment variable specifies \"nobinmode\". This is";
-                                echo "likely to result in failure of validation tests, and (possibly) of";
-                                echo "the whole install process. You need to have the \$CYGWIN environment";
-                                echo "variable set to \"binmode\". Please refer to the Cygwin user guide for";
-                                echo "details on how to change this.";
-                                echo "";
-                        else 
-                                echo "yes";
-                        fi;
-                fi;                           
-                if [ "$cygversion" = "failed" ] || [ "$cyg_env_var" = "failed" ] || [ "$mount_test" = "failed" ]; then
-                        echo "";
-                        echo "Tests indicate that your installation of Cygwin may not be suitable for";
-                        echo "installing ns-2 allinone.";
-                        echo "";
-                        echo -n "Do you wish to proceed regardless? [y/n] "
-                        read answer;
-                        if [ "$answer" != "y" ] && [ "$answer" != "Y" ]; then
-                                die "Installation aborted...";
-                        fi;
-                fi;
-                echo "Patching Tcl for Cygwin.";
-                if [ ! -f ./tcl${TCLVER}/generic/tcl.h.orig ]; then
-                        cp ./tcl${TCLVER}/generic/tcl.h ./tcl${TCLVER}/generic/tcl.h.orig;
-                        echo "The original tcl${TCLVER}/generic/tcl.h is backed up as tcl${TCLVER}/generic/tcl.h.orig";
-                        sed -e 's/\#define _TCL/\#define _TCL\`\`\#ifdef __CYGWIN__\`\#define HAVE_TM_ZONE 1\`\#endif \/\* __CYGWIN__ \*\//g' ./tcl${TCLVER}/generic/tcl.h.orig | tr '\`' '\n' > ./tcl${TCLVER}/generic/tcl.h;
-                fi;
-                touch ./tcl${TCLVER}/generic/tclStubInit.c;
-                echo "Patching sgb for Cygwin.";
-                cp ./sgb/Makefile ./sgb/Makefile.orig;
-                echo "The original sgb/Makefile is backed up as sgb/Makefile.orig";
-                sed -e 's|rm \(.*\)test_io test_graph test_flip test_sample\(.*\)|rm -f \1test_io.exe test_graph.exe test_flip.exe test_sample.exe\2|' ./sgb/Makefile.orig > ./sgb/Makefile;
-                echo "Setting executable format to .exe...";
-                EXE=".exe";
-        else
-                echo "Cygwin not detected, proceeding with regular install.";
-                EXE=;
-        fi;
-else
-        echo "Cygwin not detected, proceeding with regular install.";
-fi;
-
-
-
120
-# Compile and install xgraph
121
-
122
123
124
125
126
-echo "============================================================"
-echo "* Build XGraph-$XGRAPHVER"
-echo "============================================================"
-
-cd ./xgraph-$XGRAPHVER
127
128
129
130
-./configure --prefix=../
-if  [ "${test_cygwin}" = "true" ]; then
-       touch stamp-h;
-fi;
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
-if make
-then
-	echo "xgraph has been installed successfully. "
-else 
-	echo "Can not create xgraph; But xgraph is an optional package, continuing..."
-fi
-
-cd ../
-
-# Compile and install cweb and sgblib
-
-echo "============================================================"
-echo "* Build CWeb"
-echo "============================================================"
-
-cd ./cweb
-
-if [ ! -f ./Makefile ]
-then
-	echo "ns-allinone unable to install cweb for you. Please install it manually. cweb is used by sgb to create sgblibrary needed by scenario-generator. But this will not affect the use of ns as such, so continue.."
-else
-	echo "Making cweb"
-	touch *.c
-	make all || warn "cweb failed to make, but it's optional"
-	# xxx: other stuff will fail...
156
157
-	chmod 755 cweave${EXE}
-	chmod 755 ctangle${EXE}
158
159
160
161
162
163
164
-	cd ..
-	#echo "cd .."
-	if [ ! -d bin ]
-	then
-		mkdir bin
-	fi
-	cd bin
165
166
-	ln -s $CUR_PATH/cweb/cweave${EXE} cweave${EXE}
-	ln -s $CUR_PATH/cweb/ctangle${EXE} ctangle${EXE}
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
-fi
-
-cd ..
-PATH=$CUR_PATH/bin:$PATH
-export PATH
-
-echo "============================================================"
-echo "* Build Stanford GraphBase"
-echo "============================================================"
-
-cd ./sgb
-if [ ! -f ./Makefile ]
-	then
-	echo "Unable to create sgb library. This library is used by gt-itm and so for scenario generators. If you already have sgblib (possible if you are on solaris,sunos or freebsd platforms) you may still be able to run gt-itm. so continuing.."
-else
-	echo "Making sgb"
-	if make tests
-	then
-                if [ -f libgb.a ] ; then
-                        rm -f ../gt-itm/lib/libgb.a
187
-			cp libgb.a ../gt-itm/lib/libgb.a
188
-                else 
189
190
-		        echo "* Weird: sgb said it has been built but we can't find libgb.a! "
-			exit -1
191
192
-                fi
-	else
193
-	        echo "Unable to create sgb library, but it's optional, so continuing..."
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
-	fi
-fi
-
-cd ..
-
-# Compile and install gt-itm & sgb2ns
-
-echo "============================================================"
-echo "* Build GT-ITM"
-echo "============================================================"
-
-if [ -f ./gt-itm/lib/libgb.a ]
-then
- if [ ! -f ./gt-itm/src/Makefile ] 
-    then
-    echo "ns-alline is unable to install gt-itm sgb2ns for you, please install"
-    echo "them manually. You can't run scenario generator without gt-itm"
-    echo "and sgb2ns. But it will not affect you use ns, so continue ..."
- else
-    cd ./gt-itm/src
-    if make
-    then
-      echo "gt-itm has been installed successfully."
-    fi
-    
-    cd ../sgb2ns
-    if make
-    then
-      echo "sgb2ns has been installed successfully."
-    fi
-   cd ../../
- fi
-else
-    echo "sgb lib not found. gt-itm & sgb2ns could not be installed. Continuing.."
-fi
-
-# Build zlib
-
-echo "============================================================"
-echo "* Build zlib"
-echo "============================================================"
-
236
-cd ./zlib-1.1.4
237
238
239
240
241
242
243
244
245
246
-
-if ./configure --exec-prefix=../ --prefix=../
-then
-	if make
-	then
-		echo "Zlib has been installed successfully."
-	else
-		warn "Zlib make failed, but it's optional Continue ..."
-	fi
-else
247
-	warn "Zlib-1.1.4 configuration failed, but it's optional, so continuing ..."
248
249
250
251
-fi
-
-cd ../
-
252
-# Build Tcl8.3.5
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
-
-echo "============================================================"
-echo "* Build tcl$TCLVER"
-echo "============================================================"
-
-cd ./tcl$TCLVER/unix
-if [ -f Makefile ] ; then 
-	make distclean
-fi
-
-blame='Tcl is not part of the ns project.  Please see www.Scriptics.com
-to see if they have a fix for your platform.'
-./configure --enable-gcc --disable-shared --prefix=$CUR_PATH || die "tcl8.3.2 configuration failed! Exiting ..."
-if make 
-then 
-	echo "tcl$TCLVER make succeeded."
-	make install || die "tcl$TCLVER installation failed."
-	echo "tcl$TCLVER installation succeeded."
-	cp ../generic/*.h ../../include
272
 else
273
274
275
276
-	echo "tcl$TCLVER make failed! Exiting ..."
-	echo "For problems with Tcl/Tk see http://www.scriptics.com"
-	exit
-fi
277
 
278
-cd ../../
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
+  # Build Tcl8.3.5
+
+  echo "============================================================"
+  echo "* Build tcl$TCLVER"
+  echo "============================================================"
+
+  cd ./tcl$TCLVER/unix
+  if [ -f Makefile ] ; then 
+	  make distclean
+  fi
+
+  blame='Tcl is not part of the ns project.  Please see www.Scriptics.com
+  to see if they have a fix for your platform.'
+  ./configure --enable-gcc --disable-shared --prefix=$CUR_PATH || die "tcl8.3.2 configuration failed! Exiting ..."
+  if make 
+  then 
+  	  echo "tcl$TCLVER make succeeded."
+	  make install || die "tcl$TCLVER installation failed."
+	  echo "tcl$TCLVER installation succeeded."
+	  cp ../generic/*.h ../../include
+  else
+	  echo "tcl$TCLVER make failed! Exiting ..."
+	  echo "For problems with Tcl/Tk see http://www.scriptics.com"
+	  exit
+  fi
 
305
-# compile and install tk
306
307
+  cd ../../
 
308
309
310
-echo "============================================================"
-echo "* Build Tk$TKVER"
-echo "============================================================"
311
312
313
+  WITHTCL_PATH=$CUR_PATH/tcl$TCLVER
+  export WITHTCL_PATH
 
314
315
316
-cd ./tk$TKVER/unix
-if [ -f Makefile ] ; then
-	make distclean
317
318
 fi
 
319
320
321
322
323
324
325
326
327
328
329
330
-blame='Tk is not part of the ns project.  Please see www.Scriptics.com
-to see if they have a fix for your platform.'
-./configure --enable-gcc --disable-shared --prefix=$CUR_PATH || die "tk8.3.2 configuration failed! Exiting ..."
-if make 
-then
-	echo "tk$TKVER build succeeded."
-	make install || die "tk$TKVER installation failed."
-	echo "tk$TKVER installation succeeded."
-else
-	echo "tk$TKVER make failed! Exiting ..."
-	echo "For problems with Tcl/Tk see http://www.scriptics.com"
-	exit
331
-fi
332
-
333
-cd ../../
334
-
335
336
337
338
339
340
341
 #
 # Since our configures search for tclsh in $PATH, the following 
 # is needed. This is necessary for otcl/tclcl/ns/nam
@@ -345,28 +91,40 @@
 LD_LIBRARY_PATH=$CUR_PATH/tcl$TCLVER/unix:$CUR_PATH/tk$TKVER/unix:$LD_LIBRARY_PATH
 export LD_LIBRARY_PATH
 
342
-# Build otcl
343
344
+if [ -d /usr/local/otcl-1.0a8 ] ; then
 
345
346
347
-echo "============================================================"
-echo "* Build OTcl-$OTCLVER"
-echo "============================================================"
348
349
350
+  WITHOTCL_PATH=/usr/local/otcl-1.0a8
+  export WITHOTCL_PATH
 
351
-cd ./otcl-$OTCLVER
352
353
+else
 
354
355
356
-blame='Please check http://www.isi.edu/nsnam/ns/ns-problems.html
-for common problems and bug fixes.'
-./configure || die "otcl-$OTCLVER configuration failed! Exiting ..."
357
358
+  # Build otcl
 
359
360
361
362
363
364
365
366
-if make 
-then
-	echo "otcl-$OTCLVER has been installed successfully."
-else
-	echo "otcl-$OTCLVER make failed! Exiting ..."
-	echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
-	exit
-fi
367
368
369
370
371
372
373
374
375
376
+  echo "============================================================"
+  echo "* Build OTcl-$OTCLVER"
+  echo "============================================================"
+
+  cd ./otcl-$OTCLVER
+
+  blame='Please check http://www.isi.edu/nsnam/ns/ns-problems.html
+  for common problems and bug fixes.'
+  ./configure || die "otcl-$OTCLVER configuration failed! Exiting ..."
 
377
-cd ..
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
+  if make 
+  then
+  	  echo "otcl-$OTCLVER has been installed successfully."
+  else
+	  echo "otcl-$OTCLVER make failed! Exiting ..."
+	  echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
+	  exit
+  fi
+
+  cd ..
+
+  WITHOTCL_PATH=`pwd`/otcl-$OTCLVER
+  export WITHOTCL_PATH
+
+fi
 
394
 # Build tclcl
395
 
396
@@ -376,7 +134,7 @@
397
 
398
 cd ./tclcl-$TCLCLVER
399
 
400
401
-./configure || die "tclcl-$TCLCLVER configuration failed! Exiting ..."
+./configure --enable-static --with-tcl=$WITHTCL_PATH --with-otcl=$WITHOTCL_PATH || die "tclcl-$TCLCLVER configuration failed! Exiting ..."
402
 
403
404
 if make
 then
405
@@ -397,40 +155,20 @@
406
 echo "============================================================"
407
 
408
409
 cd ./ns-$NSVER
-./configure || die "Ns configuration failed! Exiting ..."
410
+./configure --enable-static --with-tcl=$WITHTCL_PATH --with-otcl=$WITHOTCL_PATH || die "Ns configuration failed! Exiting ..."
411
 
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
-if make
+if make nse
 then
-	echo " Ns has been installed successfully." 
+	echo " Nse has been installed successfully." 
 else
-	echo "Ns make failed!"
+	echo "Nse make failed!"
 	echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
 	exit
 fi
 
 cd ../
 
-# Build nam
427
-
428
429
430
431
432
433
-echo "============================================================"
-echo "* Build nam-$NAMVER"
-echo "============================================================"
-
-cd ./nam-$NAMVER
-
434
-./configure --with-tclcl=$CUR_PATH/tclcl-$TCLCLVER  || die "Nam configuration failed! Exiting ..."
435
436
437
438
439
440
441
442
443
444
445
446
-
-if make
-then 
-    echo "Nam has been installed successfully."
-else
-    echo "Nam make failed! Continue ..."
-    echo "See http://www.isi.edu/nsnam/ns-problems.html for problems"
-fi
-
-cd ../
-
-# Install nam, ns, xgraph into bin
447
+# Install nse into bin
448
 
449
450
 if [ ! -d bin ] ; then
     mkdir bin
451
@@ -438,55 +176,14 @@
452
 
453
 cd bin
454
 
455
-ln -s $CUR_PATH/ns-$NSVER/ns${EXE} ns${EXE}
456
-
457
-if test -x $CUR_PATH/nam-$NAMVER/nam${EXE}
458
-then
459
-    ln -s $CUR_PATH/nam-$NAMVER/nam${EXE} nam${EXE}
460
461
462
463
-else
-    echo "Please compile your nam separately."
-fi
-
464
-if test -x $CUR_PATH/xgraph-$XGRAPHVER/xgraph${EXE}
465
-then
466
-    ln -s $CUR_PATH/xgraph-$XGRAPHVER/xgraph${EXE} xgraph${EXE}
467
468
469
470
-else
-    echo "Please compile your xgraph separately."
-fi
-
471
-if test -x $CUR_PATH/gt-itm/bin/sgb2ns${EXE}
472
-then 
473
474
475
476
477
478
-    ln -s $CUR_PATH/gt-itm/bin/sgb2ns${EXE} sgb2ns${EXE}
-    ln -s $CUR_PATH/gt-itm/bin/sgb2hierns${EXE} sgb2hierns${EXE}
-    ln -s $CUR_PATH/gt-itm/bin/sgb2comns${EXE} sgb2comns${EXE}
-    ln -s $CUR_PATH/gt-itm/bin/itm${EXE} itm${EXE}
-    ln -s $CUR_PATH/gt-itm/bin/sgb2alt${EXE} sgb2alt${EXE}
-    ln -s $CUR_PATH/gt-itm/bin/edriver${EXE} edriver${EXE}
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
-else
-    echo "Please compile your gt-itm & sgb2ns separately."
-fi
+ln -s $CUR_PATH/ns-$NSVER/nse nse
 
 echo "Ns-allinone package has been installed successfully."
 echo "Here are the installation places:"
 echo "tcl$TCLVER:	$CUR_PATH/{bin,include,lib}"
-echo "tk$TKVER:		$CUR_PATH/{bin,include,lib}"
 echo "otcl:		$CUR_PATH/otcl-$OTCLVER"
 echo "tclcl:		$CUR_PATH/tclcl-$TCLCLVER"
-echo "ns:		$CUR_PATH/ns-$NSVER/ns"
-
-if [ -x $CUR_PATH/nam-$NAMVER/nam ]
-then
-echo "nam:	$CUR_PATH/nam-$NAMVER/nam"
-fi
-
-if [ -x $CUR_PATH/xgraph-$XGRAPHVER/xgraph ]
-then
-echo "xgraph:	$CUR_PATH/xgraph-$XGRAPHVER"
-fi
-if [ -x $CUR_PATH/gt-itm/bin/sgb2ns ] 
-then
-echo "gt-itm:   $CUR_PATH/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns"
-fi
+echo "nse:		$CUR_PATH/ns-$NSVER/nse"
 
 echo ""
 echo "----------------------------------------------------------------------------------"
509
510
511
--- dist-ns-allinone-2.26/ns-2.26/Makefile.in	Thu Feb 27 17:51:25 2003
+++ ns-allinone-2.26/ns-2.26/Makefile.in	Thu Jun  5 17:10:45 2003
@@ -79,6 +79,14 @@
512
513
514
515
516
 
 CFLAGS	= $(CCOPT) $(DEFINE)
 
+#### with event system
+INCLUDES += -I../.. -I../../../lib -I../../../../lib/libtb `elvin-config --cflags vin4c`
517
+CFLAGS += -DUSEEVENTS -DUSEROUTES -DADD_ETHER_OVERHEAD -DGETTIME_TSC
Shashi Guruprasad's avatar
Shashi Guruprasad committed
518
+LIB += -L../../../lib -L../../../../lib/libtb -levent -ltb -lcrypto
519
520
521
522
523
524
525
+LIB += `elvin-config --libs vin4c`
+STATIC += -static
+####
+
 # Explicitly define compilation rules since SunOS 4's make doesn't like gcc.
 # Also, gcc does not remove the .o before forking 'as', which can be a
 # problem if you don't own the file but can write to the directory.
526
@@ -276,6 +284,7 @@
527
528
 	mcast/lms-sender.o \
 	@V_STLOBJ@
529
 
530
+OBJ_CC += ../../tbevent.o
531
 
532
533
 # don't allow comments to follow continuation lines
 
534
@@ -303,6 +312,10 @@
535
536
537
538
539
 	emulate/nat.o  \
 	emulate/iptap.o \
 	emulate/tcptap.o
+
+##### nse with event system
540
+OBJ_EMULATE_CC += ../../tbnexthop.o
541
542
543
544
+####
 
 OBJ_EMULATE_C = \
 	emulate/inet.o
545
546
--- dist-ns-allinone-2.26/ns-2.26/apps/telnet.cc	Wed Feb 26 15:07:16 2003
+++ ns-allinone-2.26/ns-2.26/apps/telnet.cc	Thu Jun  5 17:12:02 2003
547
548
549
550
551
552
553
554
555
@@ -77,7 +77,7 @@
 {
         if (running_) {
 	        /* call the TCP advance method */
-		agent_->sendmsg(agent_->size());
+		agent_->sendmsg(1); // send 1 byte packets instead of 1460
 		/* reschedule the timer */
 		double t = next();
 		timer_.resched(t);
556
557
--- dist-ns-allinone-2.26/ns-2.26/common/scheduler.cc	Wed Feb 26 15:07:41 2003
+++ ns-allinone-2.26/ns-2.26/common/scheduler.cc	Fri Jun  6 18:19:59 2003
558
@@ -46,12 +46,42 @@
559
560
561
562
563
564
565
 #include "config.h"
 #include "scheduler.h"
 #include "packet.h"
+#ifdef USEEVENTS
+#include "tbevent.h"
+#endif
 
566
 
567
568
569
570
571
572
573
574
575
576
 #ifdef MEMDEBUG_SIMULATIONS
 #include "mem-trace.h"
 #endif
 
+#ifdef MEASURE_EVENT_RATE
+
+unsigned long long event_dispatch_counter;
+unsigned int events_per_sec_arr[70];
+
+#endif
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
+
+#ifdef GETTIME_TSC
+
+#define read_tsc()      \
+    ({ \
+        unsigned long low, high; \
+        asm volatile( \
+        ".byte 0x0f; .byte 0x31" \
+        : "=d" (high), "=a" (low)); \
+        ((unsigned long long)high << 32) | low; \
+    })
+
+#define TSC_FREQ     851.94
+#define TSC_COUNT_PERSEC (TSC_FREQ * 1000000)
+
+#endif
+
+#ifdef SCHED_DEBUG
+static Tcl_HashTable newevents;
+#endif
597
598
599
+
 Scheduler* Scheduler::instance_;
 scheduler_uid_t Scheduler::uid_ = 1;
600
 
601
@@ -62,6 +92,9 @@
602
603
604
605
606
607
608
609
610
 
 Scheduler::Scheduler() : clock_(SCHED_START), halted_(0)
 {
+#ifdef SCHED_DEBUG
+	  Tcl_InitHashTable( &newevents, TCL_ONE_WORD_KEYS );
+#endif
 }
 
 Scheduler::~Scheduler(){
611
@@ -112,6 +145,17 @@
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
 
 	e->time_ = t;
 	insert(e);
+#ifdef SCHED_DEBUG
+	int newentry = 0 ;
+	Tcl_HashEntry *he = Tcl_CreateHashEntry( &newevents,
+						 (char *)((unsigned int)e->uid_),
+						 &newentry );
+	if( newentry == 0 ) {
+	  fprintf(stderr, "e->uid_ = %d already present. error\n", (unsigned int)e->uid_);
+	} else {
+	  Tcl_SetHashValue( he, (char *)h );
+	}
+#endif
 }
 
 void
629
@@ -579,7 +623,7 @@
630
631
632
 	}
 } class_calendar_sched;
 
633
-CalendarScheduler::CalendarScheduler() : cal_clock_(clock_) {
634
+CalendarScheduler::CalendarScheduler() : cal_clock_(clock_), cached_head_(0) {
635
 	reinit(4, 1.0, cal_clock_);
636
 }
637
 
638
639
640
641
@@ -598,6 +642,7 @@
 		// may happen in RT scheduler
 		cal_clock_ = e->time_;
 		i = lastbucket_ = CALENDAR_HASH(cal_clock_);
642
+		cached_head_ = e;
643
644
 	} else
 		i = CALENDAR_HASH(e->time_);
645
 
646
@@ -703,6 +748,10 @@
647
648
 	if (qsize_ == 0)
 		return NULL;
649
 
650
651
652
+	if (cached_head_) {
+	  return cached_head_;	  
+	}
653
+
654
655
656
657
658
659
660
661
662
663
 	int l, i = lastbucket_;
 	int lastbucket_dec = (lastbucket_) ? lastbucket_ - 1 : nbuckets_ - 1;
 	double diff;
@@ -755,7 +804,7 @@
 	 */
 	lastbucket_ = l;
  	cal_clock_  = e->time_;
-	
+	cached_head_ = e;
 	return e;
664
665
 }
 
666
667
@@ -797,6 +846,8 @@
 		resize(nbuckets_ >> 1, cal_clock_);
668
 	}
669
 
670
671
672
+	cached_head_ = 0;
+
 	return e;
673
 }
674
 
675
676
677
@@ -926,6 +977,9 @@
 
 	--qsize_;
678
 
679
680
681
+	if ( e == cached_head_ )
+	  cached_head_ = 0;
+
682
 	return;
683
684
 }
 
685
@@ -956,11 +1010,23 @@
686
687
688
 	virtual void run();
 	double start() const { return start_; }
 	virtual void reset();
689
690
691
+#ifdef USEEVENTS
+	int command(int argc, const char*const* argv);
+#endif
692
693
 protected:
 	void sync() { clock_ = tod(); }
694
+	virtual void dispatch(Event*, double);	// exec event, set clock_
695
696
697
 	double tod();
 	double slop_;	// allowed drift between real-time and virt time
 	double start_;	// starting time
698
699
700
+#ifdef USEEVENTS
+        TbEventSink *evsink_;
+#endif
701
702
703
+#ifdef GETTIME_TSC
+        unsigned long long basetsc_ ;
+        double  oneontscfreq_;
704
+        double  tscfreq_;
705
706
707
708
+#endif
 };
 
 static class RealTimeSchedulerClass : public TclClass {
709
@@ -974,16 +1040,85 @@
710
711
712
 RealTimeScheduler::RealTimeScheduler() : start_(0.0)
 {
 	bind("maxslop_", &slop_);
713
714
715
+#ifdef USEEVENTS
+        evsink_ = 0 ;
+#endif
716
717
718
+#ifdef GETTIME_TSC
+        basetsc_ = 0 ;
+	oneontscfreq_ = 1.0 / (double)TSC_COUNT_PERSEC;
719
+	tscfreq_ = TSC_COUNT_PERSEC;
720
+#endif
721
722
+}
+
723
724
+#ifdef USEEVENTS
+  
725
+int RealTimeScheduler::command(int argc, const char*const* argv)
726
727
728
729
730
731
732
733
734
735
+{
+  Tcl& tcl = Tcl::instance();
+  if (instance_ == 0)
+    instance_ = this;
+  
+  
+  if( argc == 3 ) {
+    if(strcmp(argv[1], "tbevent-sink") == 0) {
+      evsink_ = (TbEventSink *)TclObject::lookup(argv[2]);
+      return(TCL_OK);
736
737
738
739
740
741
742
+    } else if (strcmp(argv[1], "cpuspeed") == 0) {
+      double ret;
+      if( (ret = atof(argv[2])) != 0 ) {
+	tscfreq_ = ret;
+	oneontscfreq_ = 1.0 / tscfreq_;
+      }
+      return(TCL_OK);
743
744
745
746
747
748
749
750
+    }
+  }
+
+  return(Scheduler::command(argc, argv));
+}  
+
+#endif
+
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
+/*
+ * dispatch a single simulator event by setting the system
+ * virtul clock to the event's timestamp and calling its handler.
+ * Note that the event may have side effects of placing other items
+ * in the scheduling queue
+ */
+
+void
+RealTimeScheduler::dispatch(Event* p, double t)
+{
+
+#ifdef SCHED_DEBUG
+	Tcl_HashEntry *he = Tcl_FindHashEntry(&newevents, (char *)((unsigned int)p->uid_));
+	if( he ) {
+	  Tcl_DeleteHashEntry(he);
+	} else {
+	  fprintf(stderr, "error. couldnt find event with uid = %d\n", (unsigned int)p->uid_);
+	}
+#endif
+	clock_ = t;
+	p->uid_ = -p->uid_;	// being dispatched
+	p->handler_->handle(p);	// dispatch
+#ifdef MEASURE_EVENT_RATE
+	event_dispatch_counter++;
+#endif
 }
 
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
 double
 RealTimeScheduler::tod()
 {
+#ifdef GETTIME_TSC
+                 
+        unsigned long long curtsc = read_tsc();
+        return (((double)(curtsc - basetsc_)) * oneontscfreq_);
+#else
 	timeval tv;
 	gettimeofday(&tv, 0);
 	double s = tv.tv_sec;
 	s += (1e-6 * tv.tv_usec);
 	return (s - start_);
+#endif
 }
 
 void
795
@@ -991,20 +1126,42 @@
796
797
798
799
800
801
802
803
804
805
806
 {
 	clock_ = SCHED_START;
 	start_ = tod();
+#ifdef GETTIME_TSC   
+        basetsc_ = read_tsc();
+#endif
 }
 
+#ifdef SCHED_DEBUG
+int done = 0;
+#endif
807
+
808
809
 void 
 RealTimeScheduler::run()
810
 { 
811
 	static const double RTSCHEDULER_MINWAIT = 1.0e-3; // don't wait for less
812
+	static const double delta = 1.0e-4; // should be smaller than above
813
 	const Event *p;
814
+	bool gethead = true;
815
816
817
818
819
820
821
+
+#ifdef USEEVENTS
+
+	if( evsink_ ) {
+	  evsink_->init();
+	  evsink_->subscribe();
+	}
822
+
823
+#endif
824
 
825
826
827
828
 	/*XXX*/
 	instance_ = this;
 
 	while (!halted_) {
829
+		if( gethead ) {
830
831
+		  p = head();
+		  gethead = false;
832
+		}
833
834
835
836
837
838
839
840
841
842
 		clock_ = tod();
-		p = head();
+
 		if (p && (clock_ - p->time_) > slop_) {
 			fprintf(stderr,
 				"RealTimeScheduler: warning: slop "
@@ -1014,12 +1171,31 @@
 		// handle "old events"
 		while (p && p->time_ <= clock_) {
 
843
+#ifdef DISPATCH_IN_RT
844
 			dispatch(deque(), clock_);
845
846
847
+#else
+			dispatch(deque(), p->time_);
+#endif
848
849
850
851
 			if (halted_)
 				return;
 			p = head();
 			clock_ = tod();
852
 		}
853
+
854
+#ifdef USEEVENTS
855
+		if( evsink_ && evsink_->poll() == 1 ) {
856
+		  gethead = true;
857
+		  continue;
858
859
+		}
+#endif
860
+
861
862
863
864
865
+#ifdef SCHED_DEBUG
+		if( clock_ >= 240.0 && done == 0 ) {
+		  fprintf( stderr, "After 60 secs. Hash Stats for newevents = %s\n",
+			   Tcl_HashStats(&newevents) );
+		  done = 1;
866
867
+		}
+#endif
868
869
870
871
872
873
874
875
 		
 		if (!p) {
 			// blocking wait for TCL events
@@ -1031,12 +1207,14 @@
 			if (diff > RTSCHEDULER_MINWAIT) {
 				Tcl_Time to;
 				to.sec = long(diff);
-				to.usec = long(1e6*(diff - to.sec));
876
+				to.usec = long(1e6*((diff - delta) - to.sec)); // wait for delta less
877
878
879
880
881
 				Tcl_WaitForEvent(&to);    // block
 				clock_ = tod();
 			}
 		}
-		Tcl_DoOneEvent(TCL_DONT_WAIT);
882
883
884
+		if( Tcl_DoOneEvent(TCL_DONT_WAIT) == 1 ) {
+		  gethead = true;
+		}
885
 	}
886
 	// we reach here only if halted
887
 }
888
889
--- dist-ns-allinone-2.26/ns-2.26/common/scheduler.h	Wed Feb 26 15:07:41 2003
+++ ns-allinone-2.26/ns-2.26/common/scheduler.h	Thu Jun  5 18:17:20 2003
890
@@ -98,7 +98,7 @@
891
892
893
894
895
896
897
898
 protected:
 	void dumpq();	// for debug: remove + print remaining events
 	void dispatch(Event*);	// execute an event
-	void dispatch(Event*, double);	// exec event, set clock_
+	virtual void dispatch(Event*, double);	// exec event, set clock_
 	Scheduler();
 	virtual ~Scheduler();
 	int command(int argc, const char*const* argv);
899
@@ -176,6 +176,7 @@
900
901
 private:
 	virtual void insert2(Event*);
902
 	double cal_clock_;  // same as clock in sims, may be different in RT-scheduling.
903
+	const Event *cached_head_;
904
905
906
 
 };
 
907
908
--- dist-ns-allinone-2.26/ns-2.26/common/tclAppInit.cc	Wed Feb 26 15:07:42 2003
+++ ns-allinone-2.26/ns-2.26/common/tclAppInit.cc	Thu Jun  5 18:18:08 2003
909
910
@@ -186,6 +186,7 @@
 	return TCL_OK;
911
912
 }
 
913
914
+#if 0
 #ifndef WIN32
915
 void
916
917
918
919
 abort()
@@ -200,6 +201,7 @@
 #endif /*abort*/
 	/*NOTREACHED*/
920
 }
921
922
+#endif
 #endif
923
924
 
 }
925
926
--- dist-ns-allinone-2.26/ns-2.26/common/timer-handler.cc	Wed Feb 26 15:07:42 2003
+++ ns-allinone-2.26/ns-2.26/common/timer-handler.cc	Thu Jun  5 18:21:36 2003
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
@@ -76,3 +76,40 @@
 	if (status_ == TIMER_HANDLING)
 		status_ = TIMER_IDLE;
 }
+
+#ifdef MEASURE_EVENT_RATE
+
+extern unsigned long long event_dispatch_counter;
+
+unsigned int idx;
+
+#define MAX_EVENT_ARR 70
+
+// circular buffer for the data
+extern unsigned int events_per_sec_arr[MAX_EVENT_ARR];
+
+
+void EventRateTimer::expire(Event *e) {
+
+  if ( idx % MAX_EVENT_ARR == MAX_EVENT_ARR-1 ) {
+
+    events_per_sec_arr[idx % MAX_EVENT_ARR] = event_dispatch_counter;
+    event_dispatch_counter = 0;
+    idx++;
+    
+    int i = 0 ;
+    for( ; i < MAX_EVENT_ARR-1 ; i++ ) {
+      fprintf(stderr, "%u, ", events_per_sec_arr[i] );
+    }
+    fprintf(stderr, "%u\n", events_per_sec_arr[MAX_EVENT_ARR-1] );    
+  } else {
+  
+    events_per_sec_arr[idx % MAX_EVENT_ARR] = event_dispatch_counter;
+    event_dispatch_counter = 0;
+    idx++;
+  }
+  resched(1.0);    
+    
+}
+
+#endif
968
969
--- dist-ns-allinone-2.26/ns-2.26/common/timer-handler.h	Wed Feb 26 15:07:42 2003
+++ ns-allinone-2.26/ns-2.26/common/timer-handler.h	Thu Jun  5 18:22:38 2003
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
@@ -88,4 +88,15 @@
 // mode:c++
 // End:
 
+#ifdef MEASURE_EVENT_RATE
+
+class EventRateTimer : public TimerHandler {
+
+public:
+  virtual void expire(Event *e) ;
+
+};
+
+#endif
+
 #endif /* timer_handler_h */
986
987
988
--- dist-ns-allinone-2.26/ns-2.26/emulate/iptap.cc	Wed Feb 26 15:08:40 2003
+++ ns-allinone-2.26/ns-2.26/emulate/iptap.cc	Fri Jun  6 19:08:41 2003
@@ -37,21 +37,82 @@
989
990
991
 #endif
 
 #include "iptap.h"
992
+#include <sys/time.h>
993
994
+#include <netinet/in.h>
+
995
996
997
998
999
1000
+#ifdef USEROUTES
+#include "tbnexthop.h"
+
+static IPTapAgent *iface_to_iptap[IFNAMSIZ+1];
+static Tcl_HashTable ip_to_iptap;
+
For faster browsing, not all history is shown. View entire blame