Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

EXPERIMENT NO:11

Name Tarun Shetty

Class BE EXTC B

Batch B2

Roll No. 54
EXPERIMENT NO 11

AIM:To plot the graph of Delay, Throughput, PDR, Energy of mac layer protocol
802.11 and 802.15.4.

Theory:
IEEE 802.11 is part of the IEEE 802 set of local area network (LAN) technical standards, and
specifies the set of medium access control (MAC) and physical layer (PHY) protocols for
implementing wireless local area network (WLAN) computer communication. The standard
and amendments provide the basis for wireless network products using the Wi-Fi brand and
are the world's most widely used wireless computer networking standards. IEEE 802.11 is used
in most home and office networks to allow laptops, printers, smartphones, and other devices to
communicate with each other and access the Internet without connecting wires. The standards
are created and maintained by the Institute of Electrical and Electronics Engineers (IEEE)
LAN/MAN Standards Committee (IEEE 802). The base version of the standard was released
in 1997, and has had subsequent amendments. While each amendment is officially revoked
when it is incorporated in the latest version of the standard, the corporate world tends to market
to the revisions because they concisely denote capabilities of their products. As a result, in the
marketplace, each revision tends to become its own standard. IEEE 802.11 uses various
frequencies including, but not limited to, 2.4 GHz, 5 GHz, 6 GHz, and 60 GHz frequency
bands. Although IEEE 802.11 specifications list channels that might be used, the radio
frequency spectrum availability allowed varies significantly by regulatory domain. The
protocols are typically used in conjunction with IEEE 802.2, and are designed to interwork
seamlessly with Ethernet, and are very often used to carry Internet Protocol traffic.
IEEE 802.15.4 is a technical standard which defines the operation of low-rate wireless
personal area networks (LR-WPANs). It specifies the physical layer and media access
control for LR-WPANs, and is maintained by the IEEE 802.15 working group, which defined
the standard in 2003. It is the basis for the Zigbee,
MiWi, 6LoWPAN, Thread and SNAP specifications, each of which further extends the
standard by developing the upper layers which are not defined in IEEE 802.15.4. In
particular, 6LoWPAN defines a binding for the IPv6 version of the Internet Protocol (IP) over
WPANs, and is itself used by upper layers like Thread.
This standard defines an Upper Layer Interface (ULI) sublayer in Layer 2 (L2), between Layer
3 (L3) and the IEEE 802.15.4 Media Access Control (MAC) sublayer. The ULI provides data
and management service access points (SAPs) for interface to the IEEE 802.15.4 MAC. The
ULI adapts L3 protocols and provides operational configuration including network and radio
regulation requirements of the IEEE 802.15.4 MAC. Further more, the ULI integrates optional
upper Layer 2 functionalities focused on interfacing to the IEEE 802.15.4 MAC such as Key
Management Protocols (KMPs), L2 routing (L2R) protocols, L2 fragmentation, and Internet
Engineering Task Force (IETF) IPv6 over the TimeSlotted Channel Hopping (TSCH) mode of
IEEE Std 802.15.4 (6TiSCH) Operation Protocol (6TOP). Finally, the ULI provides protocol
differentiation, using mechanisms such as EtherType Protocol Differentiation (EPD) to support
multiple, diverse higher layer protocols, and header compression.
PROGRAM:
1. 802.11/mac
#===================================
# Simulation parameters setup
#===================================
set val(chan) Channel/WirelessChannel ;# channel type 2
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) 5 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 500 ;# Y dimension of topography
set val(stop) 10.0; #/30.0/100.0/200.0/500.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open wireless10.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open wireless10.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)

set chan [new $val(chan)];#Create wireless channel

#===================================
# Mobile node parameter setup
#===================================

# $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) \
# -channel $chan \
# -topoInstance $topo \
# -agentTrace ON \
# -routerTrace ON \
# -macTrace ON \
# -movementTrace ON

$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) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF

