[ns] Problem:First packet always get lost under TCP when error rate is bigger than 0.01

Tong Mao zealotmat at gmail.com
Fri Feb 27 03:24:35 PST 2009


Hello everyone,

I have a problem when simulate the ordinary FTP/TCP transmission in NS-2.28.
I add a link error model in the link. When I set the packet error reate
bigger than 0.01(for example 0.015). The first packet's t_seqno_ is 1, and
always get lost. The transmission recovered after 6 sec. Here is the trace
file:

0.05000  0  0  1  0  t_seqno_ 1
6.05000  0  0  1  0  t_seqno_ 0
6.05000  0  0  1  0  t_seqno_ 1
6.09032  0  0  1  0  t_seqno_ 2
6.09032  0  0  1  0  t_seqno_ 3
£®£®£® £®£®£®

Is it a bug or something else? Dose anyone can help me? Thank you very much.

I attach my OTcl script here, you can try by yourself.

set ns [new Simulator]

#Define different colors for data flows (for NAM)
$ns color 1 Blue

#Open the Trace files
set tracefile1 [open out.tr w]
set winfile [open WinFile w]
$ns trace-all $tracefile1

#Open the NAM trace file
set namfile [open out.nam w]
$ns namtrace-all $namfile


#Define a 'finish' procedure
proc finish {} {
     global ns tracefile1 namfile
     $ns flush-trace
     close $tracefile1
     close $namfile
     exec nam out.nam &
     exit 0
}

#Create two nodes
set n0 [$ns node]
set n1 [$ns node]

#Create links between the nodes
$ns duplex-link $n0 $n1 2Mb 20ms DropTail

set em [new ErrorModel]
$em set rate_ 0.02
$em unit pkt
$em ranvar [new RandomVariable/Uniform]
$em drop-target [new Agent/Null]
$ns link-lossmodel $em $n0 $n1


#Set Queue Size of link (n0-n1) to 20
#$ns queue-limit $n0 $n1 20

#Setup a TCP connection
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n1 $sink
$ns connect $tcp $sink
$tcp set fid_ 1

#Open the t_seqno_ trace file
$tcp trace t_seqno_
set trace_ch [open "trace.txt" w]
$tcp attach $trace_ch

#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp

$ns at 0.05 "$ftp start"
$ns at 63.5 "$ftp stop"

#Procedure for plotting window size. Gets as arguments the name
#of the tcp source node (called "tcpSource") and of output file.
proc plotWindow {tcpSource file} {
     global ns
     set time 0.1
     set now [$ns now]
     if { [$tcpSource set cwnd_]<[$tcpSource set window_]} {
            set cwnd [$tcpSource set cwnd_]
     } else {
            set cwnd [$tcpSource set window_]
     }
     puts $file "$now $cwnd"
     $ns at [expr $now+$time] "plotWindow $tcpSource $file"
}
$ns at 0.1 "plotWindow $tcp $winfile"

$ns at 64.0 "finish"
$ns run


Best Regards,
Tong Mao


More information about the Ns-users mailing list