6. Links: Simple Links

This is the second aspect of defining the topology. In the previous chapterChapterchap:nodes, 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 in this section. 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 connectorsSectionsec:links:components. We conclude the chapter with a description the connector objectSectionsec:links:connectors, including brief descriptions of the common link connectors.

The Link../ns-2/ns-link.tcl is a standalone class in OTcl, that provides a few simple primitives. The SimpleLink../ns-2/ns-link.tcl provides the ability to connect two nodes with a point to point link. ns provides the instance procedure []simplex-link../ns-2/ns-link.tclSimulator::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 \tup{node0} \tup{node1} \tup{bandwidth} \tup{delay} \tup{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_.

Figure 6.1: Composite Construction of a Unidirectional Link
\includegraphics{link}
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 at the end of this chapterSectionsec:links:connectors, and discuss their functionality/implementation in other chapters.

The instance procedure []duplex-link../ns-2/ns-link.tclSimulator::duplex-link constructs a bi-directional link from two simplex links.



Subsections
Tom Henderson 2011-11-05