Hi, everyone!

I am doing a job to simulate a scenario with 2 BS, 2 mobile nodes each
in one BS's domain respectively, and the 2 BS connected with a wired
node. I describe it below: D-----A-B-C-----E, DE are two mobile nodes,
AC are two Base-stations and B is the wired node. I need to build 3 TCP
links: D->A, D->B, D->E. 

As in my script, I find D->A, D->B is normal while there is no TCP
connection between D and E through D->A->B->C->E. Could anyone can help
me on this? 

Thanks in advance!

================================

My script is below:

# node(0)-----BS(0)-W(0)-BS(1)-----node(1)

# =====================================================================
# Define options
# =====================================================================
set opt(chan)                   Channel/WirelessChannel
set opt(prop)                   Propagation/TwoRayGround
set opt(netif)                  Phy/WirelessPhy
set opt(mac)                    Mac/802_11
set opt(ant)                    Antenna/OmniAntenna
set opt(ifq)                    Queue/DropTail/PriQueue
set opt(ll)                             LL
set opt(ifqlen)                 50
set opt(nn)                             4       ;# nodes num
set opt(adhocRouting)   AODV

set opt(cp)             ""
set opt(sc)             ""

set opt(x)              670
set opt(y)              670
set opt(seed)   0.0
set opt(stop)   15.0

set opt(ftp0-start)     2.0     ;# D->A
set opt(ftp1-start)     5.0             ;# D->B
set opt(ftp2-start)     8.0             ;# D->E
set opt(ftp3-start) 2.0         ;# E->B

set num_wired_nodes     1
set num_bs_nodes        2

# ======================================================================
# check boundary para & random seed
if {$opt(x) == 0 || $opt(y) == 0} {
        puts "Out!!"
}
if {$opt(seed) > 0} {
        puts "new seed: $opt(seed)\n"
        ns-random $opt(seed)
}

# Create simulator instance
set ns_ [new Simulator]

# Setup for hier routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 3
lappend cluster_num 1 1 1
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 2 2 1
AddrParams set nodes_num_ $eilastlevel

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

# Create topo. obj.
set topo [new Topography]

# Define topo.
$topo load_flatgrid $opt(x) $opt(y)

# Create God.
create-god $opt(nn)

set tmp {0.0.0 1.0.0 1.0.1 2.0.0 2.0.1}

# Create wired node.
set W(0) [$ns_ node [lindex $tmp 0]]

# Configure BS 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 ON \
                                 -macTrace OFF


# Create BS node.
set BS(0) [$ns_ node [lindex $tmp 1]]
$BS(0) random-motion 0
$BS(0) set X_ 1.0
$BS(0) set Y_ 2.0
$BS(0) set Z_ 0.0

set BS(1) [$ns_ node [lindex $tmp 3]]
$BS(1) random-motion 0
$BS(1) set X_ 650.0
$BS(1) set Y_ 600.0
$BS(1) set Z_ 0.0

# Configure mobilenodes
$ns_ node-config -wiredRouting OFF

# Create mobilenodes
set node(0) [$ns_ node [lindex $tmp 2]]
$node(0) base-station [AddrParams addr2id [$BS(0) node-addr]]

set node(1) [$ns_ node [lindex $tmp 4]]
$node(1) base-station [AddrParams addr2id [$BS(1) node-addr]]

$node(0) set X_ 0.0
$node(0) set Y_ 0.0
$node(0) set Z_ 0.0

$node(1) set X_ 600.0
$node(1) set Y_ 10.0
$node(1) set Z_ 0.0

# Create links
$ns_ duplex-link $BS(0) $W(0) 5Mb 2ms DropTail
$ns_ duplex-link $W(0) $BS(1) 5Mb 2ms DropTail

# Setup TCP connections
set tcp0 [new Agent/TCP]        ;# D->A
$tcp0 set class_ 2
set sink0 [new Agent/TCPSink]
$ns_ attach-agent $node(0) $tcp0
$ns_ attach-agent $BS(0) $sink0
$ns_ connect $tcp0 $sink0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns_ at opt(ftp0-start) "$ftp0 start"

set tcp1 [new Agent/TCP]        ;# D->B
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns_ attach-agent $node(0) $tcp1
$ns_ attach-agent $W(0) $sink1
$ns_ connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns_ at opt(ftp1-start) "$ftp1 start"

set tcp2 [new Agent/TCP]        ;# D->E
$tcp2 set class_ 2
set sink2 [new Agent/TCPSink]
$ns_ attach-agent $node(0) $tcp2
$ns_ attach-agent $node(1) $sink2
$ns_ connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ns_ at opt(ftp2-start) "$ftp2 start"

for {set i 0} {$i < 2} {incr i} {
    $ns_ initial_node_pos $node($i) 20
}

for {set i 0} {$i < 2} {incr i} {
        $ns_ at $opt(stop).00010 "$node($i) reset"
        $ns_ at $opt(stop).00010 "$BS($i) reset"
}

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

proc stop {} {
        global ns_ tracefd namtrace
        $ns_ flush-trace
        close $tracefd
        close $namtrace
        exec nam scenario_0.nam &
        #exec xgraph scenario_0.tr -geometry 800x400 &
        exit 0
}

puts "Running..."
$ns_ run

=================================

Kindly regards,

Jilong LIAO

Reply via email to