Você está na página 1de 13

SRI JAYACHAMARAJENDRA COLLEGE OF ENGINEERING MYSORE-570006 Department of Information science and Engineering

Assignment - 2 802.11 Wireless Network Simulation Using NS2

Submitted by name rollno Upadhyay Dhananjay A P120713

usn 4JC12SSE16

Guidance of P.M. Shivamurthy Assistant professor Dept of IS, SJCE Mysore.

Aliated to VISVESVARAYA TECHNOLOGICAL UNIVERSITY

Contents
1 Introduction 1.1 802.11 Wireless Network . . . . . . . . . . . . . . . . . . . . . . . 1.2 802.11 in Ethernet . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Our Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Why NS2? 2.1 Advantages/Disadvantages of NS2 . . . . . . . . . . . . . . . . . 2.2 Why Simulation? . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 DSDV Routing Algorithm: 4 Program Execution in NS2 4.1 Dene optional Parameter . . . . . 4.2 Setup a Simulator . . . . . . . . . 4.3 Topology . . . . . . . . . . . . . . 4.4 Congure Nodes . . . . . . . . . . 4.5 Congure Nodes . . . . . . . . . . 4.6 Creating The Nodes . . . . . . . . 4.7 Adding the source and destination 4.8 Achived Node Structure . . . . . . 4.9 Time to run the simulation . . . . 5 How the Code Works 6 Conclusion and Future Enhancement 7 Reference 3 3 3 4 4 5 5 6 7 7 7 7 7 8 8 8 9 9 10 12 13

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

1
1.1

Introduction
802.11 Wireless Network

Unfortunately, 802.11 takes acronyms to new heights, which makes the introduction that much more important. With 802.11, the introduction serves another important purpose. 802.11 is supercially similar to Ethernet. Understanding the background of Ethernet helps slightly with 802.11, but there is a host of additional background needed to appreciate how 802.11 adapts traditional Ethernet technology to a wireless world. To account for the dierences between wired networks and the wireless media used by 802.11, a number of additional management features were added. At the heart of 802.11 is a white lie about the meaning of media access control (MAC). Wireless network interface cards are assigned 48-bit MAC addresses, and, for all practical purposes, they look like Ethernet network interface cards. In fact, the MAC address assignment is done from the same address pool so that 802.11 cards have unique addresses even when deployed into a network with wired Ethernet stations.

1.2

802.11 in Ethernet

Relation of 802.11 wireless network in OSI mode:

1.3

Our Goal

Our System goal is to make virtual system in which we have 5 nodes, two node work as Agent and others works as Routers in between this agent We have separate each node with 200m distance and connected with link of 10Mbps each of it. We have to measure the Throughput of the system while transferring the packets from one Agent to other. System diagram of nodes and Link

We will run this simulation for three dierent timing 80ms 120ms 160ms The ns2 network simulator is a powerful tool, but unfortunately it does not provide any tools for getting results. It simply simulates a network, and provides a trace le of all the events that occur. Our TCL Program script is generating the same trace le and we will derived the attribute from this le for further uses.

Why NS2?

NS2 is an open-source event-driven simulator designed specically for research in computer communication networks. NS2 now contains modules for numerous network components such as routing, transport layer protocol, application, etc. Network Simulator (Version 2), widely known as NS2, is simply an eventdriven simulation tool that has proved useful in studying the dynamic nature of communication networks. Simulation of wired as well as wireless network functions and protocols (e.g.,routing algorithms, TCP, UDP) can be done using NS2.

In general, NS2 provides users with a way of specifying such network protocols and simulating their corresponding behaviors. NS2 provides a large number of built-in C++ objects. It is advisable to use these C++ objects to set up a simulation using a Tcl simulation script.However, advance users may nd these objects insucient. They need to develop their own C++ objects, and use a OTcl conguration interface to put together these objects. After simulation, NS2 outputs either text-based or animation-based simulation results. To interpret these results graphically and interactively, tools such as NAM (Network AniMator) and XGraph are used. To analyze a particular behavior of the network, users can extract a relevant subset of text-based data and transform it to a more conceivable presentation.

2.1

Advantages/Disadvantages of NS2

Advantages: sometimes cheaper nd bugs (in design) in advance generality: over analytic/numerical techniques detail: can simulate system details at arbitrary level Disadvantages: caution: does model reect reality large scale systems: lots of resources to simulate (especially accurately simulate) may be slow (computationally expensive 1 min real time could be hours of simulated time) art: determining right level of model complexity statistical uncertainty in results

2.2

Why Simulation?

