Tran Minh Trung

Ph.D., Hanoi University of Science and Technology – School of Electronics and Communications

Interfaces of Wireless MAC in ns-2

Posted by trungtm on June 16, 2007

Source: Zhibin Wo (WINLAB)

The relationship of MAC could be found in ns-mobilenode.tcl.

The source code:

# 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 actype type qlen iftype anttype topo inerrproc
outerrproc ecproc}
{$self instvar arptable_ nifs_ netif_ mac_ ifq_ ll_
imep_ inerr_ outerr_ fec_

	# Link Layer
	$ll arptable $arptable_
	$ll mac $mac
	$ll down-target $ifq

	if {$imepflag == "ON" } {
		$imep recvtarget [$self entry]
		$imep sendtarget $ll
		$ll up-target $imep

        } else {
		$ll up-target [$self entry]
	# Interface Queue
	$ifq target $mac
	$ifq set limit_ $qlen
	if {$imepflag != ""} {
		set drpT [$self mobility-trace Drop "IFQ"]
	} else {
		set drpT [cmu-trace Drop "IFQ" $self]
	$ifq drop-target $drpT
	if { $namfp != "" } {
		$drpT namattach $namfp

        # Mac Layer
	$mac netif $netif
	$mac up-target $ll

	if {$outerr == "" && $fec == ""} {
		$mac down-target $netif
	} elseif {$outerr != "" && $fec == ""} {
		$mac down-target $outerr
		$outerr target $netif
	} elseif {$outerr == "" && $fec != ""} {
		$mac down-target $fec
		$fec down-target $netif
	} else {
		$mac down-target $fec
		$fec down-target $outerr
		$err target $netif

Actually, from top to down path, the structure is ll —> ifq —-> mac —> netif . for packets going up, it is netif —> mac —>ll. Thus, ifq is only used for down path of . however, a scheduler is also only useful to handle outgoing packets. Thus, if we want to implement a scheduler, we have to use something to replace this “ifq” and remake the interface in tcl script.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: