0% found this document useful (0 votes)
9 views3 pages

Practical (Smulation)

The document outlines the creation of a network simulator using a scripting language, defining nodes, duplex links, and TCP connections. It includes procedures for starting and stopping a file transfer application (FTP) and managing trace files for simulation output. The simulation runs with specific parameters for packet size and queue limits, ultimately executing a finish procedure to clean up resources.

Uploaded by

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

Practical (Smulation)

The document outlines the creation of a network simulator using a scripting language, defining nodes, duplex links, and TCP connections. It includes procedures for starting and stopping a file transfer application (FTP) and managing trace files for simulation output. The simulation runs with specific parameters for packet size and queue limits, ultimately executing a finish procedure to clean up resources.

Uploaded by

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

# Create a simulator object

set ns [new Simulator]


$ns color 1 Blue

set namfile[open out.nam w]


$ns namtrace-all $namfile

#Define a 'finish' procedure


proc finish {} {
global ns namfile
$ns flush-trace
close $namfile
exec nam out.nam &
exit 0
}

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]

$ns duplex-link $n0 $n1 2Mb 20ms DropTail


$ns duplex-link $n1 $n2 2Mb 20ms DropTail

$ns queue-limit $n1 $n2 20

$ns duplex-link-op $n0 $n1 orient right


$ns duplex-link-op $n1 $n2 orient right-down

#Setup a TCP connection


set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp

set sink [new Agent/TCPSink]


$ns attach-agent $n2 $sink
$ns connect $tcp $sink
$tcp set fid_ 1
$tcp set packetSize_ 552

set ftp [new Application/FTP]


$ftp attach-agent $tcp

$ns at 0.1 "$ftp start"


$ns at 4.5 "$ftp stop"
$ns at 5.0 "finish"
$ns run
# Create a simulator object
set ns [new Simulator]
$ns color 1 Blue

# Open tracefile
set tracefile [open out.tr w]
$ns trace-all $tracefile

set namfile[open out.nam w]


$ns namtrace-all $namfile

#Define a 'finish' procedure


proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}

set n0[$ns node]


set n1[$ns node]
set n2[$ns node]

$ns duplex-link $n0 $n1 2Mb 20ms DropTail


$ns duplex-link $n1 $n2 2Mb 20ms DropTail

$ns duplex-link-op $n0 $n1 orient right


$ns duplex-link-op $n1 $n2 orient right-down

$ns queue-limit $n1 $n2 20

#Setup a TCP connection


set tcp[new Agent/TCP]
$ns attach-agent $n0 $tcp

set sink[new Agent/TCPSink]


$ns attach-agent $n2 $sink
$ns connect $tcp $sink
$tcp set fid_ 1
$tcp set packetSize_ 552

set ftp[new Application/FTP]


$ftp attach-agent $tcp

$ns at 0.1 "$ftp start"


$ns at 4.5 "$ftp stop"
$ns at 5.0 "finish"
$ns run

You might also like