Difference between revisions of "Manual: Links: Simple Links"

From nsnam
Jump to: navigation, search
(Initial creation)
 
m (Instance Procedures for Links and SimpleLinks)
 
Line 52: Line 52:
 
|up?{} || returns status of the link. Status is "up" or "down"; status is "up" if link dynamics is not enabled.
 
|up?{} || returns status of the link. Status is "up" or "down"; status is "up" if link dynamics is not enabled.
 
|-
 
|-
|all-connectors{} || Apply specified operation to all connectors on the link.p An example of such usage is link all-connectors reset.
+
|all-connectors{} || Apply specified operation to all connectors on the link. An example of such usage is link all-connectors reset.
 
|-
 
|-
 
|cost{} || set link cost to value specified.
 
|cost{} || set link cost to value specified.

Latest revision as of 04:57, 2 December 2008

Previous chapter: "Nodes and Packet Forwarding" | index | Next chapter: "Queue Management and Packet Scheduling"

This is the second aspect of defining the topology. In the previous chapter, we had described how to create the nodes in the topology in ns. We now describe how to create the links to connect the nodes and complete the topology. In this chapter, we restrict ourselves to describing the simple point to point links. ns supports a variety of other media, including an emulation of a multi-access LAN using a mesh of simple links, and other true simulation of wireless and broadcast media. They will be described in a separate chapter. The CBQlink is derived from simple links and is a considerably more complex form of link that is also not described in this chapter.

We begin by describing the commands to create a link. As with the node being composed of classifiers, a simple link is built up from a sequence of connectors. We also briefly describe some of the connectors in a simple link. We then describe the instance procedures that operate on the various components of defined by some of these connectors. There is then a description the connector object, including brief descriptions of the common link connectors. We conclude the chapter with a description of the object hierarchy.

Creating a Link

The class Link is a standalone class in OTcl, that provides a few simple primitives. The class SimpleLink provides the ability to connect two nodes with a point to point link. ns provides the instance procedure simplex-link{} to form a unidirectional link from one node to another. The link is in the class SimpleLink. The following describes the syntax of the simplex link:

set ns [new Simulator]
$ns simplex-link <node0> <node1> <bandwidth> <delay> <queue_type>

The command creates a link from <node0> to <node1>, with specified <bandwidth> and <delay> characteristics. The link uses a queue of type <queue_type>. The procedure also adds a TTL checker to the link. Five instance variables define the link:

head_ Entry point to the link, it points to the first object in the link.
queue_ Reference to the main queue element of the link. Simple links usually have one queue per link. Other more complex types of links may have multiple queue elements in the link.
link_ A reference to the element that actually models the link, in terms of the delay and bandwidth characteristics of the link.
ttl_ Reference to the element that manipulates the ttl in every packet.
drophead_ Reference to an object that is the head of a queue of elements that process link drops.

In addition, if the simulator instance variable, $traceAllFile_, is defined, the procedure will add trace elements that track when a packet is enqueued and dequeued from queue_. Furthermore, tracing interposes a drop trace element after the drophead_. The following instance variables track the trace elements:

enqT_ Reference to the element that traces packets entering queue_.
deqT_ Reference to the element that traces packets leaving queue_.
drpT_ Reference to the element that traces packets dropped from queue_.
rcvT_ Reference to the element that traces packets received by the next node.

Note however, that if the user enable tracing multiple times on the link, these instance variables will only store a reference to the last elements inserted.

Other configuration mechanisms that add components to a simple link are network interfaces (used in multicast routing), link dynamics models, and tracing and monitors. We give a brief overview of the related objects in the section on connectors, and discuss their functionality/implementation in other chapters.

The instance procedure duplex-link{} constructs a bi-directional link from two simplex links.

Instance Procedures for Links and SimpleLinks

Link procedures The class Link is implemented entirely in Otcl. The OTcl SimpleLink class uses the C++ LinkDelay class to simulate packet delivery delays. The instance procedures in the class Link are:

head{} returns the handle for head_.
queue{} returns the handle for queue_.
link{} returns the handle for the delay element, link_.
up{} set link status to "up" in the dynamics_ element. Also, writes out a trace line to each file specified through the procedure trace-dynamics{}.
down{} As with up{}, set link status to "down" in the dynamics_ element. Also, writes out a trace line to each file specified through the procedure trace-dynamics{}.
up?{} returns status of the link. Status is "up" or "down"; status is "up" if link dynamics is not enabled.
all-connectors{} Apply specified operation to all connectors on the link. An example of such usage is link all-connectors reset.
cost{} set link cost to value specified.
cost?{} returns the cost of the link. Default cost of link is 1, if no cost has been specified earlier.