#===================================
# Nodes Definition
#===================================
#Create 5 nodes
set n0 [$ns node]
$n0 set X_ 105
$n0 set Y_ 80
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 209
$n1 set Y_ 202
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 369
$n2 set Y_ 221
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 312
$n3 set Y_ 126
$n3 set Z_ 0.0
$ns initial_node_pos $n3 20
set n4 [$ns node]
$n4 set X_ 315
$n4 set Y_ 19
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20

#===================================
# Generate movement
#===================================
$ns at 1 " $n0 setdest 70 50 50 "
$ns at 2 " $n1 setdest 150 150 50 "
$ns at 3 " $n2 setdest 300 200 50 "
$ns at 4 " $n3 setdest 300 120 50 "
$ns at 5 " $n4 setdest 300 50 50 "
#===================================
# Agents Definition
#===================================
#Setup a TCP connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $sink1
$ns connect $tcp0 $sink1
$tcp0 set packetSize_ 1500
#Setup a UDP connection
set udp3 [new Agent/UDP]
$ns attach-agent $n1 $udp3
set null4 [new Agent/Null]
$ns attach-agent $n3 $null4
$ns connect $udp3 $null4
$udp3 set packetSize_ 1500
#===================================
# Applications Definition
#===================================
#Setup a FTP Application over TCP connection
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 1.0 "$ftp0 start"
$ns at 10.0 "$ftp0 stop"
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp3
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns at 1.0 "$cbr1 start"
$ns at 10.0 "$cbr1 stop"
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefilenamfile
$ns flush-trace
close $tracefile
close $namfile
exec nam wireless10.nam &
exit 0
}
for {set i 0} {$i< $val(nn) } { incri } {
$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
2. 802.15.4/ZigBee
#===================================
# Simulation parameters setup
#===================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy/802_15_4 ;# network interface type
set val(mac) Mac/802_15_4 ;# 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) 5 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 500 ;# Y dimension of topography
set val(stop) 10.0/30/0/100.0/200.0/500.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open wireless10.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open wireless10.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel

#===================================
# Mobile node parameter setup
#===================================
#$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) \
# -channel $chan \
# -topoInstance $topo \
# -agentTrace ON \
# -routerTrace ON \
# -macTrace ON \
# -movementTrace ON

$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) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF

#===================================
# Nodes Definition
#===================================
#Create 5 nodes
set n0 [$ns node]
$n0 set X_ 105
$n0 set Y_ 80
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 209
$n1 set Y_ 202
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 369
$n2 set Y_ 221
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 312
$n3 set Y_ 126
$n3 set Z_ 0.0
$ns initial_node_pos $n3 20
set n4 [$ns node]
$n4 set X_ 315
$n4 set Y_ 19
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
#===================================
# Generate movement
#===================================
$ns at 1 " $n0 setdest 70 50 50 "
$ns at 2 " $n1 setdest 150 150 50 "
$ns at 3 " $n2 setdest 300 200 50 "
$ns at 4 " $n3 setdest 300 120 50 "
$ns at 5 " $n4 setdest 300 50 50 "
#===================================
# Agents Definition
#===================================
#Setup a TCP connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $sink1
$ns connect $tcp0 $sink1
$tcp0 set packetSize_ 1500
#Setup a UDP connection
set udp3 [new Agent/UDP]
$ns attach-agent $n1 $udp3
set null4 [new Agent/Null]
$ns attach-agent $n3 $null4
$ns connect $udp3 $null4
$udp3 set packetSize_ 1500
#===================================
# Applications Definition
#===================================
#Setup a FTP Application over TCP connection
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 1.0 "$ftp0 start"
$ns at 10.0 "$ftp0 stop"
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp3
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns at 1.0 "$cbr1 start"
$ns at 10.0 "$cbr1 stop"
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefilenamfile
$ns flush-trace
close $tracefile
close $namfile
exec nam wireless10.nam &
exit 0
}
for {set i 0} {$i< $val(nn) } { incri } {
$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run

OUTPUT:

1. 802.11/mac
2. 802.15.4/ZigBee

CONCLUSION: The graph of Delay, Throughput, PDR, Energy of mac layer


protocol 802.11 and 802.15.4. has been plotted.

You might also like