0% found this document useful (0 votes)
2K views

Experiment No:1 Three Node Point To Point Network Aim: Simulate A Three Node Point To Point Network With Duplex Links Between Them. Set Queue Size and

The document describes experiments simulating different types of computer networks using the Network Simulator ns-3. Experiment 1 simulates a three node point-to-point network and measures packet drops as bandwidth is varied. Experiment 2 simulates ping transmissions over a six node network and measures packet drops. Experiment 3 simulates an Ethernet LAN with multiple traffic sources and plots congestion windows. Experiment 4 simulates a simple wireless extended service set and determines packet transmission performance. Experiments 5 and 6 implement and study the performance of GSM and CDMA mobile networks using ns-3.

Uploaded by

gopinath R
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)
2K views

Experiment No:1 Three Node Point To Point Network Aim: Simulate A Three Node Point To Point Network With Duplex Links Between Them. Set Queue Size and

The document describes experiments simulating different types of computer networks using the Network Simulator ns-3. Experiment 1 simulates a three node point-to-point network and measures packet drops as bandwidth is varied. Experiment 2 simulates ping transmissions over a six node network and measures packet drops. Experiment 3 simulates an Ethernet LAN with multiple traffic sources and plots congestion windows. Experiment 4 simulates a simple wireless extended service set and determines packet transmission performance. Experiments 5 and 6 implement and study the performance of GSM and CDMA mobile networks using ns-3.

Uploaded by

gopinath R
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/ 19

PART A

Experiment No:1 THREE NODE POINT TO POINT NETWORK

Aim: Simulate a three node point to point network with duplex links between them. Set queue size and
vary the bandwidth and find number of packets droppe.

Program:

set ns [new Simulator]

set f [open lab1.tr w]

set nf [open lab1.nam w]

$ns trace-all $f

$ns namtrace-all $nf

