Chinaunix首页 | 论坛 | 博客
  • 博客访问: 556068
  • 博文数量: 126
  • 博客积分: 2071
  • 博客等级: 大尉
  • 技术积分: 1522
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-24 16:09
文章分类
文章存档

2013年(8)

2012年(37)

2011年(80)

2010年(1)

分类:

2011-02-10 22:34:07

The following modifications can be applied to ns-2.26. It should be applicable to 2.1b8a and 2.1b9 as well, but not to 2.28 and later version as I observed there is modification to the low level config of wireless channels in both tcl and c++ and I haven't figured it out.

At least following files should be modified:

Ns-lib.tcl (tcl\lib): Add multiple interfaces
### BEGIN ###
#Add multi-interface support
if{[info exists channel2_]} {
set chan2 $channel2_
}
..

$self instvar routingAgent_ wiredRouting_ propInstance_ llType_ \
macType_ ifqType_ ifqlen_ phyType_ chan chan2 chan3 chan4 chan5 antType_ energyModel_ \
inic_tialEnergy_ txPower_ rxPower_ idlePower_ \
topoInstance_ level1_ level2_ inerrProc_ outerrProc_ FECProc_

Simulator instproc create-wireless-node args {
# Add main node interface
$node add-interface $chan2 $propInstance_ $llType_ $macType_ \
$ifqType_ $ifqlen_ $phyType_ $antType_ \
$inerrProc_ $outerrProc_ $FECProc_

$node add-interface $chan3 $propInstance_ $llType_ $macType_ \
$ifqType_ $ifqlen_ $phyType_ $antType_ \
$inerrProc_ $outerrProc_ $FECProc_

$node add-interface $chan4 $propInstance_ $llType_ $macType_ \
$ifqType_ $ifqlen_ $phyType_ $antType_ \
$inerrProc_ $outerrProc_ $FECProc_

..
###END ###

Then in routing protocol, create coresponding downtarget for each interface to send out packet like:
NsObject *downtarget1_; // my port dmux
NsObject *downtarget2_; // my port dmux


When routing agent receive a packet, sends out packet to the according downtarget due to the channel assignment.

Finally, in the running script, configure each node with multiple interface and channel-assign-to-interface:

#Creating Channel
set chan_0_ [new $val(chan)]
set chan_1_ [new $val(chan)]
set chan_2_ [new $val(chan)]
set chan_3_ [new $val(chan)]
set chan_4_ [new $val(chan)]
...


$ns_ node-config -channel $chan_3_\
-channel2 $chan_11_\
-channel3 $chan_12_\
-channel4 $chan_12_\
-channel5 $chan_12_


tcl/lib/ns-mobilenode.tcl: set up multi-channel for routing agent

Node/MobileNode instproc add-target-rtagent { agent port } {
$self instvar imep_ toraDebug_

set ns [Simulator instance]
set newapi [$ns imep-support]
set namfp [$ns get-nam-traceall]

set dmux_ [$self demux]
set classifier_ [$self entry]

# let the routing agent know about the port dmux
$agent port-dmux $dmux_

if { [Simulator set RouterTrace_] == "ON" } {
#
# Send Target
#
if {$newapi != ""} {
#WHQ IMWN: multi-channel support
#set sndT [$self mobility-trace Send "RTR"]
set sndT1 [$self mobility-trace Send "RTR"]
set sndT2 [$self mobility-trace Send "RTR"]
set sndT3 [$self mobility-trace Send "RTR"]
set sndT4 [$self mobility-trace Send "RTR"]
set sndT5 [$self mobility-trace Send "RTR"]
#WHQ IMWN: multi-channel support

} else {
#WHQ IMWN: multi-channel support
#set sndT [cmu-trace Send "RTR" $self]
set sndT1 [cmu-trace Send "RTR" $self]
set sndT2 [cmu-trace Send "RTR" $self]
set sndT3 [cmu-trace Send "RTR" $self]
set sndT4 [cmu-trace Send "RTR" $self]
set sndT5 [cmu-trace Send "RTR" $self
#WHQ IMWN: multi-channel support

}
if { $namfp != "" } {
#WHQ IMWN: multi-channel support
#$sndT namattach $namfp
$sndT1 namattach $namfp
$sndT2 namattach $namfp
$sndT3 namattach $namfp
$sndT4 namattach $namfp
$sndT5 namattach $namfp
#WHQ IMWN: multi-channel support

}
if { $newapi == "ON" } {
$agent target $imep_(0)
$imep_(0) sendtarget $sndT
# second tracer to see the actual
# types of tora packets before imep packs them
if { [info exists toraDebug_] && $toraDebug_ == "ON"} {
set sndT2 [$self mobility-trace Send "TRP"]
$sndT2 target $imep_(0)
$agent target $sndT2
}
} else { ;# no IMEP
#WHQ IMWN: multi-channel support
#$agent target $sndT
$agent down-target-1 $sndT1
$agent down-target-2 $sndT2
$agent down-target-3 $sndT3
$agent down-target-4 $sndT4
$agent down-target-5 $sndT5
#WHQ IMWN: multi-channel support

}
#WHQ IMWN: multi-channel support
#$sndT target [$self set ll_(0)]
$sndT1 target [$self set ll_(0)]
$sndT2 target [$self set ll_(1)]
$sndT3 target [$self set ll_(2)]
$sndT4 target [$self set ll_(3)]
$sndT5 target [$self set ll_(4)]
#WHQ IMWN: multi-channel support

#
# Recv Target
#
if {$newapi != ""} {
set rcvT [$self mobility-trace Recv "RTR"]
} else {
set rcvT [cmu-trace Recv "RTR" $self]
}
if { $namfp != "" } {
$rcvT namattach $namfp
}
if {$newapi == "ON" } {
[$self set ll_(0)] up-target $imep_(0)
$classifier_ defaulttarget $agent
# need a second tracer to see the actual
# types of tora packets after imep unpacks them
# no need to support any hier node
if {[info exists toraDebug_] && $toraDebug_ == "ON" } {
set rcvT2 [$self mobility-trace Recv "TRP"]
$rcvT2 target $agent
$classifier_ defaulttarget $rcvT2
}
} else {
$rcvT target $agent
$classifier_ defaulttarget $rcvT
$dmux_ install $port $rcvT
}
} else {
#
# Send Target
#
# if tora is used
if { $newapi == "ON" } {
$agent target $imep_(0)
# second tracer to see the actual
# types of tora packets before imep packs them
if { [info exists toraDebug_] && $toraDebug_ == "ON"} {
set sndT2 [$self mobility-trace Send "TRP"]
$sndT2 target $imep_(0)
$agent target $sndT2
}
$imep_(0) sendtarget [$self set ll_(0)]

} else { ;# no IMEP
#WHQ IMWN: multi-channel support
#$agent target [$self set ll_(0)]
puts "Adding 5 targets to routing agent!\n"
$agent down-target-1 [$self set ll_(0)]
$agent down-target-2 [$self set ll_(1)]
$agent down-target-3 [$self set ll_(2)]
$agent down-target-4 [$self set ll_(3)]
$agent down-target-5 [$self set ll_(4)]
#WHQ IMWN: multi-channel support

}
#
# Recv Target
#
if {$newapi == "ON" } {
[$self set ll_(0)] up-target $imep_(0)
$classifier_ defaulttarget $agent
# need a second tracer to see the actual
# types of tora packets after imep unpacks them
# no need to support any hier node
if {[info exists toraDebug_] && $toraDebug_ == "ON" } {
set rcvT2 [$self mobility-trace Recv "TRP"]
$rcvT2 target $agent
[$self set classifier_] defaulttarget $rcvT2
}
} else {
$classifier_ defaulttarget $agent
$dmux_ install $port $agent
}
}
}


阅读(1631) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~