[ns] the packet loss rate

zheng zhengkunming@hotmail.com
Sat Apr 6 06:50:02 2002


This is a multi-part message in MIME format.

------=_NextPart_000_001E_01C1DDC4.EEAE1880
Content-Type: text/plain;
	charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit

Hello! all:

I have a simple tcl script to set the packet loss rate, but the trace file
is same as the tcl script which don't set the packet loss rate. where have
wrong?
best regards
zheng

############################################################################
###################
pktloss.tcl:
############################################################################
####################
#Create a simulator object
set ns [new Simulator]

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

#Open the trace file
set tf[open out.tr w]
$ns trace-all $tf

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

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

#Creat link
$ns duplex-link $n0 $n1 128kb 10ms DropTail

$Set up TCP connection
set tcp [new Agent/TCP/Reno]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n1 $sink
$ns connect $tcp $sink

#Setup the packetsize
$tcp set packetSize_ 1048576

#Setup FTP
set ftp [new Application/FTP]
$ftp attach-agent $tcp

$ns at 0.1 "$ftp start"
$ns at 4.0  "finish"

#Packet loss
#Get a handle to the link n0---->n1
set link [$ns link $n0 $n1]

#Create a loss_module
set loss_module [new ErrorModel]
$loss_module set rate_ 0.01
$loss_module unit pkt

$link errormodule $loss_module

$ns run


------=_NextPart_000_001E_01C1DDC4.EEAE1880
Content-Type: text/html;
	charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-2022-jp">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>Hello! all:</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have a simple tcl script to&nbsp;set the packet loss rate, but =
the trace=20
file is same as the tcl script which don't set the packet loss rate. =
where have=20
&nbsp;wrong?</DIV>
<DIV>best regards</DIV>
<DIV>zheng</DIV>
<DIV>&nbsp;</DIV>
<DIV>####################################################################=
###########################</DIV>
<DIV>pktloss.tcl:</DIV>
<DIV>####################################################################=
############################</DIV>
<DIV>#Create a simulator object</DIV>
<DIV>set ns [new Simulator]</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Open the nam trace file</DIV>
<DIV>set nf [open out.nam w]</DIV>
<DIV>$ns namtrace-all $nf</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Open the trace file</DIV>
<DIV>set tf[open out.tr w]</DIV>
<DIV>$ns trace-all $tf</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Define a finish procedure</DIV>
<DIV>proc finish {} {</DIV>
<DIV>&nbsp;&nbsp;&nbsp; global ns nf tf</DIV>
<DIV>&nbsp;&nbsp;&nbsp; $ns flush-trace</DIV>
<DIV>&nbsp;&nbsp;&nbsp; close $nf</DIV>
<DIV>&nbsp;&nbsp;&nbsp; close $tf</DIV>
<DIV>&nbsp;&nbsp;&nbsp; exec nam out.nam &amp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; exit 0</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Create two nodes</DIV>
<DIV>set n0 [$ns node]</DIV>
<DIV>set n1 [$ns node]</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Creat link</DIV>
<DIV>$ns duplex-link $n0 $n1 128kb 10ms DropTail</DIV>
<DIV>&nbsp;</DIV>
<DIV>$Set up TCP connection</DIV>
<DIV>set tcp [new Agent/TCP/Reno]</DIV>
<DIV>$ns attach-agent $n0 $tcp</DIV>
<DIV>set sink [new Agent/TCPSink]</DIV>
<DIV>$ns attach-agent $n1 $sink</DIV>
<DIV>$ns connect $tcp $sink</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Setup the packetsize</DIV>
<DIV>$tcp set packetSize_ 1048576</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Setup FTP</DIV>
<DIV>set ftp [new Application/FTP]</DIV>
<DIV>$ftp attach-agent $tcp</DIV>
<DIV>&nbsp;</DIV>
<DIV>$ns at 0.1 "$ftp start"</DIV>
<DIV>$ns at 4.0&nbsp; "finish"</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Packet loss</DIV>
<DIV>#Get a handle to the link n0----&gt;n1</DIV>
<DIV>set link [$ns link $n0 $n1]</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Create a loss_module</DIV>
<DIV>set loss_module [new ErrorModel]</DIV>
<DIV>$loss_module set rate_ 0.01</DIV>
<DIV>$loss_module unit pkt</DIV>
<DIV>&nbsp;</DIV>
<DIV>$link errormodule $loss_module</DIV>
<DIV>&nbsp;</DIV>
<DIV>$ns run</DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_001E_01C1DDC4.EEAE1880--