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

Lab 1

Uploaded by

sarvesh.ds
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lab 1

Uploaded by

sarvesh.ds
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment No: 1 Date:

THREE NODE POINT TO POINT NETWORK

AIM: Implement Three nodes point – to – point network with duplex links between them for
different topologies. Set the queue size, vary the bandwidth, and find the number of packets
dropped for various iterations.

Program Objective:
Understand the Implementation of the Duplex link between the networks.

Theory:
1. Create a simulator object.
2. We open a file for writing that is going to be used for the trace data.
3. We now attach the agent to the nodes.
4. Now we attach the application to run on top of these nodes.
5. We now connect the agent and the application for its working.
6. Set the simulation time.
7. The next step is to add a 'finish' procedure that closes the trace file and starts nam.

set ns [new Simulator] # Letter S is capital


set nf [open lab1.nam w] # open a nam trace file in write mode
$ns namtrace-all $nf # nf nam filename
set tf [open lab1.tr w] # tf trace filename
$ns trace-all $tf
proc finish { } {
global ns nf tf
$ns flush-trace # clears trace file contents
close $nf
close $tf
exec nam lab1.nam &
exit 0
}
set n0 [$ns node] # creates 3 nodes
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 200Mb 10ms DropTail # establishing links
$ns duplex-link $n2 $n3 1Mb 1000ms DropTail
$ns queue-limit $n0 $n2 10
set udp0 [new Agent/UDP] # attaching transport layer protocols
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR] # attaching application layer protocols
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
set null0 [new Agent/Null] # creating sink(destination) node
$ns attach-agent $n3 $null0
$ns connect $udp0 $null0
$ns at 0.1 "$cbr0 start"
$ns at 1.0 "finish"
$ns run

AWK file:
(Open a new editor using “vi command” and write awk file and save with “.awk” extension)

BEGIN{ c=0;}
{
if($1= ="d")
{ c++;
printf("%s\t%s\n",$5,$11);
}
}
END{ printf("The number of packets dropped is %d\n",c); }

Steps for execution:


a. Open gedit and type program. Program name should have the extension”.tcl”
[root@localhost ~]# gedit lab1.tcl
b. Save the program and close the file.
c. open gedit editor and type awk program. Program name should have the
extension”.awk”
[root@localhost ~]# gedit lab1.awk
d. Save the program and close the file.
e. Run the simulation program
[root@localhost~]# ns lab1.tcl
f. Here ”ns” indicates network simulator. We get the topology shown in the snapshot.
g. Now press the play button in the simulation window and the simulation will begin.
h. After simulation is completed run awk file to see the output ,
[root@localhost~]# awk -f lab1.awk lab1.tr
i. To see the trace file contents open the file as ,
[root@localhost~] gedit lab1.tr

Trace file contains 12 columns:


Event type, Event time, From Node, To Node, Packet Type, Packet Size, Flags (indicated by
--------), Flow ID, Source address, Destination address, Sequence ID, Packet ID
Figure 1: Contents of Trace File

Figure 2:Topology

Figure 3:Output
Program Outcome:
Implement the Duplex link between the networks.

You might also like