NS2.35移动自组网FSR仿真出现Segmentation fault (core dumped)错误求助
Hey there! Let’s tackle that segmentation fault you’re hitting when trying to run your FSR protocol simulation in NS2.35. From what you’ve shared, I’ve got a few strong hunches about what’s going wrong, plus actionable steps to fix it.
First, the Likely Culprit: Incompatible MAC Layer
You’re using Mac/802_15_4 (Zigbee) with FSR, which is a routing protocol designed for traditional 802.11-based adhoc networks. NS2’s FSR implementation doesn’t play nicely with 802.15.4 out of the box—they have different frame structures, MAC logic, and layer interactions that can cause memory access errors (the segmentation fault you’re seeing).
Quick Fix: Switch to 802.11 MAC
Update your MAC configuration line to use the standard 802.11 MAC that’s compatible with FSR:
set val(mac) Mac/802_11 ;# Replace Mac/802_15_4 with this
Next, Verify Your Full Node Configuration
Make sure your node setup includes all required parameters for FSR to work. Here’s a complete example of node config that pairs well with FSR:
set val(rp) FSR ;# Explicitly set routing protocol to FSR set topo [new Topography] $topo load_flatgrid 500 500 ;# Define your simulation area (adjust size as needed) $ns node-config -adhocRouting $val(rp) \ -llType LL \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen 50 \ -antType Antenna/OmniAntenna \ -propType $val(prop) \ -phyType $val(netif) \ -channelType $val(chan) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF
Note: If you didn’t define the $topo topology object in your code, that’s another common cause of segmentation faults—NS2 needs a valid topology to place mobile nodes.
Additional Debugging Steps
If switching the MAC layer doesn’t fix the issue, try these:
- Trim down your code: Start with a minimal working FSR simulation (just a few nodes, basic movement) and build up from there. This helps isolate if the error comes from a specific part of your setup (like a broken mobility model or incorrect agent configuration).
- Check NS2 compilation: Ensure FSR was properly compiled with your NS2.35 setup. Navigate to
ns-allinone-2.35/ns-2.35/routing/fsr—you should see.ccand.hfiles here, and there should be no errors during the original NS2 installation. - Validate uncompleted code: Your snippet cuts off at
interface q...—make sure the rest of your queue configuration is complete (e.g., settingifqLencorrectly) and that all variables are properly initialized before use.
If you’re still stuck, sharing your full TCL code would help pinpoint the exact issue—even small missing lines can cause these memory errors in NS2.
内容的提问来源于stack exchange,提问作者Rizal Christian

