A Tutorial of NS2 and its Wireless Simulation - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

A Tutorial of NS2 and its Wireless Simulation

Description:

is essentially a centralized discrete event scheduler. For more information ... In particular, none of the provided propagation models include Doppler effects, ... – PowerPoint PPT presentation

Number of Views:482
Avg rating:3.0/5.0
Slides: 30
Provided by: appsrvCs
Category:

less

Transcript and Presenter's Notes

Title: A Tutorial of NS2 and its Wireless Simulation


1
A Tutorial of NS-2 and its Wireless Simulation
  • Yue Wang
  • July 21, 2007

2
Agenda
  • Introduction to NS-2
  • What is NS-2
  • NS-2 vs GloMoSim OPNET
  • NS-2 Basics
  • Wireless Simulation
  • PHY Layer
  • MAC Layer
  • Example My Fading Extension
  • Bugs

3
What is NS-2
  • NS-2 (Network Simulator 2) is
  • a TCL interpreter ?
  • a C project ?
  • a protocol stack ?
  • NS-2 is
  • a network simulator using TCL scripts as
    configuration interface and using C
    objects/functions to simulate network
    components/protocols

4
What is NS-2 (cont)
  • NS-2
  • can do packet level simulation
  • supports a variety of wired/wireless protocols
  • is essentially a centralized discrete event
    scheduler
  • For more information
  • NS-2 http//www.isi.edu/nsnam/ns/
  • Baisi Forum http//www.baisi.net/forum-440-1.html
  • My wireless tutorial http//www.cse.cuhk.edu.hk/
    ywang/ns2.html

5
NS-2 vs GloMoSim OPNET
6
NS-2 Basics
  • NS-2 directory structure

7
NS-2 Basics (cont)
  • Network Components
  • Simple components
  • correspond to a single C object
  • Compound components
  • a combination of multiple simple components
  • Example

8
NS-2 Basics (cont)
  • Node component
  • Link component

9
NS-2 Basics (cont)
  • class Event
  • defined by time, uid, next, handler
  • class Packet is a subclass of Event
  • Timer is a subclass of Event
  • class Handler
  • All network components are its subclasses
  • TimerHander which handles expired timers
  • Scheduler
  • void Schedulerschedule(Handler h, Event e,
    double delay)

10
NS-2 Basics (cont)
  • Scheduling procedure

Note There are no real time, timer and packet
tx/rx in ns-2 as in UNIX network programming.
11
NS-2 Basics (cont)
  • Example 1 A and B are two mobile nodes within tx
    range. A wants to send packet p to B.

12
NS-2 Basics (cont)
  • Example 2 TimerHandler

13
NS-2 Basics (cont)
  • recv function is often the entry to each network
    component / protocol
  • e.g. in 802.11

14
Wireless Simulation
  • The inner structure of a wireless node

15
Limitations in Simulating Mobile Wireless Networks
  • Nodes do not move significantly over the length
    of time they transmit or receive a packet. This
    assumption holds only for mobile nodes of
    high-rate and low-speed.
  • Consider a node with the sending rate of 10Kbps
    and moving speed of 10m/s, during its receiving a
    packet of 1500B, the node moves 12m. Thus, the
    surrounding can change significantly and cause
    reception failure.
  • Node velocity is insignificant compared to the
    speed of light. In particular, none of the
    provided propagation models include Doppler
    effects, although they could.

16
PHY layer class Channel
  • Its function is to deliver packets from a
    wireless node to its neighbors within sensing
    range
  • I. Stamp txinfo in packets before sending, for
    receivers to calculate receiving power
  • II. Send packets to the nodes within the sensing
    range distCST_ for sensing or receiving

17
PHY layer class WirelessPhy (NetIF)
  • Its function is to transmit/receive packets
    to/from Channel
  • Transmitting
  • Receiving
  • Calculate receiving power
  • can not sense the packet
  • can sense but can not decode the packet
  • can decode the packet (Note that SNR will be
    checked in MAC layer for finally receiving the
    packet)

18
MAC layer class Mac802_11 (cont)
  • Its function is to send/receive packets to/from
    NetIF
  • Sending CSMA/CA
  • Receiving SNR threshold based capture model
  • Need to understand its state transition diagram

19
MAC layer class Mac802_11 (cont)
  • States

20
MAC layer class Mac802_11 (cont)
  • Channel idle state

21
MAC layer class Mac802_11 (cont)
  • Timers

22
MAC layer class Mac802_11 (cont)
  • Example 1 controlling backoff timer

23
MAC layer class Mac802_11 (cont)
  • Sending packets (CSMA/CA)

Note Packets will be transmitted in
backoffHandler() after mhBackoff_ expires
24
MAC layer class Mac802_11 (cont)
  • Receiving packets (capture)

25
My Fading Extension
  • Standard NS-2 does not consider fading effect

26
Example 1 of fading effect
  • How fading affects TCP throughput

(a) Without fading
(b) With fading
27
Example 2 of fading effect
  • How fading affects flow fairness

(a) Without fading
(b) With fading
28
Bugs in NS-2
  • Oversimplifications
  • E.g. there is no scanning for WLAN
    (Discovery/Select/Authentication/Association)
  • Standard Misinterpretation
  • E.g. abuse of EIFS

29
  • Thanks!
Write a Comment
User Comments (0)
About PowerShow.com