SimpleLink Procedures The Otcl class SimpleLink implements a simple point-to-point link with an associated queue and delay. (The current version also includes an object to examine the network layer “ttl” field and discard packets if the field reaches zero.) It is derived from the base Otcl class Link as follows:

Class SimpleLink -superclass Link
SimpleLink instproc init { src dst bw delay q { lltype "DelayLink" } } {
   $self next $src $dst
   $self instvar link_ queue_ head_ toNode_ ttl_
   ...
   set queue_ $q
   set link_ [new Delay/Link]
   $link_ set bandwidth_ $bw
   $link_ set delay_ $delay
   $queue_ target $link_
   $link_ target [$toNode_ entry]
   ...
   # XXX
   # put the ttl checker after the delay
   # so we don’t have to worry about accounting
   # for ttl-drops within the trace and/or monitor
   # fabric
   #
   set ttl_ [new TTLChecker]
   $ttl_ target [$link_ target]
   $link_ target $ttl_
}

Notice that when a SimpleLink object is created, new Delay/Link and TTLChecker objects are also created. Note also that, the Queue object must have already been created.

There are two additional methods implemented (in OTcl) as part of the SimpleLink class: trace and init-monitor. These functions are described in further detail in the section on tracing.

Connectors

Connectors, unlink classifiers, only generate data for one recipient; either the packet is delivered to the target_ neighbor, or it is sent to he drop-target_.

A connector will receive a packet, perform some function, and deliver the packet to its neighbor, or drop the packet. There are a number of different types of connectors in ns. Each connector performs a different function.

networkinterface labels packets with incoming interface identifier—it is used by some multicast routing protocols. The class variable “Simulator NumberInterfaces_ 1” tells ns to add these interfaces, and then, it is added to either end of the simplex link. Multicast routing protocols are discussed in a separate chapter (Chapter 31).
DynaLink Object that gates traffic depending on whether the link is up or down. It expects to be at the head of the link, and is inserted on the link just prior to simulation start. It’s status_ variable control whether the link is up or down. The description of how the DynaLink object is used is in a separate chapter (Chapter 32).
DelayLink Object that models the link’s delay and bandwidth characteristics. If the link is not dynamic, then this object simply schedules receive events for the downstream object for each packet it receives at the appropriate time for that packet. However, if the link is dynamic, then it queues the packets internally, and schedules one receives event for itself for the next packet that must be delivered. Thus, if the link goes down at some point, this object’s reset() method is invoked, and the object will drop all packets in transit at the instant of link failure. We discuss the specifics of this class in another chapter (Chapter 8).
Queues model the output buffers attached to a link in a “real” router in a network. In ns, they are attached to, and are considered as part of the link. We discuss the details of queues and different types of queues in nsin another chapter (Chapter 7).
TTLChecker will decrement the ttl in each packet that it receives. If that ttl then has a positive value, the packet is forwarded to the next element on the link. In the simple links, TTLCheckers are automatically added, and are placed as the last element on the link, between the delay element, and the entry for the next node.

Object hierarchy

The base class used to represent links is called Link. Methods for this class are listed in the next section. Other link objects derived from the base class are given as follows:

  • SimpleLink Object A SimpleLink object is used to represent a simple unidirectional link. There are no state variables or configuration parameters associated with this object. Methods for this class are:
$simplelink enable-mcast <src> <dst>
This turns on multicast for the link by creating an incoming network interface for the destination and adds an outgoing interface for the source.
$simplelink trace <ns> <file> <optional:op>
Build trace objects for this link and update object linkage. If op is specified as "nam" create nam trace files.
$simplelink nam-trace <ns> <file>
Sets up nam tracing in the link.
$simplelink trace-dynamics <ns> <file> <optional:op>
This sets up tracing specially for dynamic links. <op> allows setting up of nam tracing as well.
$simplelink init-monitor <ns> <qtrace> <sampleInterval>
Insert objects that allow us to monitor the queue size of this link. Return the name of the object that can be queried to determine the average queue size.
$simplelink attach-monitors <insnoop> <outsnoop> <dropsnoop> <qmon>
This is similar to init-monitor, but allows for specification of more of the items.
$simplelink dynamic
Sets up the dynamic flag for this link.
$simplelink errormodule <args>
Inserts an error module before the queue.
$simpleilnk insert-linkloss <args>
Inserts the error module after the queue.
//Other link objects derived from class SimpleLink are FQLink, CBQLink and IntServLink.
Configuration parameters for FQLink are:
queueManagement_ The type of queue management used in the link. Default value is DropTail.