proc finish {} {

global f nf ns

$ns flush-trace

close $f

close $nf

exec nam lab1.nam &

exit 0

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

$n0 label "TCP Source"

$n1 label "UDP Source"


$n2 label "Sink"

$ns color 1 red

$ns color 2 yellow

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

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

$ns queue-limit $n1 $n2 10

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

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

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 attach-agent $udp0

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.005

set null0 [new Agent/Null]

$ns attach-agent $n2 $null0

$ns connect $udp0 $null0

set tcp0 [new Agent/TCP]

$ns attach-agent $n0 $tcp0

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0


set sink [new Agent/TCPSink]

$ns attach-agent $n2 $sink

$ftp0 set maxPkts_ 1000

$ns connect $tcp0 $sink

$udp0 set class_ 1

$tcp0 set class_ 2

$ns at 0.1 "$cbr0 start"

$ns at 1.0 "$ftp0 start"

$ns at 4.0 "$ftp0 stop"

$ns at 4.5 "$cbr0 stop"

$ns at 5.0 "finish"

$ns run

OUTPUT
Experiment No: 2 TRANSMISSION OF PING MESSAGE

Aim:Simulate the transmission of ping messages over a network topology consisting of 6 nodes and find
the number of packets dropped due to congestion.

Program:

set ns [new Simulator]

set f [open lab2.tr w]

set nf [open lab2.nam w]

$ns trace-all $f

$ns namtrace-all $nf

proc finish {} {

global ns f nf

$ns flush-trace

close $f

close $nf

exec nam lab2.nam &

exit 0

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

set n5 [$ns node]

$n0 label "ping0"

$n1 label "ping1"


$n2 label "R1"

$n3 label "R2"

$n4 label "ping4"

$n5 label "ping5"

$ns color 1 red

$ns color 2 blue

$ns color 3 green

$ns color 4 orange

$ns duplex-link $n0 $n2 1Mb 10ms DropTail

$ns duplex-link $n1 $n2 1Mb 10ms DropTail

$ns duplex-link $n2 $n3 0.5Mb 30ms DropTail

$ns duplex-link $n3 $n4 1Mb 10ms DropTail

$ns duplex-link $n3 $n5 1Mb 10ms DropTail

set ping0 [new Agent/Ping]

$ns attach-agent $n0 $ping0

set ping1 [new Agent/Ping]

$ns attach-agent $n1 $ping1

set ping4 [new Agent/Ping]

$ns attach-agent $n4 $ping4

set ping5 [new Agent/Ping]

$ns attach-agent $n5 $ping5

$ns connect $ping0 $ping4

$ns connect $ping1 $ping5


proc sendPingPacket {} {

global ns ping0 ping1 ping4 ping5

set intervalTime 0.001

set now [$ns now]

$ns at [expr $now + $intervalTime] "$ping0 send"

$ns at [expr $now + $intervalTime] "$ping1 send"

$ns at [expr $now + $intervalTime] "$ping4 send"

$ns at [expr $now + $intervalTime] "$ping5 send"

$ns at [expr $now + $intervalTime] "sendPingPacket"

Agent/Ping instproc recv {from rtt} {

global seq

$self instvar node_

puts "The node [$node_ id] received an ACK from the node $from

with RTT $rtt ms"

$ping0 set class_ 1

$ping1 set class_ 2

$ping4 set class_ 4

$ping5 set class_ 5

$ns at 0.01 "sendPingPacket"

$ns at 10.0 "finish"

$ns run
OUTPUT

Experiment No:3 Ethernet lan using n-nodes with multiple traffic

Aim: Simulate an Ethernet LAN using „n‟ nodes and set multiple traffic nodes and plot congestion
window for different source / destination.

Program:

set ns [new Simulator]

set f [open lab3.tr w]

set nf [open lab3.nam w]


$ns trace-all $f

$ns namtrace-all $nf

proc finish {} {

global ns f nf outFile1 outFile2

$ns flush-trace

close $f

close $nf

exec nam lab3.nam &

exec xgraph Congestion1.xg -geometry 400x400 &

exec xgraph Congestion2.xg -geometry 400x400 &

exit 0

$ns color 1 red

$ns color 2 green

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

set n5 [$ns node]

set n6 [$ns node]

set n7 [$ns node]

$n0 label "TCP FTP Source"

$n3 label "Sink Destination"

$n5 label "TCP Telnet Source"


$n7 label "Sink Destination"

$ns make-lan "$n0 $n1 $n2 $n3 $n4 $n5 $n6 $n7" 10Mb 30ms LL

Queue/DropTail Mac/802_3

set tcp1 [new Agent/TCP]

$ns attach-agent $n0 $tcp1

set ftp1 [new Application/FTP]

$ftp1 attach-agent $tcp1

set sink1 [new Agent/TCPSink]

$ns attach-agent $n3 $sink1

$ns connect $tcp1 $sink1

$tcp1 set class_ 1

set tcp2 [new Agent/TCP]

$ns attach-agent $n5 $tcp2

set telnet1 [new Application/FTP]

$telnet1 attach-agent $tcp2

set sink2 [new Agent/TCPSink]

$ns attach-agent $n7 $sink2

$ns connect $tcp2 $sink2

$telnet1 set type_ $sink2

$tcp2 set class_ 2

set outFile1 [open Congestion1.xg w]

set outFile2 [open Congestion2.xg w]


puts $outFile1 "TitleText: Congestion Window Plot for TCP1"

puts $outFile1 "XUnitText: SimulationTime(Secs)"

puts $outFile1 "YUnitText: CongestionWindowSize"

puts $outFile2 "TitleText: Congestion Window Plot for TCP2"

puts $outFile2 "XUnitText: SimulationTime(Secs)"

puts $outFile2 "YUnitText: CongestionWindowSize"

proc findWindowSize {tcpSource outFile} {

global ns

set now [$ns now]

set cWindSize [$tcpSource set cwnd_]

puts $outFile "$now $cWindSize"

$ns at [expr $now + 0.1] "findWindowSize $tcpSource $outFile"

$ns at 0.0 "findWindowSize $tcp1 $outFile1"

$ns at 0.1 "findWindowSize $tcp2 $outFile2"

$ns at 0.3 "$ftp1 start"

$ns at 0.5 "$telnet1 start"

$ns at 50.0 "$ftp1 stop"

$ns at 50.0 "$telnet1 stop"

$ns at 50.0 "finish"

$ns run
OUTPUT

Experiment No: 4 SIMPLE ESS WITH WIRELESS LAN

Aim:Simulate simple ESS and with transmitting nodes in wireless LAN by simulation and determine the
performance with respect to transmission of packets.

Program:

# Simulator Instance Creation

set ns [new Simulator]

#Fixing the co-ordinate of simutaion area

set val(x) 500

set val(y) 500


# Define options

set val(chan) Channel/WirelessChannel ;# channel type

set val(prop) Propagation/TwoRayGround ;# radio-propagation model

set val(netif) Phy/WirelessPhy ;# network interface type

set val(mac) Mac/802_11 ;# MAC type

set val(ifq) Queue/DropTail/PriQueue ;# interface queue type

set val(ll) LL ;# link layer type

set val(ant) Antenna/OmniAntenna ;# antenna model

set val(ifqlen) 50 ;# max packet in ifq

set val(nn) 2 ;# number of mobilenodes

set val(rp) AODV ;# routing protocol

set val(x) 500 ;# X dimension of topography

set val(y) 400 ;# Y dimension of topography

set val(stop) 10.0 ;# time of simulation end

# set up topography object

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

#Nam File Creation nam – network animator

set namfile [open sample1.nam w]

#Tracing all the events and cofiguration

$ns namtrace-all-wireless $namfile $val(x) $val(y)


#Trace File creation

set tracefile [open sample1.tr w]

#Tracing all the events and cofiguration

$ns trace-all $tracefile

# general operational descriptor- storing the hop details in the network

create-god $val(nn)

# configure the nodes

$ns node-config -adhocRouting $val(rp) \

-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 OFF \

-movementTrace ON
# Node Creation

set node1 [$ns node]

# Initial color of the node

$node1 color black

#Location fixing for a single node

$node1 set X_ 200

$node1 set Y_ 100

$node1 set Z_ 0

set node2 [$ns node]

$node2 color black

$node2 set X_ 200

$node2 set Y_ 300

$node2 set Z_ 0

# Label and coloring

$ns at 0.1 "$node1 color blue"

$ns at 0.1 "$node1 label Node1"

$ns at 0.1 "$node2 label Node2"

#Size of the node

$ns initial_node_pos $node1 30

$ns initial_node_pos $node2 30

# ending nam and the simulation

$ns at $val(stop) "$ns nam-end-wireless $val(stop)"


$ns at $val(stop) "stop"

#Stopping the scheduler

$ns at 10.01 "puts \"end simulation\" ; $ns halt"

#$ns at 10.01 "$ns halt"

proc stop {} {

global namfile tracefile ns

$ns flush-trace

close $namfile

close $tracefile

#executing nam file

exec nam sample1.nam &

#Starting scheduler

$ns run
OUTPUT

Experiment 5 & 6:

Implement and study the performance of GSM & CDMA on NS3 (Using MAC
layer) or equivalent Environment

Program

# General Parameters
set opt(ecn) 0 ;
set opt(window) 30 ;
# Topology
set opt(type) gsm ; #type of link:
# AQM parameters
set opt(minth) 5 ;
set opt(maxth) 10 ;
set opt(adaptive) 1 ; # 1 for Adaptive RED, 0 for plain RED
#default downlink bandwidth in bps
set bwDL(gsm) 9600
#default uplink bandwidth in bps
set bwUL(gsm) 9600
#default downlink propagation delay in seconds
set propDL(gsm) .500
#default uplink propagation delay in seconds
set propUL(gsm) .500
#default buffer size in packets
set buf(gsm) 10

set ns [new Simulator]


set tf [open out.tr w]
set nf [open out1.nam w]
$ns trace-all $tf
$ns namtrace-all $nf
set nodes(s) [$ns node]
set nodes(bs1) [$ns node]
set nodes(ms) [$ns node]
set nodes(bs2) [$ns node]
set nodes(d) [$ns node]
proc cell_topo {} {
global ns nodes

$ns duplex-link $nodes(s) $nodes(bs1) 3Mbps 10ms DropTail


$ns duplex-link $nodes(bs1) $nodes(ms) 1Mbps 1ms RED
$ns duplex-link $nodes(ms) $nodes(bs2) 1Mbps 1ms RED
$ns duplex-link $nodes(bs2) $nodes(d) 3Mbps 50ms DropTail puts "Cell Topology"

proc set_link_params {t} {


global ns nodes bwUL bwDL propUL propDL buf
$ns bandwidth $nodes(bs1) $nodes(ms) $bwDL($t) simplex
$ns bandwidth $nodes(ms) $nodes(bs1) $bwUL($t) simplex
$ns bandwidth $nodes(bs2) $nodes(ms) $bwDL($t) simplex
$ns bandwidth $nodes(ms) $nodes(bs2) $bwUL($t) simplex
$ns delay $nodes(bs1) $nodes(ms) $propDL($t) simplex
$ns delay $nodes(ms) $nodes(bs1) $propDL($t) simplex
$ns delay $nodes(bs2) $nodes(ms) $propDL($t) simplex
$ns delay $nodes(ms) $nodes(bs2) $propDL($t) simplex
$ns queue-limit $nodes(bs1) $nodes(ms) $buf($t)
$ns queue-limit $nodes(ms) $nodes(bs1) $buf($t)
$ns queue-limit $nodes(bs2) $nodes(ms) $buf($t)
$ns queue-limit $nodes(ms) $nodes(bs2) $buf($t)
}
# RED and TCP parameters
Queue/RED set summarystats_ true
Queue/DropTail set summarystats_ true
Queue/RED set adaptive_ $opt(adaptive)
Queue/RED set q_weight_ 0.0
Queue/RED set thresh_ $opt(minth)
Queue/RED set maxthresh_ $opt(maxth)
Queue/DropTail set shrink_drops_ true
Agent/TCP set ecn_ $opt(ecn)
Agent/TCP set window_ $opt(window)
DelayLink set avoidReordering_ true
#Create topology
switch $opt(type) {
gsm - gprs - umts {cell_topo}
}
set_link_params $opt(type)
$ns insert-delayer $nodes(ms) $nodes(bs1) [new Delayer]
$ns insert-delayer $nodes(bs1) $nodes(ms) [new Delayer]
$ns insert-delayer $nodes(ms) $nodes(bs2) [new Delayer]
$ns insert-delayer $nodes(bs2) $nodes(ms) [new Delayer]

# Set up forward TCP connection


set tcp1 [$ns create-connection TCP/Sack1 $nodes(s) TCPSink/Sack1 $nodes(d) 0]
set ftp1 [[set tcp1] attach-app FTP]
$ns at 0.5 "$ftp1 start"
proc stop {} {
global nodes ns opt nf tf
$ns flush-trace
close $nf
close $tf
exec nam out1.nam &
exit 0
}
$ns at 100 "stop"
$ns run

BEGIN {
PacketRcvd=0;
Throughput=0.0;
}
{
if(($1=="r") && ($5=="tcp") && ($10=4.0))
{
PacketRcvd++;
}
}
END {
Throughput=((PacketRcvd*1000*8)/(95.0*1000000));
printf("packet received:%f\n", PacketRcvd);
printf( "the throughput is:%f\n",Throughput);
}

OUTPUT

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