*Hi all, *
According to your question, this is my all script, so please can you go
through and comment  me ?

With regards,
Raol.

 # ======================================================================
 # Define options
 #======================================================================
 #set opt(namfile)         out.nam
 #set opt(tracefile)       out.tr
 set val(chan)             Channel/WirelessChannel        ;# channel type
 set val(prop)             Propagation/TwoRayGround       ;#
radio-propagation model
 set val(netif)            Phy/WirelessPhy                ;# network
interface type
 set val(mac)              Mac/802_11                     ;# MAC type
 set val(ifq)              CMUPriQueue                    ;# interface queue
type
 set val(ll)               LL                             ;# link layer type
 set val(ant)              Antenna/OmniAntenna            ;# antenna model
 set val(ifqlen)           50                             ;# max packet in
ifq
 set val(wirelessRouters)  8                            ;# number of fixed &
mobilenodes
 set val(wirelessNodes)    5                             ;# number of mobile
nodes
 set val(wiredNode)        1                              ;# number of wired
nodes
 set val(gatewayNode)      1                              ;# number of
gateway nodes
 set val(rp)               DSR                            ;# routing
protocol
 set val(x)                1050                           ;# X dimension of
topography
 set val(y)                750                            ;# Y dimension of
topography
 set val(stop)             20                             ;# time of
simulation end
 set val(start)            0.01                            ;# Warm-Up
 set val(sizePacket)       512                            ;# Size of TCP
packet
 # ======================================================================
 #Configuration for Orinoco 802.11b 11Mbps PC card with ->160m range
  #======================================================================
 Phy/WirelessPhy set Pt_ 0.031622777
 Phy/WirelessPhy set bandwidth_ 11Mb
 Mac/802_11 set dataRate_ 11Mb
 Mac/802_11 set basicRate_ 1Mb
 Phy/WirelessPhy set freq_ 2.472e9
 Phy/WirelessPhy set CPThresh_ 10.0
 Phy/WirelessPhy set CSThresh_ 5.011872e-12
 Phy/WirelessPhy set L_ 1.0
 Phy/WirelessPhy set RXThresh_ 1.15126e-10     ;# 160m range
 # ======================================================================
 # Main Program
 #======================================================================


 # Initialize Global Variables
 #
 set ns_ [new Simulator]
 $ns_ color 0 Brown

 set tracefile [open dsr-out.tr w]
 set namtrace [open dsr-out.nam w]
 #
 $ns_ trace-all $tracefile
 $ns_ namtrace-all-wireless $namtrace $val(x) $val(y)


 # Define The Hierachial Topology Structure

$ns_ node-config -addressType hierarchical      # Number of domains

AddrParams set domain_num_ 2

#=========================================================================

# Assign clusters (sub domains) in each domain

lappend clusterNbr 2 1
AddrParams set cluster_num_ $clusterNbr

#=========================================================================

#Assign mobile nodes in each cluster

lappend eilastlevel 1 1 8
AddrParams set nodes_num_ $eilastlevel

#========================================================================

 # Set up topography object
 #
 set topo       [new Topography]
 $topo load_flatgrid $val(x) $val(y)
 #
 # Create God
 #
 create-god [expr $val(wirelessRouters)+$val(gatewayNode)+$val(wiredNode)]
 #
 # configure node

         $ns_ node-config -adhocRouting $val(rp) \
                                     -llType $val(ll) \
                                     -macType $val(mac) \
                                     -ifqType $val(ifq) \
                                     -ifqLen $val(ifqlen) \
                                     -antType $val(ant) \
                                     -propType $val(prop) \
                                     -phyType $val(netif) \
                                     -channel [new $val(chan)] \
                                     -topoInstance $topo \
                                     -agentTrace ON \
                                     -routerTrace ON \
                                     -macTrace ON \
                                     -movementTrace OFF



             for {set i 2} {$i < $val(wirelessRouters)+2} {incr i} {
                         set node_($i) [$ns_ node]
                         $node_($i) random-motion 0              ;# disable
random motion
             }

#===================================================================
#create wired nodes

set temp {0.0.0}
for {set i 0} {$i < $val(wiredNode)} {incr i} {
    set wired_node_($i) [$ns_ node [lindex $temp $i]]
}

$wired_node_(0) set X_ 525.0
$wired_node_(0) set Y_ 425.0
$wired_node_(0) set Z_ 0.0

$wired_node_(0) color blue

$ns_ at 0.0 "$wired_node_(0) label \"WIRED_Node_0\""

#====================================================================
 #configure for gateways

$ns_ node-config -wiredRouting ON

#=====================================================================

#create gateway
#=====================================================================

# Create fixed & mobile nodes in the GW domain

set temp {1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9}
for {set i 2} {$i < $val(wirelessRouters) + 2} {incr i} {
    set ROUTER_($i) [$ns_ node [lindex $temp [expr $i-2]]]
    $ROUTER_($i) base station [AddrParams addr2id [$BS_(0) node-addr]]
}

set BS_(0) [$ns_ node 1.0.0]
$BS_(0) random-motion 0                    ;# disable random motion

$BS_(0) set X_ 525.0
$BS_(0) set Y_ 375.0
$BS_(0) set Z_ 0.0

$BS_(0) color red

$ns_ at 0.0 "$BS_(0) label GATE_WAY"

#=====================================================================

#configure for Fixed & mobile nodes

$ns_ node-config -wiredRouting OFF


#====================================================================


$ROUTER_(2) set X_ 0.0
$ROUTER_(2) set Y_ 0.0
$ROUTER_(2) set Z_ 0.0

$ROUTER_(3) set X_ 450.0
$ROUTER_(3) set Y_ 0.0
$ROUTER_(3) set Z_ 0.0

