[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Broadcast in Wired network?
Does ns2 routing moduleod Wired network support IP_BROADCAST?
I tried to do broadcast in c++ code of mobsecagent (derive from agent
class)
as following:
{
...
iph->daddr() = IP_BROADCAST
iph->ttl() = 1;
target_->recv(p, (Handler*) 0);
...
}
but I get the following error message when I run a tcl file for Wired
network and 'ns' aborts
_o11: no target for slot -1
---------------------------
I'm not sure if my c++ code or tcl file is wrong? Can I use node-config
command for wired node?
I attach my tcl file as following:
---
set ns_ [new Simulator]
#
# Load the scenario file and parameters file
#
set val(chan) Channel
set val(netif) Phy/WiredPhy
set val(mac) Mac/Csma/Cd
set val(ifq) Queue/DropTail
set val(ll) LL
set val(ifqlen) 50
source $val(pr)
#
# Predefine tracing
#
set log_ [open "ziyue.log" w]
$ns_ trace-all $log_
#
# Create channel
#
puts "create channel"
set chan_1 [new $val(chan)]
puts "finish create channel"
#
# Configure node
#
#$ns_ node-config -llType $val(ll) \
# -macType $val(mac) \
# -ifqType $val(ifq) \
# -ifqLen $val(ifqlen) \
# -phyType $val(netif) \
# -channelType $val(chan) \
# -agentTrace OFF \
# -routerTrace OFF \
# -macTrace OFF \
# -channel $chan_1
#
# Define the port the agent will listen to
#
set secport 100
#
# Create some nodes
#
puts "create nodes"
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
}
puts "finish create nodes"
$ns_ rtproto Static
$ns_ make-lan "\
$node_(0) $node_(1) $node_(2) $node_(3) $node_(4)\
$node_(5) $node_(6) $node_(7) $node_(8) $node_(9)\
$node_(10) $node_(11) $node_(12) $node_(13) $node_(14)\
$node_(15) $node_(16) $node_(17) $node_(18) $node_(19)\
$node_(20) $node_(21) $node_(22) $node_(23) $node_(24)\
$node_(25) $node_(26) $node_(27) $node_(29) $node_(29)\
$node_(30) $node_(31) $node_(32) $node_(33) $node_(34)\
$node_(35) $node_(36) $node_(37) $node_(38) $node_(39)\
$node_(40) $node_(41) $node_(42) $node_(43) $node_(44)\
$node_(45) $node_(46) $node_(47) $node_(48) $node_(49)"\
5Mb 2ms $val(ll) $val(ifq) $val(mac)
#
#
# Create some links
#
#puts "create links"
#for {set i 0} {$i < $val(nn) } {incr i} {
# for {set j [expr $i+1]} {$j < $val(nn) } {incr j} {
# $ns_ duplex-link $node_($i) $node_($j) 5Mb 2ms DropTail
# }
#}
#puts "finish create links"
#
# Create some agents
#
...
ns_ run
Sophia