0% found this document useful (0 votes)
9 views

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 views

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

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