Procedure To Set Up Wired Network in Network Simulator-2
Procedure To Set Up Wired Network in Network Simulator-2
Procedure To Set Up Wired Network in Network Simulator-2
Aim: T o understand and design the point-to-point network structure. Also here we
understand the working of TCP and UDP transport protocol.
Theory:
n We open a file for writing that is going to be used for the “nam” trace data
n We now connect the agent and the application for its working
n The next step is to add a 'finish' procedure that closes the trace file and starts
nam.
Save the following program as ex1.tcl
proc finish {} {
global ns tf nf
$ns flush-trace
close $tf
close $nf
exit 0
}
$ns run
Expected output: Animated 4 node structure is displayed. We need to see the trace file
to understand what has happened to the data flow.
Grep
BEGIN {
tcp_count=0;
udp_count=0;
tcp_count ++;
udp_count ++;
END {
To run the awk script you need to execute the command shown bellow on the terminal.
Aim: To understand and design TCP Applications like FTP and Telnet. Here we see that
the throughput of both the application vary depending on the data size
Theory:
n We open a file for writing that is going to be used for the “nam” trace data.
n We now connect the agent and the application for its working
n The next step is to add a 'finish' procedure that closes the trace file and starts
nam.
Save the following program as ex2.tcl
global ns
proc finish {} {
global ns tf nf cwind
$ns flush-trace
close $tf
close $nf
exit 0
$ns run
Expected output: Animated 4 node structure is displayed. We need to see the trace file
to understand what has happened to the data flow depending on the application used.
Awk script to calculate throughput
BEGIN {
last = 0
tcp_sz = 0
cbr_sz = 0
total_sz = 0
action = $1;
time = $2;
from = $3;
to = $4;
type = $5;
pktsize = $6;
flow_id = $8;
src = $9;
dst = $10;
seq_no = $11;
packet_id = $12;
tcp_sz += pktsize
cbr_sz += pktsize
total_sz += pktsize
END {
}
3. Set up the topology with 6 nodes, and demonstrate the working of
Distance vector routing protocol. The link between 1 and 4 breaks at
1.0ms and comes up at 3.0ms. Assume that the source node 0
transmits packets to node 4. Plot the congestion window when TCP
sends packets via other nodes. Assume your own parameters for
bandwidth and delay.
Aim: To understand the working o distance vector routing.
Theory:
n We open a file for writing that is going to be used for the “nam” trace data.
n Create nodes and establish links between them and orient accordingly
n We now connect the agent and the application for its working
n The next step is to add a 'finish' procedure that closes the trace file and starts
nam.
Save the following program as ex4.tcl
$ns rtproto DV
global ns
proc finish {} {
global ns tf nf cwind
$ns flush-trace
close $tf
close $nf
exit 0
$ns run
Expected output: Animated 6 node structure is displayed. We need to see the nam file
as well as the trace file to understand what has happened to the data flow.
4. Consider a client and a server. The server is running a FTP
application over TCP. The client sends a request to download a file of
size 10 MB from the server. Write a TCL script to simulate this
scenario. Let node n0 be the server and node n1 be the client. TCP
packet size is 1500 Bytes.
Aim: T o understand the working of a client and a server, when transmitting 10MB file
from server to the client.
Theory:
n We open a file for writing that is going to be used for the “nam” trace data.
n We now connect the agent and the application for its working
n The next step is to add a 'finish' procedure that closes the trace file and starts
nam.
Save the following program as ex6.tcl
#Create a ns simulator
#Create 2 nodes
$s label "Server"
$c label "Client"
proc finish { } {
close $tracefile
close $namfile
$ns run
Expected output: Animated 2 node structure is displayed with the node labeled as
client and server. We need to make use of the awk script to calculate the time required
to transfer the 10 MB file from the server to client and duration for converting
downloaded file into MB.
Save the following awk script as ex5transfer.awk
# AWK script to calulate the time required to transfer the 10 MB file from the server to
client
BEGIN {
count=0;
time=0;
total_bytes_sent =0;
total_bytes_received=0;
total_bytes_received += $6;
total_bytes_sent += $6;
END {
system("clear");
BEGIN {
count=0;
time=0;
count += $6;
time=$2;
printf("\n%f\t%f",time,(count)/1000000);
END {
}
5. Demonstrate the working of a multicast routing protocol. Plot the
congestion window for the source node and write your observation
on protocol performance. Assume your own parameters for
bandwidth and delay.
Aim: To understand the working of multicast routing protocol and observe the protocol
performance by plotting congestion window.
Theory:
n We open a file for writing that is going to be used for the “nam” trace data.
n We now connect the agent and the application for its working
#$ns multicast
#Turn on Tracing
# Create nodes
# Create links
set mproto DM
# Create receiver
# Schedule events
global ns tf fd
$ns flush-trace
close $tf
close $fd
exit 0
# For nam
# Group 0 source
# Group 1 source
$ns run
Expected output: Animated node structure is displayed with single sender multicasting
data to specific receiver group.
PROCEDURE TO SET UP WIRELESS NETWORK IN NETWORK SIMULATOR-2
Aim: T o understand and design the two nodes wireless network. Also here we
understand the working of DSDV routing protocol and analyze its performance.
Theory:
Theory:
n Define the options for the wireless network. (Choose routing protocol as DSDV,
No. of nodes 2)
set val(ll) LL
set val(ifqlen) 50
set val(nn) 2
create-god $val(nn)
#Node Configuration
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
#Creating Nodes
$node_($i) random-motion 0
#Topology Design
#Generating Traffic
#Simulation Termination
$ns_ run
Theory:
n Define node movement i.e n0 and n2 moves towards each other and after
some time move away from each other.
set val(ll) LL
set val(ifqlen) 50
set val(nn) 3
create-god $val(nn)
#Node Configuration
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
#Creating Nodes
$node_($i) random-motion 0
#Topology Design
#Generating Traffic
#Simulation Termination
$ns_ run
Theory:
Theory:
Desktop>ns-2.35>ns-2.35all_in_one>indeputils>lib>cmu-scen-gen>cbrgen.tcl
Desktop>ns-2.35>ns-2.35all_in_one>indeputils>lib>cmu-scen-gen>setdest>setde
st.h
nodes: 6, pause: 2.00, max speed: 40.00, max x: 200.00, max y: 300.00
Save the following program as 003.tcl
set val(ll) LL
set val(ifqlen) 50
set val(nn) 25
#Node Configuration
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
#Creating Nodes
$node_($i) random-motion 0
}
#puts "Loading scenario file..."
#source $val(sc)
source $val(cp)
#Simulation Termination
$ns_ run
Expected Output: Setup of wireless network and Performance analysis of static and
mobile nodes.
9. Write a TCL script to simulate the following scenario. Consider six
nodes, (as shown in the figure below) moving within a flat topology of
700m x 700m. The initial positions of nodes are: n0(150, 300), n1(300,
500), n2(500, 500), n3 (300, 100), n4(500, 100) and n5(650, 300)
respectively. A TCP connection is initiated between n0 (source) and
n5 (destination) through n3 and n4 i.e., the route is 0-3-4-5. At time t =
3 seconds, the FTP application runs over it. After time t = 4 seconds,
n3(300,100) moves towards n1(300, 500) with a speed of 5.0m/sec and
after some time the path breaks. The data is then transmitted with a
new path via n1 and n2 i.e., the new route is 0-1-2-5. The simulation
lasts for 60 secs. In the above said case both the routes have equal
cost. Use DSR as the routing protocol and the IEEE 802.11 MAC
protocol.
o simulate wireless network with six nodes. Here we implement the working of
Aim: T
DSR routing protocol, IEEE 802.11 and analyze performance when a specific path
breaks.
Theory:
set val(ll) LL
set val(ifqlen) 50
set val(nn) 6
#Node Configuration
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
#Creating Nodes
$node_($i) random-motion 0
#Topology Design
#Generating Traffic
#Simulation Termination
$ns_ run
Aim: T o simulate wireless network with mobile nodes and induce error to analyze
performance..
Theory:
n Create uniform error procedure and induce the interval at which the error is to
be generated.
set val(ll) LL
set val(ifqlen) 50
set val(nn) 5
create-god $val(nn)
#Node Configuration
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-IncomingErrProc "uniformErr" \
-OutgoingErrProc "uniformErr"
proc uniformErr {} {
return $err
#Creating Nodes
$node_($i) random-motion 0
#Topology Design
#Generating Traffic
$ns_ run