0% found this document useful (0 votes)
29 views7 pages

Part A-Exp 4

The document discusses implementing an Ethernet LAN simulation using NS2/NS3 and obtaining congestion windows for different sources and destinations. It provides code to create nodes, connect them in a LAN, assign TCP and FTP agents, start and stop FTP transfers, and trace the congestion window sizes for different TCP flows.

Uploaded by

Balaji Koushik S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views7 pages

Part A-Exp 4

The document discusses implementing an Ethernet LAN simulation using NS2/NS3 and obtaining congestion windows for different sources and destinations. It provides code to create nodes, connect them in a LAN, assign TCP and FTP agents, start and stop FTP transfers, and trace the congestion window sizes for different TCP flows.

Uploaded by

Balaji Koushik S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

PART-A: Simulation experiments using NS2/ NS3/

OPNET/ NCTUNS/ NetSim/QualNet or any other


equivalent tool

4. Implement Ethernet LAN using n nodes and assign multiple traffic to


the nodes and obtain congestion window for different sources/
destinations.

set ns [new Simulator]

set tf [open p4.tr w]

$ns trace-all $tf

set nf [open p4.nam w]

$ns namtrace-all $nf

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]


$ns make-lan "$n0 $n1 $n2 $n3" 10Mb 10ms LL Queue/DropTail
Mac/802_3

set tcp0 [new Agent/TCP]

set ftp0 [new Application/FTP]

set sink0 [new Agent/TCPSink]

set tcp1 [new Agent/TCP]

set ftp1 [new Application/FTP]

set sink1 [new Agent/TCPSink]

$ns attach-agent $n0 $tcp0

$ftp0 attach-agent $tcp0

$ns attach-agent $n3 $sink0

$ns connect $tcp0 $sink0

$ns attach-agent $n2 $tcp1

$ftp1 attach-agent $tcp1


$ns attach-agent $n1 $sink1

$ns connect $tcp1 $sink1

set file0 [open file0.tr w]

$tcp0 attach $file0

$tcp0 trace cwnd_

$tcp0 set maxcwnd_ 10

set file1 [open file1.tr w]

$tcp1 attach $file1

$tcp1 trace cwnd_

$tcp1 set maxcwnd_ 5

$ns color 0 "red"

$ns color 1 "blue"


$tcp0 set class_ 0

$tcp1 set class_ 1

proc finish { } {

global nf tf ns

$ns flush-trace

exec nam p4.nam &

close $nf

close $tf

exit 0

$ns at 0.1 "$ftp0 start"

$ns at 1.5 "$ftp0 stop"

$ns at 2 "$ftp0 start"

$ns at 3 "$ftp0 stop"


$ns at 0.2 "$ftp1 start"

$ns at 2 "$ftp1 stop"

$ns at 2.5 "$ftp1 start"

$ns at 4 "$ftp1 stop"

$ns at 5.0 "finish"

$ns run

Output Commands: ns p4.tcl


Awk program
BEGIN{
}
{
if($6=="cwnd_")
printf("%f\t%f\t\n",$1,$7);
}
END{
}
Output commands:
awk –f p4.awk file0.tr > file0
awk –f p4.awk file1.tr > file1
xgraph -x “time” -y “convalue” file0 file1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy