to Using the Network Simulator NS - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

to Using the Network Simulator NS

Description:

Introduction. to Using the Network Simulator NS. by Chung Ling Chi, Gigi. Outline. Introduction. Interface to the Interpreter (The duality of OTcl and C ) ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 49
Provided by: Gigi70
Category:

less

Transcript and Presenter's Notes

Title: to Using the Network Simulator NS


1
  • Introduction
  • to Using the Network Simulator NS
  • by Chung Ling Chi, Gigi

2
Outline
  • Introduction
  • Interface to the Interpreter (The duality of OTcl
    and C)
  • Topology Generation, the nodes and the links
  • Agents
  • Example
  • Conclusion

3
Introduction
  • NS is a discrete event simulator targeted at
    networking research.
  • Network researchers can study the complex
    interactions between network protocols in complex
    topologies and with a rich set of traffic
    generators.
  • extend its functionality

4
Otcl and C The Duality
Interface to the Interpreter
  • NS is an object oriented simulator, written in
    C, with an OTcl interpreter as a frontend.

5
OTcl Linkage
Interface to the Interpreter
  • C ltgt OTcl
  • class Tcl C methods to access the interpreter
  • class TclObject Root of basic object hierarchy in
    ns
  • class TclClass C class to set up the TclObject
  • hierarchy
  • class TclCommand Basic Script to provide limited
    global
  • commands to the interpreter
  • class EmbeddedTcl Container for Tcl scripts that
    are
  • pre-loaded at startup
  • class InstVar Internal class to bind C member
  • variables to OTcl instance variables

6
Class Tcl
Interface to the Interpreter
  • The class Tcl
  • Obtain a handle
  • Invoke Otcl procedures
  • Retrieve the result from the interpreter
  • On invocation, pass a result string to the
    interpreter
  • Return Success/Failure return codes

7
Class Tcl C Methods to access OTcl
Interface to the Interpreter
8
Class TclObject
Interface to the Interpreter
  • Base class for most classes in the interpreted
    and compiled hierarchies of ns
  • Hierarchy mirrored in C and OTcl
  • For example

9
Class TclObject Hierarchy and Shadowing
Interface to the Interpreter
10
Class TclObject Creation/Deletion Mechanisms
Interface to the Interpreter
  • Global procedure new
  • Global procedure delete

11
Class TclObject Binding Variables
Interface to the Interpreter
  • Makes identical C member variables to Otcl
    instance variables
  • Syntax
  • Initialisation through OTcl class variables
  • Other methods bind() (integer), bind_time()
    (time variables), bind_bw() (bandwidth
    variables), bind_bool() (boolean variables)

12
Examples of Specify Bound Variables
Interface to the Interpreter
13
Class TclObject command() methods
Interface to the Interpreter
  • Shadow object is accessed by a cmd procedure,
    called instproclike
  • For example, distance? is an instance
    procedure of an Adaptive SRM agent

14
command() methods call sequence
Interface to the Interpreter
  • Usage

15
Class TclClass
Interface to the Interpreter
  • Programmer defines C hierarchy that is mirrored
    in Otcl
  • not all classes are mirrored exactly

16
Class TclClass Definition
Interface to the Interpreter
  • For example, Adaptive SRM agent class in C is
    mirrored into Agent/SRM/Adaptive

17
Class TclClass Mechanism
Interface to the Interpreter
  • Static initialisation by compiler
  • Run time activation at startup

18
Class InstVar
Interface to the Interpreter
  • One object per bound variable
  • Created by TclObjectbind() call
  • Constructor activity
  • 1. Point to C member variable
  • 2. Create instance variable for interpreted
    object
  • 3. Enable trap read/writes to instance variable
  • using Tcl_TraceVar()

19
OTcl Linkage Summary
Interface to the Interpreter
  • Class Tcl
  • primitives to access the interpreter
  • Class TclObject root object for mirrored
    hierarchies
  • Unifies interpreted and compiled hierarchy
  • Provide seamless access to ns objects in compiled
    code and interpreted scripts
  • Class TclClass class that sets up the
    interpreted hierarchy
  • establish interpreted hierarchy
  • shadowing methods

20
Nodes
Topology Generation
  • Configuring the node
  • -- Control function
  • -- Address and port number
  • management,
  • unicast routing functions
  • -- Agent management
  • -- Adding neighbors

21
Multicast Node
Topology Generation
22
Classifiers
Topology Generation
  • Table of slots
  • Each slot can point to a TclObject
  • When a packet is received
  • classify() identifies the slot to forward the
    packet to
  • If slot is invalid, the classifier calls
    no-slot()
  • Many different types of classifiers
  • Address Classifier parse address in packet
  • Multipath Classifier returns next slot number to
    use
  • Replicator uses classifier as a table

23
Classifier Methods
Topology Generation
  • Install entries into classifier
  • install
  • installNext
  • Query entries in classifier
  • elements returns current list of elements
    inserted
  • slot returns handle of object in the specified
    slot
  • Delete entry in a particular slot
  • clear
  • classify internal method receives a packet,
    and returns a slot number for that packet

24
Links
Topology Generation
25
Connectors
Topology Generation
  • Connectors receive incoming packets, and usually
    transmit them to their target or drop-target_
  • Many different types of connectors
  • Queue holds a certain number of
    packets. Packets exceeding their queue-size
    are sent to the queues trop-target_.
  • DelayLink models delay/bandwidth of the link for
    detailed simulations.
  • DynaLink decrements TTLs on each packet, drops
    the packer if the TTL becomes zero.
  • TTLChecker transmit packets if the link is up,
    drop packet otherwise

26
Connector methods
Topology Generation
  • Add tracing or monitoring
  • Library support
  • trace
  • attach-monitors
  • init-monitor
  • C Trace class objects are implemented
  • Define trace file format
  • example of trace file

27
Agents
Agents
  • Endpoints where network-layer packets are
    constructed or consumed
  • implementation of protocols at various layers
  • Agent state

28
Agent Methods
Agents
  • Packet generation and reception
  • Packet allocpkt() allocate new packet and assign
    its fields
  • Packet allocpkt(int) allocate new packet with a
    data payload of n bytes and assign its fields
  • Member functions to be over-ridden by classes
  • void timeout(timeout number)
  • subclass-specific time out method
  • void recv(Packet, Handler)
  • receiving agent main receive path of packets

29
Protocol Agents
Agents
30
OTcl Linkage
Agents
  • Creating and Manipulating Agents
  • Default Values
  • link bind member variable between OTcl and C
    (in ns/tcl/lib/ns-default)

31
Tcp, TCP Sink Agents
Example
  • Agents
  • Class TCPAgent a simplified TCP sender to send
    packet
  • Class TCPSinkAgent receiving the packets and
    return acknowledgments
  • Creating the Agent
  • OTcl code

32
Tcp, TCP Sink Agents
Example
  • C code

33
Tcp, TCP Sink Agents
Example
  • Starting the agent
  • OTcl code
  • C code

34
Tcp, TCP Sink Agents
Example
  • Processing Input at Receiver (class TcpSinkAgent)

35
Tcp, TCP Sink Agents
Example
  • Processing Responses at the Sender (class
    TcpAgent)

36
Tcp, TCP Sink Agents
Example
  • Implementing Timers
  • derived from an abstract base class TimerHandler
  • public member functions
  • protected members

37
Tcp, TCP Sink Agents
Example
  • agent wish to override the Agenttimeout()
    method
  • Timers used in Tahoe TCP Agent
  • delsnd_timer_ delays sending of packets by a
    small random amount of time to avoid phase
    efforts
  • rtx_timer_ retransmission timer
  • burstsnd_timer_ helps TCP to stagger the
    transmission of a large window into several
    smaller bursts

38
Tcp, TCP Sink Agents
Example
  • Three timer classes (in ns/tcp.h)

39
Tcp, TCP Sink Agents
Example
  • Timer initalized with this pointer

40
Tcp, TCP Sink Agents
Example
  • Define schedule timer events

41
Tcp, TCP Sink Agents
Example
  • Timer expire

42
Tcp, TCP Sink Agents
Example
  • simple.tcl

set ns new Simulator set f open out.tr w ns
trace-all f set nf open out.nam w ns
namtrace-all nf set s1 ns node set s2 ns
node set r1 ns node set k1 ns node ns
duplex-link s1 r1 10Mb 0.1ms DropTail ns
duplex-link s2 k1 10Mb 0.1ms DropTail ns
simplex-link r1 k1 3.20Mb 20ms DropTail ns
simplex-link k1 r1 0.032Mb 20ms DropTail ns
queue-limit r1 k1 8 ns queue-limit k1 r1 8
43
Tcp, TCP Sink Agents
Example
  • simple.tcl (cont.)

set tcp ns create-connection TCP s1 TCPSink
s2 1 tcp set fid_ 1 tcp set flow_id 1 tcp
set window_ 1000 set ftp tcp attach-app
FTP ns at 0.0 "ftp start" ns at 50.0
"finish" proc finish global ns f nf ns
flush-trace close f close nf puts "running
nam..." exec nam out.nam exit 0 ns run
44
Tcp, TCP Sink Agents
Example
  • Using Nam
  • Tcl/TK based animation tool for viewing network
    simulation traces and real world packet trace
    data.
  • The trace file is generated by ns (out.nam)

k1
s1
s2
r1
45
Tcp, TCP Sink Agents
Example
  • Packets and acks passing

46
Tcp, TCP Sink Agents
Example
  • View the information of packet and ack

47
Tcp, TCP Sink Agents
Example
  • Analysis on the trace file (out.tr)

48
Conclusion
  • ftp//mash.cs.berkeley.edu/dist/vint/
  • download software ns-allinone-2.1b5a
  • run in Unix
  • http//www-mash.cs.berkeley.edu/ns/
  • download documentation
Write a Comment
User Comments (0)
About PowerShow.com