Hello All,

I wrote a simple wired-wless scenario

Wired_node----Base_Station----Mobile_Node

but I keep receiving the message: "warning: Route to base_stn not known:
dropping pkt"

I searched for this and I could see this means the Base-Station cannot reach
the mobile node.

I treid many alternatives of position... But I could node solve the problem!

Here is my code.

I apreciate very much your help.

Bruno
____________________________________________________________________________

set opt(chan)           Channel/WirelessChannel    ;# channel type
set opt(prop)           Propagation/TwoRayGround   ;# radio-propagation
model
set opt(netif)          Phy/WirelessPhy            ;# network interface type
set opt(mac)            Mac/802_11                 ;# MAC type
set opt(ifq)            Queue/DropTail/PriQueue    ;# interface queue type
set opt(ll)             LL                         ;# link layer type
set opt(ant)            Antenna/OmniAntenna        ;# antenna model
set opt(ifqlen)         50                         ;# max packet in ifq
set opt(nn)             1                          ;# number of mobilenodes
set opt(adhocRouting)   DSDV                       ;# routing protocol

set opt(cp)             ""                         ;# connection pattern
file
set opt(sc)             ""                   ;# node movement file.

set opt(x)      600                            ;# x coordinate of topology
set opt(y)      600                            ;# y coordinate of topology
set opt(seed)   0.0                            ;# seed for random number
gen.
set opt(stop)   10                             ;# time to stop simulation

#set opt(ftp1-start)      0.1

set num_wired_nodes      1
set num_bs_nodes         1

#
============================================================================
# check for boundary parameters and random seed
if { $opt(x) == 0 || $opt(y) == 0 } {
    puts "No X-Y boundary values given for wireless topology\n"
}
if {$opt(seed) > 0} {
    puts "Seeding Random number generator with $opt(seed)\n"
    ns-random $opt(seed)
}

# create simulator instance
#remove-all-packet-headers
#add-packet-header IP TCP
set ns_ [new Simulator]

# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2                   ;# number of domains
lappend cluster_num 1 1                    ;# number of clusters in each
domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 2                      ;# number of nodes in each
cluster
AddrParams set nodes_num_ $eilastlevel         ;# of each domain

set tracefd  [open wireless2-out.tr w]
set namtrace [open wireless2-out.nam w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)

# Create topography object
set topo [new Topography]

# define topology
$topo load_flatgrid $opt(x) $opt(y)

# create God
create-god [expr $opt(nn) + $num_bs_nodes]

#create wired nodes
set temp {0.0.0}
set wired_node [$ns_ node [lindex $temp 0]]


# configure for base-station node
$ns_ node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop) \
                 -phyType $opt(netif) \
                 -channelType $opt(chan) \
         -topoInstance $topo \
                 -wiredRouting ON \
         -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF

set temp {1.0.0 1.0.1}
# create base-station node
set BS [$ns_ node [lindex $temp 0]]
;#DelayBox [lindex $temp 0]]
$BS random-motion 0                       ;# disable random motion

# provide some co-ord (fixed) to base station node
$BS set X_ 300.0
$BS set Y_ 200.0
$BS set Z_ 0.0

# create mobilenodes in the same domain as BS(0)
# note the position and movement of mobilenodes is as defined
# in $opt(sc)

# mobilenodes configuration
$ns_ node-config -wiredRouting OFF

set mob_node [ $ns_ node [lindex $temp 1]]
$mob_node base-station [AddrParams addr2id [$BS node-addr]]
$mob_node random-motion 0

$mob_node set X_ 300.0
$mob_node set Y_ 198.0
$mob_node set Z_ 0.0

#create links between wired and BS nodes
$ns_ duplex-link $wired_node $BS 5Mb 2ms DropTail

$ns_ duplex-link-op $wired_node $BS orient down


# setup TCP connections
set tcp1 [new Agent/TCP]
#$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
#$tcp1 fid_ 1
#$sink1 fid_ 1

$ns_ attach-agent $mob_node $tcp1
$ns_ attach-agent $wired_node $sink1
$ns_ connect $sink1 $tcp1

set exp [new Application/Traffic/Exponential]
$exp set packet_size_ 1000
$exp set burst_time_ 0.01
$exp set dle_time_ 0.01
$exp set rate 100kbps
$exp attach-agent $tcp1

$ns_ at 0.1 "$exp start"

#set ftp1 [new Application/FTP]
#$ftp1 attach-agent $tcp1
#$ns_ at $opt(ftp1-start) "$ftp1 start"

# create random variables

#global defaultRNG
#$defaultRNG seed 0

#set delay [new RandomVariable/Constant];    # delay ms
#$delay set val_ 20
#set bw [new RandomVariable/Constant];        # bw Mbps
#$bw set val_ 100
#set bw [new RandomVariable/Uniform];        # bw Mbps
#$bw set min_ 1
#$bw set max_ 20
#set loss_rate [new RandomVariable/Uniform];    # loss 0-1% loss
#$loss_rate set min_ 0
#$loss_rate set max_ 0.01

#$BS(0) add-rule [$n_src id] [$n_sink id] $recvr_delay $loss_rate $recvr_bw

# source connection-pattern and node-movement scripts
if { $opt(cp) == "" } {
    puts "*** NOTE: no connection pattern specified."
        set opt(cp) "none"
} else {
    puts "Loading connection pattern..."
    source $opt(cp)
}
if { $opt(sc) == "" } {
    puts "*** NOTE: no scenario file specified."
        set opt(sc) "none"
} else {
    puts "Loading scenario file..."
    source $opt(sc)
    puts "Load complete..."
}

# Define initial node position in nam

for {set i 0} {$i < $opt(nn)} {incr i} {

    # 20 defines the node size in nam, must adjust it according to your
scenario
    # The function must be called after mobility model is defined

    $ns_ initial_node_pos $mob_node 5
}

# Tell all nodes when the simulation ends
for {set i } {$i < $opt(nn) } {incr i} {
    $ns_ at $opt(stop).0 "$mob_node reset";
}

$ns_ at $opt(stop).0 "$BS reset";

$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"

proc stop {} {
    global ns_ tracefd namtrace
    $ns_ flush-trace
    close $tracefd
    close $namtrace
    exec nam wireless2-out.nam &
    exit 0
}

# informative headers for CMUTracefile
puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y) rp $opt(adhocRouting)"
puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)"
puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"

puts "Starting Simulation..."
$ns_ run

Reply via email to