Professional Documents
Culture Documents
Exp 1
Exp 1
Practical No: 3
Evaluation:
Conclusion: Mobile networks using NS2 has been studied and implemented successfully.
Description:
NS (version 2) is an object-oriented, discrete event driven network simulator developed at UC
Berkely written in C++ and OTcl. NS is primarily useful for simulating local and wide area
networks. It implements network protocols such as TCP and UPD, traffic source behavior such
as FTP, Telnet, Web, CBR and VBR, router queue management mechanism such as Drop Tail,
RED and CBQ, routing algorithms such as Dijkstra, and more. NS also implements multicasting
and some of the MAC layer protocols for LAN simulations.
Steps:
1. Set the following configuration for each node’s interface
- Type of channel - Wireless Channel
- Type of propagation – TwoRayGround
- Physical Layer – Wireless
- Mac Layer – MAC 802.11
- Type of Queue – DropTail / PriQueue
- LinkLayer – LL
- Type of Antenna - OmniAntenna
- Maximum Packet in Queue - 50
2. Open Trace file in write mode
3. Open NAM file in write mode.
4. Create a topology containing 6 groups each having 4 nodes. Use FlatGrid topology
5. Configure each node using the configuration set in step 1.
6. Create a simple MessagePassing/Flooding agent
7. Create Receive procedure that receives each packet and maintain list of unseen messages
8. Create send procedure that broadcasts message.
9. Create MessagePassing/Flooding agent and attach it with every node.
10. Set up some events.
11. Write finish procedure.
DSDV:
DSDV (Destination-Sequenced Distance-Vector) is a routing protocol designed for use in
mobile ad-hoc networks (MANETs). It is a proactive protocol, meaning that it continuously
maintains and updates routing information for all nodes in the network. Each node in the network
maintains a routing table that contains the next hop and the number of hops needed to reach each
destination. The routing table is updated by using a distance-vector algorithm, in which each node
exchanges its routing table with its neighbours at regular intervals. The routing table entries also
have a sequence number assigned by the destination node, which is used to ensure that the most
recent and accurate routing information is used. When a node receives an update from a neighbour,
it compares the sequence number in the update with the one in its own routing table. If the received
sequence number is higher, the node updates its routing table with the new information. To prevent
routing loops, DSDV uses a technique called "poison reverse", where each node sends updates to
its neighbours with a metric of infinity for any routes that lead back to itself. In addition to the
regular updates, DSDV also uses triggered updates. When a node detects a change in the network,
such as a link failure, it immediately sends a triggered update to its neighbours to inform them of
the change. This helps to quickly converge to the new state of the network. DSDV has several
advantages over other routing protocols for MANETs, including the ability to handle dynamic
network changes and the ability to work with multi-hop routes. However, it also has a high
overhead for maintaining and updating routing information, which can consume a lot of bandwidth
and power.
set a 1
while {$a == 1 } {
puts "Enter the Routing Agents in mobile networking"
puts "1. AODV"
puts "2. DSDV"
puts "3. DSR"
#ANNOTATIONS DETAILS
proc stop {} {
} elseif {$top == 2} {
# 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) 7 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 400 ;# Y dimension of topography
set val(stop) 100 ;# time of simulation end
set ns [new Simulator]
set tracefd [open dsdv.tr w]
set namtrace [open dsdv.nam w]
Mobile Computing Lab Manual:
$ns use-newtrace
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
create-god $val(nn)
#
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
#
# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 10.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 10.0"
$ns at 29.0 "$node_(2) setdest 480.0 300.0 10.0"
$ns at 70.0 "$node_(3) setdest 180.0 30.0 10.0"
$ns at 80.0 "$node_(4) setdest 80.0 30.0 10.0"
$ns at 90.0 "$node_(5) setdest 98.0 30.0 10.0"
$ns at 80.0 "$node_(6) setdest 50.0 30.0 10.0"
$ns run
} elseif {$top == 3} {
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 3 ;# number of mobilenodes
set opt(rp) DSR ;# routing protocol
set opt(x) 500 ;# X dimension of topography
set opt(y) 400 ;# Y dimension of topography
set opt(stop) 150 ;
set ns [new Simulator]
#Creating trace file and nam file
set tracefd [open Dsr.tr w]
create-god $opt(nn)
# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 110.0 "$node_(0) setdest 480.0 300.0 5.0"
$ns run
}
puts "want to continue (0/1)"
set a [gets stdin]
}