Hello, All,

 

I want to introduce error in LAN, tried like in following code but its
giving error.

 

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/CdChannel]

 

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

 

set LossyLink [$ns link $n1 $n2]

insert_error $LossyLink

 

 

proc get_throughput { tcp } {

#now calculate the average throughtput (in Mb/s)

       puts "[expr [$tcp set ndatapack_]*8.0/1000/2]Mb/s"

}

# Creating Error Module

proc insert_error {LossyLink} {

 

set loss_module [new ErrorModel]

$loss_module unit pkt

$loss_module set rate_ 0.1

$loss_module ranvar [new RandomVariable/Uniform]

$loss_module drop-target [new Agent/Null]

#$ns link-lossmodel $loss_module $n1 $n2

$LossyLink errormodule $loss_module

 

}

 

$ns at 0 "$ftp start"

$ns at 2.0 "$ftp stop"

$ns at 2.0 "get_throughput $tcp"

$ns at 2.0 "finish"

$ns run

 

Please suggest a simple method by which I can introduce error in LAN.

 

Thanks in advance.

 

Regards,

Anup

Reply via email to