2008-11-05 8 views
2

무선 링크가있는 ns2에서 오류 모델을 사용하려고하는데 ns2.33을 사용하고 있습니다. 나는 균일 한 오차 모델과 마크로프 체인 모델을 시도했다. ns에서 오류는 없지만 손상된 패킷을 찾을 때 유니폼 또는 마르코프 모델을 사용하여 찾을 수 없습니다. 오류 모델을 사용할 때 오류가 발생하면 도와주십시오. 무선 시나리오에서 오류 모델을 사용하는 패킷을 드롭하지 않습니까?

내가

을 사용하고 손실 된 패킷을 검색

이드 @ 이드 - 노트북 : ~/코드/NS2/소음 $ 고양이 mixed.tr | 그렙 D

여기

는 전체 코드입니다 :

### This simulation is an example of combination of wired and wireless 
### topologies. 
#------------------------------------------------------------------------------- 
#defining a new hashtable to store values 
global opt 
set adhocRouting DSDV 
set stop   350 
set num_wired_nodes  1 
set num_bs_nodes   1 
set num_wireless_nodes    2 
set x 300 
set y 300 
#------------------------------------------------------------------------------- 

proc plotWindow { tcpSource file } { 
global ns_ 
set time 0.1 
set now [$ns_ now] 
set cwnd [$tcpSource set cwnd_] 
set wnd [$tcpSource set window_] 
puts $file "$now $cwnd" 
$ns_ at [expr $now+$time] "plotWindow $tcpSource $file" 
} 

proc wireless_node_config {ns topo em} { 
    $ns node-config -adhocRouting DSDV \ 
       -llType LL \ 
       -macType Mac/802_11 \ 
       -ifqType Queue/DropTail/PriQueue \ 
       -ifqLen 50 \ 
       -antType Antenna/OmniAntenna \ 
       -propInstance [new Propagation/TwoRayGround] \ 
       -phyType Phy/WirelessPhy \ 
       -channel [new Channel/WirelessChannel] \ 
       -topoInstance $topo \ 
       -wiredRouting ON \ 
       -agentTrace ON \ 
       -routerTrace OFF \ 
       -macTrace OFF \ 
@@     -outgoingErrProc $em 
@@     -incomingErrProc $em 

} 

proc nam {ns namFile trFile namOutFile} { 
    $ns flush-trace 
    close $namFile 
    close $trFile 
    puts "running nam..." 
# exec nam $namOutFile & 
    puts "I am in nam" 
} 
proc finish { } { 
    exit 0 
} 
#------------------------------------------------------------------------------- 
# The global simulator instance 
set ns_ [new Simulator] 
#------------------------------------------------------------------------------- 
#Hierarchical routing is needed to in mixed environments 
#each of wireless and wired environment must be in seperated domains 
#so at least we want 2 domains 

# set up for hierarchical routing 
$ns_ node-config -addressType hierarchical 
AddrParams set domain_num_ 2 
lappend cluster_num 1 2 
AddrParams set cluster_num_ $cluster_num 
lappend eilastlevel 1 1 2 
AddrParams set nodes_num_ $eilastlevel 
#------------------------------------------------------------------------------- 
#set the Topology 
set topo [new Topography] 
$topo load_flatgrid x y 

# god needs to know the number of all wireless interfaces 
create-god [expr $num_wireless_nodes+$num_wired_nodes] 
#------------------------------------------------------------------------------- 
#trace output file 
set trFile [open mixed.tr w] 
$ns_ trace-all $trFile 

# nam output files 
set namFile [open mixed.nam w] 
$ns_ namtrace-all $namFile 
$ns_ namtrace-all-wireless $namFile x y 

#xgraph output files 
set x0 [open xgraph0.tr w] 