$ROUTER_(4) set X_ 0.0
$ROUTER_(4) set Y_ 150.0
$ROUTER_(4) set Z_ 0.0

$ROUTER_(5) set X_ 600.0
$ROUTER_(5) set Y_ 150.0
$ROUTER_(5) set Z_ 0.0


$ROUTER_(6) set X_ 150.0
$ROUTER_(6) set Y_ 300.0
$ROUTER_(6) set Z_ 0.0

$ROUTER_(7) set X_ 300.0
$ROUTER_(7) set Y_ 300.0
$ROUTER_(7) set Z_ 0.0


$ROUTER_(8) set X_ 375.0
$ROUTER_(8) set Y_ 75.0
$ROUTER_(8) set Z_ 0.0

$ROUTER_(9) set X_ 75.0
$ROUTER_(9) set Y_ 200.0
$ROUTER_(9) set Z_ 0.0



 #==================================================================
# Label fixed routers

for {set i 2} {$i < $val(wirelessRouters)-2} {incr i} {
    $ns_ at 0.0 "$ROUTER_($i) label \"GateWay $i\""
}


for {set i 2} {$i < $val(wirelessRouters)-2} {incr i} {
    $ns_ at 0.0 "$ROUTER_($i) label \"WMR $i\""
}

# Label mobile nodes

for {set i 7} {$i < $val(wirelessRouters)+2} {incr i} {
    $ns_ at 0.0 "$ROUTER_($i) label \"MobileMesh $i\""
}

#==================================================================


# configure mobile nodes for movement

$ns_ at 0.0 "$ROUTER_(7) setdest 225.0 525.0 30.0"
$ns_ at 0.0 "$ROUTER_(8) setdest 580.0 320.0 30.0"
$ns_ at 0.0 "$ROUTER_(9) setdest 225.0 225.0 30.0"


#==================================================================

# Screen out nodes positions on screen

puts ""
puts "host0 = [$wired_node_(0) node-addr] = [AddrParams addr2id
[$wired_node_(0) node-addr]]"
#puts "host1 = [$wired_node(1) node-addr] = [AddrParams addr2id
[$wired_node(1) node-addr]]"
puts "$BS_(1) = [$BS_(0) node-addr] = [AddrParams addr2id [$BS_(0)
node-addr]]"
for {set i 2} {$i < $opt(wirelessRouters)+2} {incr i} {
    puts "ROUTER_($i) = [$ROUTER_($i) node-addr] = [AddrParams addr2id
[$ROUTER_($i) node-addr]]"
}
puts ""

#==================================================================

#create link between wired node and basestation node

$ns_ duplex-link $wired_node_(0) $BS_(0) 5Mb 20ms DropTail

$ns_ duplex-link-op $wired_node_(0) $BS_(0) orient down


 #================================================================
 # setup for TCP Traffic

set src [new Agent/TCP]
$src set class_ 2
$src set window_ 100
$src set packetSize_ $val(sizePacket)
Agent/TCPSink set interval_ 100ms
set dst [new Agent/TCPSink]
$ns_ attach-agent $BS_(0) $src
$ns_ attach-agent $ROUTER_(7) $dst
$src set fid_ 0
$ns_ connect $src $dst

set ftp [new Application/FTP]
$ftp attach-agent $src
$ns_ at 0.0 "$ftp start"
$ns_ at 21.01 "stop"
$ns_ at $val(stop) "$ftp stop"

set src [new Agent/TCP]
$src set class_ 2
$src set window_ 100
$src set packetSize_ $val(sizePacket)
Agent/TCPSink set interval_ 100ms
set dst [new Agent/TCPSink]
$ns_ attach-agent $BS_(0) $src
$ns_ attach-agent $ROUTER_(8) $dst
$src set fid_ 1
$ns_ connect $src $dst

set ftp [new Application/FTP]
$ftp attach-agent $src
$ns_ at 0.0 "$ftp start"
$ns_ at 21.01 "stop"
$ns_ at $val(stop) "$ftp stop"


set src [new Agent/TCP]
$src set class_ 2
$src set window_ 100
$src set packetSize_ $val(sizePacket)
Agent/TCPSink set interval_ 100ms
set dst [new Agent/TCPSink]
$ns_ attach-agent $BS_(0) $src
$ns_ attach-agent $ROUTER_(9) $dst
$src set fid_ 2
$ns_ connect $src $dst

set ftp [new Application/FTP]
$ftp attach-agent $src
$ns_ at 0.0 "$ftp start"
$ns_ at 21.01 "stop"
$ns_ at $val(stop) "$ftp stop"


#================================================================

  #
 # Define node initial position in NAM
 #
 for {set i 2} {$i < $val(wirelessRouters)+2} {incr i} {
             $ns_ initial_node_pos $ROUTER_($i) 30
 }
 #
 # Telling nodes when the simulation ends
 #
 for {set i 2} {$i < $val(wirelessRouters)+2} {incr i} {
     $ns_ at $val(stop) "$ROUTER_($i) reset";
 }
 #
 # Ending NAM and the Simulation
 #
 $ns_ at $val(stop).0 "$BS_(0) reset";
 $ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
 $ns_ at $val(stop) "stop"
 $ns_ at 21.01 "puts \"End Simulation\"; $ns_ halt";
 #
 proc stop {} {
             global ns_ tracefile namtrace tcp
             $ns_  flush-trace
             close $tracefile
             close $namtrace
         exec nam dsr-out.nam &
             exit 0
 }

puts "Starting simulation..."
$ns_ at 0.0 "$ns_ set-animation-rate 5ms"


 $ns_ run


#====================================================================
 This is the error I get !

$ num_nodes is set 10
Error!!
str2addr:Address 1628668875 outside range of address field length 2048

#====================================================================

Reply via email to