FSR Moblie AdHoc NS2

时间:2018-04-25 05:03:57

标签: ns2

我是来自印度尼西亚的学生,我是NS 2的新人。

我想使用NS 2.35在Mobile Adhoc中模拟FSR,但是我遇到了一些错误,我不知道该问谁。我只是从互联网上关注一些tcl示例。

这是我的tcl

# Define options
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_15_4               ;# MAC type
set val(ifq)            Queue/DropTail/PriQueue    ;# 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(nn)             10                         ;# number of mobilenodes
set val(rp)             FSR                        ;# routing protocol
set val(x)              1000                       ;# X dimension of topography
set val(y)              1000                       ;# Y dimension of topography  
set val(stop)           1000                       ;# time of simulation end

#inisiasi simulasi
set ns_           [new Simulator]

#set file trace
set tracefd       [open tesfisheye.tr w]
$ns_ trace-all $tracefd

#set file nam
set namtrace      [open tesfisheye.nam w]    
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
#set windowVsTime2 [open win.tr w] 

# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

# create God
set god_ [create-god $val(nn)]

# configure mobile nodes

$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) \
         -channelType $val(chan) \
         -topoInstance $topo \
         -wiredRouting OFF \
         -agentTrace ON \
         -routerTrace ON \
         -macTrace OFF

for {set i 0} {$i < $val(nn)} {incr i} {
    set node_($i) [$ns_ node]
    $node_($i) random-motion 1

}


# define initial node position in nam
$node_(0) set X_ 251.0
$node_(0) set Y_ 200.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 231.0
$node_(1) set Y_ 285.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 231.0
$node_(2) set Y_ 245.0
$node_(2) set Z_ 0.0
$node_(3) set X_ 254.0
$node_(3) set Y_ 235.0
$node_(3) set Z_ 0.0
$node_(4) set X_ 243.0
$node_(4) set Y_ 203.0
$node_(4) set Z_ 0.0
$node_(5) set X_ 282.0
$node_(5) set Y_ 303.0
$node_(5) set Z_ 0.0
$node_(6) set X_ 323.0
$node_(6) set Y_ 394.0
$node_(6) set Z_ 0.0
$node_(7) set X_ 243.0
$node_(7) set Y_ 293.0
$node_(7) set Z_ 0.0
$node_(8) set X_ 212.0
$node_(8) set Y_ 213.0
$node_(8) set Z_ 0.0
$node_(9) set X_ 229.0
$node_(9) set Y_ 242.0
$node_(9) set Z_ 0.0

for {set i 0} {$i < $val(nn)} {incr i} {
    $ns_ initial_node_pos $node_($i) 10
}

set tcp [new Agent/TCP]
$tcp set window_ 2000
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(1) $sink
$ns_ connect $tcp $sink 
set ftp [new Application/FTP]
$ftp set packetSize_ 20     
$ftp set rate_ 124 Kb       ;# sending rate
$ftp attach-agent $tcp 
$ns_ at 1.0 "$ftp start"
$ns_ at 1500 "$ftp stop"

set tcp1 [new Agent/TCP]
$tcp1 set window_ 2000
set sink1 [new Agent/TCPSink]
$ns_ attach-agent $node_(2) $tcp1
$ns_ attach-agent $node_(3) $sink1
$ns_ connect $tcp1 $sink1 
set ftp1 [new Application/FTP]
$ftp1 set packetSize_ 20    
$ftp1 set rate_ 124 Kb      
$ftp1 attach-agent $tcp1 
$ns_ at 1.0 "$ftp1 start"
$ns_ at 1500 "$ftp1 stop"

set tcp2 [new Agent/TCP]
$tcp2 set window_ 2000
set sink2 [new Agent/TCPSink]
$ns_ attach-agent $node_(5) $tcp2
$ns_ attach-agent $node_(4) $sink2
$ns_ connect $tcp2 $sink2 
set ftp2 [new Application/FTP]
$ftp2 set packetSize_ 20
$ftp2 set rate_ 124 Kb      
$ftp2 attach-agent $tcp2 
$ns_ at 1.0 "$ftp2 start"
$ns_ at 1500 "$ftp2 stop"

set tcp3 [new Agent/TCP]
$tcp3 set window_ 2000
set sink3 [new Agent/TCPSink]
$ns_ attach-agent $node_(2) $tcp3
$ns_ attach-agent $node_(0) $sink3
$ns_ connect $tcp3 $sink3 
set ftp3 [new Application/FTP]
$ftp3 set packetSize_ 20
$ftp3 set rate_ 124 Kb      
$ftp3 attach-agent $tcp3 
$ns_ at 1.0 "$ftp3 start"
$ns_ at 1500 "$ftp3 stop"

set tcp4 [new Agent/TCP]
$tcp4 set window_ 2000
set sink4 [new Agent/TCPSink]
$ns_ attach-agent $node_(6) $tcp4
$ns_ attach-agent $node_(7) $sink4
$ns_ connect $tcp4 $sink4 
set ftp4 [new Application/FTP]
$ftp4 set packetSize_ 20    
$ftp4 set rate_ 124 Kb      
$ftp4 attach-agent $tcp4 
$ns_ at 1.0 "$ftp4 start"
$ns_ at 1500 "$ftp4 stop"

set tcp5 [new Agent/TCP]
$tcp5 set window_ 2000
set sink5 [new Agent/TCPSink]
$ns_ attach-agent $node_(7) $tcp5
$ns_ attach-agent $node_(8) $sink5
$ns_ connect $tcp5 $sink5 
set ftp5 [new Application/FTP]
$ftp5 set packetSize_ 20    
$ftp5 set rate_ 124 Kb  
$ftp5 attach-agent $tcp5 
$ns_ at 1.0 "$ftp5 start"
$ns_ at 1500 "$ftp5 stop"

set tcp6 [new Agent/TCP]
$tcp6 set window_ 2000
set sink6 [new Agent/TCPSink]
$ns_ attach-agent $node_(9) $tcp6
$ns_ attach-agent $node_(6) $sink6
$ns_ connect $tcp6 $sink6 
set ftp6 [new Application/FTP]
$ftp6 set packetSize_ 20    
$ftp6 set rate_ 124 Kb      
$ftp6 attach-agent $tcp6 
$ns_ at 1.0 "$ftp6 start"
$ns_ at 1500 "$ftp6 stop"

set tcp7 [new Agent/TCP]
$tcp7 set window_ 2000
set sink7 [new Agent/TCPSink]
$ns_ attach-agent $node_(1) $tcp7
$ns_ attach-agent $node_(7) $sink7
$ns_ connect $tcp7 $sink7 
set ftp7 [new Application/FTP]
$ftp7 set packetSize_ 20    
$ftp7 set rate_ 124 Kb      
$ftp7 attach-agent $tcp7 
$ns_ at 1.0 "$ftp7 start"
$ns_ at 1500 "$ftp7 stop"


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

$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop).0001 "stop"
$ns_ at $val(stop).0002 "puts \"NS EXITING------------\" ; $ns_ halt"

proc stop {} {
    global ns_ tracefd namtrace
    $ns_ flush-trace
    close $tracefd
    close $namtrace
}

# begin simulation
puts "Starting Simulation..."
$ns_ run

然后这是输出

警告:请使用-channel,如tcl / ex / wireless-mitf.tcl所示 分段错误(核心转储)

帮我修复模拟。 我在Ubuntu 16.04 x64上 谢谢。

抱歉英语不好。

0 个答案:

没有答案