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.
Tom Henderson 2011-11-05