Hi all! I got a segmentation fault when using Queue/DRR and AODV in wireless network. following is the message output by valgrind
==2252== Invalid read of size 4 ==2252== at 0x81BD274: PacketQueue::head() (queue.h:82) ==2252== by 0x829A1D6: PriQueue::filter(int) (priqueue.cc:158) ==2252== by 0x82C82FF: AODV::rt_ll_failed(Packet*) (aodv.cc:343) ==2252== by 0x82C8339: aodv_rt_failed_callback(Packet*, void*) (aodv.cc:293) ==2252== by 0x827A041: Mac802_11::RetransmitRTS() (mac-802_11.cc:1295) ==2252== by 0x827A4C4: Mac802_11::send_timer() (mac-802_11.cc:883) ==2252== by 0x827A530: Mac802_11::sendHandler() (mac-802_11.cc:793) ==2252== by 0x82A142D: TxTimer::handle(Event*) (mac-timers.cc:254) ==2252== by 0x81A7933: Scheduler::dispatch(Event*, double) (scheduler.cc:150) ==2252== by 0x81A7B85: Scheduler::run() (scheduler.cc:129) ==2252== by 0x81A7E44: Scheduler::command(int, char const* const*) (scheduler.cc:198) ==2252== by 0x83CCAFD: TclClass::dispatch_cmd(void*, Tcl_Interp*, int, char const**) (in /home/howardgod/ns2/ns-2.33/ns) ==2252== Address 0x1a is not stack'd, malloc'd or (recently) free' I think the problem is in AODV::rt_ll_failed(Packet*) and PriQueue::filter(int). And there was a similar problem posed http://mailman.isi.edu/pipermail/ns-users/2005-April/048686.html and there's a solution about this problem http://mailman.isi.edu/pipermail/ns-users/2005-April/048710.html but solution is aimed at adding a new routing protocol. So the solutions is not help for me. I'm making a new queue based on DRR. And use it in wireless network. So when I use Queue/MyQueue and AODV in TCL file, segmentation fault occurs. But I make the problem easier. I write the same tcl file except I use Queue/DRR. And I find out there's still a segmentation fault just as I use Queue/MyQueue. following is the TCL file # ========================================================= # 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(ifq) Queue/DRR set opt(ll) LL set opt(ant) Antenna/OmniAntenna set opt(ifqLen) 50 set opt(nn) 7 set opt(rp) AODV set opt(x) 1000 set opt(y) 1000 set opt(stop) 10 set opt(tran) 250 # ========================================================= # Create simulation object set ns [new Simulator] # Open trace file set tracefd [open drr-out.tr w] set namtrace [open drr-out.nam w] $ns trace-all $tracefd $ns namtrace-all-wireless $namtrace $opt(x) $opt(y) # Create topology object set topo [new Topography] # Define topology $topo load_flatgrid $opt(x) $opt(y) # Create God create-god $opt(nn) set chan [new $opt(chan)] # Congigure for node $ns node-config -adhocRouting $opt(rp) \ -llType $opt(ll) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqLen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -channel $chan \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF # ========================================================= # Node Definition # ========================================================= for {set i 0} {$i < 3} {incr i} { set wl_node_($i) [$ns node] $wl_node_($i) random-motion 0 puts "wireless node $i created ..." $wl_node_($i) set X_ [expr 200.0 + $i * 200.0] $wl_node_($i) set Y_ 400.0 $wl_node_($i) set Z_ 0.0 $ns initial_node_pos $wl_node_($i) 20 } for {set i 3} {$i < 5} {incr i} { set wl_node_($i) [$ns node] $wl_node_($i) random-motion 0 puts "wireless node $i created ..."; $wl_node_($i) set X_ 400.0 $wl_node_($i) set Y_ [expr 800.0 - ($i - 3)*200.0] $wl_node_($i) set Z_ 0.0 $ns initial_node_pos $wl_node_($i) 20 } for {set i 5} {$i < 7} {incr i} { set wl_node_($i) [$ns node] $wl_node_($i) random-motion 0 puts "wireless node $i created ..."; $wl_node_($i) set X_ 400.0 $wl_node_($i) set Y_ [expr 200.0 - ($i - 5)*200.0] $wl_node_($i) set Z_ 0.0 $ns initial_node_pos $wl_node_($i) 20 } # ========================================================= # Traffic Definition # ========================================================= set udp0 [new Agent/UDP] set dst_udp0 [new Agent/Null] $ns attach-agent $wl_node_(0) $udp0 $ns attach-agent $wl_node_(2) $dst_udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set rate_ 200Kb $cbr0 attach-agent $udp0 $ns connect $udp0 $dst_udp0 $ns at 0.0 "$cbr0 start" $ns at $opt(stop) "$cbr0 stop" set udp1 [new Agent/UDP] set des_udp1 [new Agent/Null] $ns attach-agent $wl_node_(4) $udp1 $ns attach-agent $wl_node_(5) $des_udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set rate_ 500Kb $cbr1 attach-agent $udp1 $ns connect $udp1 $des_udp1 $ns at 0.0 "$cbr1 start" $ns at $opt(stop) "$cbr1 stop" set udp2 [new Agent/UDP] set des_udp2 [new Agent/Null] $ns attach-agent $wl_node_(3) $udp2 $ns attach-agent $wl_node_(6) $des_udp2 set cbr2 [new Application/Traffic/CBR] $cbr2 set rate_ 500Kb $cbr2 attach-agent $udp2 $ns connect $udp2 $des_udp2 $ns at 0.0 "$cbr2 start" $ns at $opt(stop) "$cbr2 stop" # ========================================================= # Termination # ========================================================= proc finish {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace #exec nam normal.nam & exit 0 } $ns at $opt(stop) "$ns nam-end-wireless $opt(stop)" $ns at $opt(stop) "finish" $ns at $opt(stop) "puts \"done\" ; $ns halt" $ns run the tcl file is easy. I create 7 nodes.like this n3 | n4 | n0-----n1------n2 | n5 | n6 and there are three CBR traffics. n0 to n2, n3 to n6, and n4 to n5. And I using Queue/DRR and AODV. Is there any solution for this problem. Any advice will appreciate!! thanks. p.s I using ns2.33 Howard