Results 1 to 1 of 1
Help me with my ns2 simulation!!!
--------------------------------------------------------------------------------
Hi All,
I tried to simulate the tcp protocol on Lan network, but the result of simulation puzzled me.
I run the code ...
- 01-19-2009 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 6
Help me with my ns2 simulation!!!
Help me with my ns2 simulation!!!
--------------------------------------------------------------------------------
Hi All,
I tried to simulate the tcp protocol on Lan network, but the result of simulation puzzled me.
I run the code below, in the code, I calculate the throughput of the tcp connection using
[expr [$tcp set ndatapack_]*8.0/1024/124]( which you can see more clearly in my code below),
here 8.0 represents one byte 8 bits, and 1024 is 1K, 124s is my simulation time,
But each time I run the simulation , I'll get the result 1.7632Mb/s,which is quite absurd,
could anyone point out the errors in my code,
or give me some useful suggestions or advices, thanks a lot.
the code below simulates a ftp application from node1(n1) to node2(n2)
Here is my code:
#================================================= =====
set ns [new Simulator]
proc finish {} {
exit 0
}
#define the nodes and the lan
set n1 [$ns node]
set n2 [$ns node]
set lan [$ns newLan "$n1 $n2" 100Mb 1ms LL Queue/DropTail MAC/Csma/Cd Channel]
#define the TCP connection
set tcp [new Agent/TCP/Newreno]
$ns attach-agent $n1 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n2 $sink
$ns connect $tcp $sink
$tcp set window_ 65536
$tcp set packetSize_ 1024
#Setup a FTP over the TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
#calculate the average throughtput (in Mb/s)
proc get_throughput { tcp } {
puts "[expr [$tcp set ndatapack_]*8.0/1024/124]Mb/s"
}
#begin to run
$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
#=================================================


Reply With Quote