No configuration parameters are specified for CBQLink and IntServLink objects.

  • DelayLink Object The DelayLink Objects determine the amount of time required for a packet to traverse a link. This is defined to be size/bw + delay where size is the packet size, bw is the link bandwidth and delay is the link propagation delay. There are no methods or state variables associated with this object.
Configuration Parameters are:
bandwidth_ Link bandwidth in bits per second.
delay_ Link propagation delay in seconds.

Commands at a glance

Following is a list of common link commands used in simulation scripts:

$ns_ simplex-link <node1> <node2> <bw> <delay> <qtype> <args>
This command creates an unidirectional link between node1 and node2 with specified bandwidth (BW) and delay characteristics. The link uses a queue type of <qtype> and depending on the queue type different arguments are passed through <args>.
$ns_ duplex-link <node1> <node2> <bw> <delay> <qtype> <args>
This creates a bi-directional link between node1 and node2. This procedure essentially creates a duplex-link from two simplex links, one from node1 to node2 and the other from node2 to node1. The syntax for duplex-link is same as that of simplex-link described above.
$ns_ duplex-intserv-link <n1> <n2> <bw> <dly> <sched> <signal> <adc> <args>
This creates a duplex-link between n1 and n2 with queue type of intserv, with specified BW and delay. This type of queue implements a scheduler with two level services priority. The type of intserv queue is given by <sched>, with admission control unit type of <adc> and signal module of type <signal>.
$ns_ simplex-link-op <n1> <n2> <op> <args>
This is used to set attributes for a simplex link. The attributes may be the orientation, color, label, or queue-position.
$ns_ duplex-link-op <n1> <n2> <op> <args>
This command is used to set link attributes (like orientation of the links, color, label, or queue-position) for duplex links.
$ns_ link-lossmodel <lossobj> <from> <to>
This function generates losses (using the loss model <lossobj> inserted in the link between <from> node and <to> node) in the link that can be visualized by nam.
$ns_ lossmodel <lossobj> <from> <to>
This is used to insert a loss module in regular links.

Following is a list of internal link-related procedures:

$ns_ register-nam-linkconfig <link>
This is an internal procedure used by "$link orient" to register/update the order in which links should be created in nam.
$ns_ remove-nam-linkconfig <id1> <id2>
This procedure is used to remove any duplicate links (duplicate links may be created by GT-ITM topology generator).
$link head
Returns the instance variable head_ for the link. The head_ is the entry pont to the link and it points to the first object in the link.
$link add-to-head <connector>
This allows the <connector> object to be now pointed by the head_ element in the link, i.e, <connector> now becomes the first object in the link.
$link link
Returns the instance variable link_. The link_ is the element in the link that actually models the link in terms of delay and bandwidth characteristics of the link.
$link queue
Returns the instance variable queue_. queue_ is queue element in the link. There may be one or more queue elements in a particular link.
$link cost <c>
This sets a link cost of <c>.
$link cost?
Returns the cost value for the link. Default cost of link is set to 1.
$link if-label?
Returns the network interfaces associated with the link (for multicast routing).
$link up
This sets the link status to "up". This command is a part of network dynamics support in ns.
$link down
Similar to up, this command marks the link status as "down".
$link up?
Returns the link status. The status is always "up" as default, if link dynamics is not enabled.
$link all-connectors op
This command applies the specified operation <op> to all connectors in the link. Like, $link all-connectors reset or $link all-connectors isDynamic.
$link install-error <errmodel>
This installs an error module after the link_ element.

In addition to the Link and link-related commands listed above, there are other procedures to support the specific requirements of different types of links derived from the base class "Link" like simple-link (SimpleLink), integrated service (IntServLink), class-based queue (CBQLink), fair queue (FQLink) and procedures to support multicast routing, sessionsim, nam etc. These and the above procedures may be found in ~ns/tcl/lib(ns-lib.tcl, ns-link.tcl, ns-intserv.tcl, ns-namsupp.tcl, ns-queue.tcl), ~ns/tcl/mcast/(McastMonitor.tcl, ns-mcast.tcl), ~ns/tcl/session/session.tcl.

Previous chapter: "Nodes and Packet Forwarding" | index | Next chapter: "Queue Management and Packet Scheduling"