#extra files 
set cwndFile [open cwndFile.wtc w] 
#------------------------------------------------------------------------------- 
#Define different colors for data flows (for NAM) 
$ns_ color 1 Blue 
$ns_ color 2 Red 
$ns_ color 3 Green 
#------------------------------------------------------------------------------- 
@@#creating the error model 
@@set m1_ubstate 27.0 
@@set m1_bstate 12.0 
@@set m2_ubstate 0.4 
@@set m2_bstate 0.4 
@@set durlist "$m1_ubstate $m1_bstate $m2_ubstate $m2_bstate" 
@@set errmodel [new ErrorModel/ComplexTwoStateMarkov $durlist time] 
@@$errmodel unit packet 
@@$errmodel drop-target [new Agent/Null] 

#the option below is for wired links, there is no links in wireless environment 

#$ns_ link-lossmodel $loss_module $BS(0) $node_(0) 
#------------------------------------------------------------------------------- 
#Creating the nodes 

    # The wired nodes 
set addresses {0.0.0 1.0.0 1.1.0 1.1.1} 
set W(0) [$ns_ node [lindex $addresses 0]] 
    #The wireless nodes 
wireless_node_config $ns_ $topo $errmodel 
set BS(0) [$ns_ node [lindex $addresses 1]] 


$ns_ node-config -wiredRouting OFF 
     #base stations nodes 
$BS(0) random-motion 0 

     #mobile nodes 
    for {set j 0} {$j < [expr $num_wired_nodes + $num_bs_nodes]} {incr j} { 
    set node_($j) [ $ns_ node [lindex $addresses [expr $j+2]] ] 
    #attach nodes to base station 
    $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]] 
    } 

# End Creating the Nodes 
#------------------------------------------------------------------------------- 
# Positioning the nodes 
    $BS(0) set X_ 50.0 
    $BS(0) set Y_ 50.0 
    $BS(0) set Z_ 0.0 
    $node_(0) set X_ 0.0 
    $node_(0) set Y_ 0.0 
    $node_(0) set Z_ 0.0 
    $node_(1) set X_ 100.0 
    $node_(1) set Y_ 0.0 
    $node_(1) set Z_ 0.0 
#------------------------------------------------------------------------------- 
#create links between wired and BS nodes 
$ns_ duplex-link $W(0) $BS(0) 2Mb 2ms DropTail down 
$ns_ duplex-link-op $W(0) $BS(0) orient down 
$ns_ queue-limit $W(0) $BS(0) 2020Mb 
#$ns_ duplex-link-op $W(0) $BS(0) queuePos 0.5 
#------------------------------------------------------------------------------- 

#Sizing the mobile nodes this will make them appear in NAM 
for {set i 0} {$i < $num_wireless_nodes} {incr i} { 
     $ns_ initial_node_pos $node_($i) 10 
    } 
#------------------------------------------------------------------------------- 
# setup TCP connections 
    set tcp1 [new Agent/TCP/Newreno] 
    $tcp1 set class_ 2 
    set sink1 [new Agent/TCPSink/DelAck] 
    $ns_ attach-agent $W(0) $tcp1 
    $ns_ attach-agent $node_(0) $sink1 
    $ns_ connect $tcp1 $sink1 
    set ftp1 [new Application/FTP] 
    $ftp1 attach-agent $tcp1 
#------------------------------------------------------------------------------- 
#time line scenario. 
$ns_ at 1.5 "$ftp1 start" 
$ns_ at [expr $stop-10] "$ftp1 stop" 

#reset nodes after finishing 
for {set i 0} {$i < $num_wireless_nodes } {incr i} { 
     $ns_ at $stop.000000 "$node_($i) reset"; 
    } 
$ns_ at $stop.000000 "$BS(0) reset"; 

puts "Starting Simulation..." 
$ns_ at 0.1 "plotWindow $tcp1 $cwndFile" 
$ns_ at $stop.1 "nam $ns_ $namFile $trFile mixed.nam" 
$ns_ at $stop.2 "finish" 
#------------------------------------------------------------------------------- 
$ns_ run 

또한 찾을 수 있습니다 동일한 코드 here

답변

-1

시도 :

grep d mixed.tr