Whenever real-system not available,or system is complex/costly or dangerous (eg: space simulations, ight simulations to build we can use the simulation on design network.

The time duration is very sort then we can not build the original system. By quickly evaluate design alternatives (eg: dierent system congurations) we can manege. We can evaluate complex functions for which closed form formulas or numerical techniques not available.

DSDV Routing Algorithm:

Destination sequenced distance vector routing (DSDV) is adapted from the conventional Routing Information Protocol (RIP) to ad hoc networks routing. It adds a new attribute, sequence number, to each route table entry of the conventional RIP. Using the newly added sequence number, the mobile nodes can distinguish stale route information from the new and thus prevent the formation of routing loops. In DSDV, each mobile node of an ad hoc network maintains a routing table, which lists all available destinations, the metric and next hop to each destination and a sequence number generated by the destination node. Using such routing table stored in each mobile node, the packets are transmitted between the nodes of an ad hoc network. Each node of the ad hoc network updates the routing table with advertisement periodically or when signicant new information is available to maintain the consistency of the routing table with the dynamically changing topology of the ad hoc network. Ftp transfers the data packet from one node to other(From one Agent to other).

4
4.1
set set set set set set set set set set

Program Execution in NS2


Dene optional Parameter
val(chan) val(prop) val(ant) val(ll) val(ifq) val(ifqlen) val(netif) val(mac) val(rp) val(nn) Channel/WirelessChannel Propagation/TwoRayGround Antenna/OmniAntenna LL Queue/DropTail/PriQueue 50 Phy/WirelessPhy Mac/802_11 DSDV 5 ;# ;# ;# ;# ;# ;# ;# ;# ;# ;# channel type radio-propagation model Antenna type Link layer type Interface queue type max packet in ifq network interface type MAC type ad-hoc routing protocol number of mobilenodes

4.2

Setup a Simulator

# Creating the simulator set ns_ [new Simulator] # Set up trace file $ns_ use-newtrace set tracefd [open simple.tr w] $ns_ trace-all $tracefd # Create the "general operations director" # Used internally by MAC layer: must create! create-god $val(nn)

4.3

Topology

# Create and configure topography (used for mobile scenarios) set topo [new Topography] # 1000x1000m terrain $topo load_flatgrid 1000 1000

4.4

Congure 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) \ -channel [new $val(chan)] \ -topoInstance $topo \

-agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF

4.5

Congure 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) \ -channel [new $val(chan)] \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF

4.6

Creating The Nodes

# Setting the node and distance for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0 $node_($i) set Y_ 0.0 $node_($i) set Z_ 0.0 } $node_(0) $node_(1) $node_(2) $node_(3) $node_(4) set set set set set X_ X_ X_ X_ X_ 0.0 200.0 400.0 600.0 800.0

;# disable random motion

4.7

Adding the source and destination

# 1500 - 20 byte IP header - 40 byte TCP header = 1440 bytes Agent/TCP set packetSize_ 1440 ;# This size EXCLUDES the TCP header set agent [new Agent/TCP] set app [new Application/FTP] set sink [new Agent/TCPSink]

$app attach-agent $agent $ns_ attach-agent $node_(0) $agent $ns_ attach-agent $node_(4) $sink $ns_ connect $agent $sink

4.8

Achived Node Structure

Agent node containing the TCP, Node containing routing algorithm and Queue. Link is connected with other node with TCP Sink

4.9
# 30 $ns_ # 60 $ns_ $ns_

Time to run the simulation


seconds of warmup time for routing at 0.0 "$app start" seconds of running the simulation time at 120.0 "$ns_ halt" run

$ns_ flush-trace close $tracefd

How the Code Works

The ow of code work can be analyzed based on the ow of the program from the of optional parameter where we dene the 802.11 Mac and DSDV routing protocol, then we dene the trace le name in which we want to write the output of our program. Then we setting up the simulator, without this it is not possible to generate correct output. After setting the simulator we dene the topology which we used in the system On each node we have to congure the protocol and Tracing information which shows in Trace le. After congure the node we have created logical 5 node which are 200m apart from each.We have created the Source and destination, source as Agent destination as Agent and intermediate nodes works as router

Result Analysis
TRACE FILE OUT PUT: 1. s -t 0.000000000 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 0.00 -Nz 0.00 -Ne -1.000000 -Nl AGT -Nw -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0.0 -Id 4.0 -It tcp -Il 40 -If 0 -Ii 0 -Iv 32 -Pn tcp -Ps 0 -Pa 0 -Pf 0 -Po 0 2. r -t 0.000000000 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 0.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0.0 -Id 4.0 -It tcp -Il 40 -If 0 -Ii 0 -Iv 32 -Pn tcp -Ps 0 -Pa 0 -Pf 0 -Po 0 3. s -t 0.031538939 -Hs 1 -Hd -1 -Ni 1 -Nx 200.00 -Ny 0.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 1.255 -Id -1.255 -It message -Il 32 -If 0 -Ii 1 -Iv 32 4. r -t 0.032599606 -Hs 0 -Hd -1 -Ni 0 -Nx 0.00 -Ny 0.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw -Ma 0 -Md -Ms 1 -Mt 800 -Is 1.255 -Id -1.255 -It message -Il 32 -If 0 -Ii 1 -Iv 32 5. r -t 0.032599606 -Hs 2 -Hd -1 -Ni 2 -Nx 400.00 -Ny 0.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw -Ma 0 -Md -Ms 1 -Mt 800 -Is 1.255 -Id -1.255 -It message -Il 32 -If 0 -Ii 1 -Iv 32

10

Each line represents a message being transferred Common elds: Event type (s = send, r = received, d = drop) Time stamp Source and destination XYZ co-ordinates of the node Network layer (AGT = agent, RTR = router, ) many many others

11

Conclusion and Future Enhancement

By Running the simulation of wireless network without random motion of the router, it easily shows us the clear output in trace le. We can use this trace le in various manner for the system.We can use same topology in Wired network for throughput, as we know that Wired network are more expensive. We can build the logical network in ns2 and simulate it. This can be further enhanced for Intera Network organization(Educations Institute and Oces) to check the packet simulation

12

Reference
http://ns2-experience.blogspot.in/2008/01/why-ns2.html http://en.wikipedia.org/wiki/IEEE8 02.11 pages.cs.wisc.edu/ akella/CS740/S07/notes/nstut.ppt www.winlab.rutgers.edu/ zhibinwu/html/networks imulator2 .html en.wikipedia.org/.../Destination-SequencedD istanceV ectorr outing www.cs.caltech.edu/ weixl/technical/ns2linux/index.html

13

Você também pode gostar