this is bcoz of the the nam is reading the previous history of the file. so u must delete the out.tr and out.nam both before re-running the simulation.
pingpingping wrote: > > Hello, > recently I use the ns2 simulator to simulate local area network. I > write the tcl code following the manual downloaded from > http://www.isi.edu/nsnam/ns/, but I find that every time I run the > code below, the output is 1.7293548387096773Mb/s,but it shouldn't > be,because I have set the bw of the local area network as 1Mb,how can > it achieve 1.7Mb, I am quite puzzled with it > I don't kown whether there should be some more settings or some > other > > the code below just simulate a lan which transmits data from node n1 > to node n2,the bw between n1 and n2 is set as 1Mb > is there bugs in the code, please point them out and give me some advice, > thanks a lot! > ##########################################code######################## > set ns [new Simulator] > > #Define different colors for data flows (for NAM) > $ns color 1 Blue > $ns color 2 Red > > #Open the Trace files > set file1 [open out.tr w] > set winfile [open WinFile w] > $ns trace-all $file1 > #Define a 'finish' procedure > proc finish {} { > global ns file1 > $ns flush-trace > close $file1 > exec nam out.nam & > exit 0 > } > set n1 [$ns node] > set n2 [$ns node] > set lan [$ns newLan "$n1 $n2" 1Mb 40ms LL Queue/DropTail MAC/Csma/Cd > Channel] > set tcp [new Agent/TCP/Newreno] > $ns attach-agent $n1 $tcp > set sink [new Agent/TCPSink/DelAck] > $ns attach-agent $n2 $sink > $ns connect $tcp $sink > $tcp set fid_ 1 > $tcp set window_ 65536 > $tcp set packetSize_ 1024 > > #Setup a FTP over TCP connection > set ftp [new Application/FTP] > $ftp attach-agent $tcp > $ftp set type_ FTP > > proc get_throughput { tcp } { > #now calculate the average throughtput (in Mb/s) > puts "[expr [$tcp set ndatapack_]*8.0/1000/124]Mb/s" > } > $ns at 1.0 "$ftp start" > $ns at 124.0 "$ftp stop" > $ns at 124 "get_throughput $tcp" > $ns at 125.0 "finish" > $ns run > ######################################################## > -- View this message in context: http://www.nabble.com/ns2-problems-with-simulation-of-lan-tp21140877p21303699.html Sent from the ns-users mailing list archive at Nabble.com.
