16.1.3 Network Components in a mobilenode

The network stack for a mobilenode consists of a link layer(LL), an ARP module connected to LL, an interface priority queue(IFq), a mac layer(MAC), a network interface(netIF), all connected to the channel. These network components are created and plumbed together in OTcl. The relevant MobileNode method add-interface() in ~ns/tcl/lib/ns-mobilenode.tcl is shown below:

#  The following setups up link layer, mac layer, network interface
#  and physical layer structures for the mobile node.
Node/MobileNode instproc add-interface { channel pmodel 
                lltype mactype qtype qlen iftype anttype } {

        $self instvar arptable_ nifs_
        $self instvar netif_ mac_ ifq_ ll_

        global ns_ MacTrace opt

        set t $nifs_
        incr nifs_

        set netif_($t)  [new $iftype]           ;# net-interface
        set mac_($t)    [new $mactype]          ;# mac layer
        set ifq_($t)    [new $qtype]            ;# interface queue
        set ll_($t)     [new $lltype]           ;# link layer
        set ant_($t)    [new $anttype]

        # Local Variables
        set nullAgent_ [$ns_ set nullAgent_]
        set netif $netif_($t)
        set mac $mac_($t)
        set ifq $ifq_($t)
        set ll $ll_($t)

        # Initialize ARP table only once.
        if { $arptable_ == "" } {
            set arptable_ [new ARPTable $self $mac]
            set drpT [cmu-trace Drop "IFQ" $self]
            $arptable_ drop-target $drpT

        # Link Layer
        $ll arptable $arptable_
        $ll mac $mac
        $ll up-target [$self entry]
        $ll down-target $ifq

        # Interface Queue
        $ifq target $mac
        $ifq set qlim_ $qlen
        set drpT [cmu-trace Drop "IFQ" $self]
        $ifq drop-target $drpT

        # Mac Layer
        $mac netif $netif
        $mac up-target $ll
        $mac down-target $netif
        $mac nodes $opt(nn)

        # Network Interface
        $netif channel $channel
        $netif up-target $mac
        $netif propagation $pmodel      ;# Propagation Model
        $netif node $self               ;# Bind node \<---\> interface
        $netif antenna $ant_($t)        ;# attach antenna

        # Physical Channel
        $channel addif $netif           ;# add to list of interfaces

        # ============================================================
        # Setting up trace objects
        if { $MacTrace == "ON" } {
            # Trace RTS/CTS/ACK Packets
            set rcvT [cmu-trace Recv "MAC" $self]
            $mac log-target $rcvT

            # Trace Sent Packets
            set sndT [cmu-trace Send "MAC" $self]
            $sndT target [$mac sendtarget]
            $mac sendtarget $sndT

            # Trace Received Packets
            set rcvT [cmu-trace Recv "MAC" $self]
            $rcvT target [$mac recvtarget]
            $mac recvtarget $rcvT

            # Trace Dropped Packets
            set drpT [cmu-trace Drop "MAC" $self]
            $mac drop-target $drpT
        } else {
            $mac log-target [$ns_ set nullAgent_]
            $mac drop-target [$ns_ set nullAgent_]

        # ============================================================

        $self addif $netif

The plumbing in the above method creates the network stack we see in Figure 16.1.

Each component is briefly described here. Hopefully more detailed docuentation from CMU shall be available in the future.

Link Layer
The LL used by mobilenode is same as described in Chapter 14. The only difference being the link layer for mobilenode, has an ARP module connected to it which resolves all IP to hardware (Mac) address conversions. Normally for all outgoing (into the channel) packets, the packets are handed down to the LL by the Routing Agent. The LL hands down packets to the interface queue. For all incoming packets (out of the channel), the mac layer hands up packets to the LL which is then handed off at the node_entry_ point. The LL../ns-2/ll.h is implemented in ~ns/ll.{cc,h} and ~ns/tcl/lan/ns-ll.tcl.

The Address Resolution Protocol (implemented in BSD style) module receives queries from Link layer. If ARP has the hardware address for destination, it writes it into the mac header of the packet. Otherwise it broadcasts an ARP query, and caches the packet temporarily. For each unknown destination hardware address, there is a buffer for a single packet. Incase additional packets to the same destination is sent to ARP, the earlier buffered packet is dropped. Once the hardware address of a packet's next hop is known, the packet is inserted into the interface queue. The ARPTable../ns-2/arp.h is implemented in ~ns/arp.{cc,h} and ~ns/tcl/lib/ns-mobilenode.tcl.

Interface Queue
The PriQueue../ns-2/priqueue.h is implemented as a priority queue which gives priority to routing rotocol packets, inserting them at the head of the queue. It supports running a filter over all packets in the queue and removes those with a specified destination address. See ~ns/priqueue.{cc,h} for interface queue implementation.

Mac Layer
Historically, ns-2 (prior to release ns-2.33) has used the implementation of IEEE 802.11 distributed coordination function (DCF) from CMU. Starting with ns-2.33, several 802.11 implementations are available. See section 16.3 for more information.

Tap Agents
Agents that subclass themselves as Tap../ns-2/mac.h defined in mac.h can register themselves with the mac object using method installTap(). If the particular Mac protocol permits it, the tap will promiscuously be given all packets received by the mac layer, before address filtering is done. See ~ns/mac.{cc,h} for Tap implementation.

Network Interfaces
The Network Interphase layer serves as a hardware interface which is used by mobilenode to access the channel. The wireless shared media interface is implemented as Phy/WirelessPhy../ns-2/wireless-phy.h. This interface subject to collisions and the radio propagation model receives packets transmitted by other node interfaces to the channel. The interface stamps each transmitted packet with the meta-data related to the transmitting interface like the transmission power, wavelength etc. This meta-data in pkt header is used by the propagation model in receiving network interface to determine if the packet has minimum power to be received and/or captured and/or detected (carrier sense) by the receiving node. The model approximates the DSSS radio interface (Lucent WaveLan direct-sequence spread-spectrum). See ~ns/phy.{cc.h} and ~ns/wireless-phy.{cc,h} for network interface implementations.

Radio Propagation Model
It uses Friss-space attenuation ($1/r^2$) at near distances and an approximation to Two ray Ground ($1/r^4$) at far distances. The approximation assumes specular reflection off a flat ground plane. See ~ns/tworayground.{cc,h} for implementation.

An omni-directional antenna having unity gain is used by mobilenodes. See ~ns/antenna.{cc,h} for implementation details.

Tom Henderson 2011-11-05