Castalia铁路线性WSN能耗仿真结果异常技术求助
Hey there, let's troubleshoot your Castalia WSN simulation issue where the energy consumption results don't match your expectations for that railway linear network setup. First, let's recap your goal: node 0 is the coordinator, node 9 is the sensing node that forwards data all the way to node 0, but the energy numbers are off. Here are targeted steps to track down the problem:
Your provided config cuts off after node 3's x-coordinate, so make sure all 10 nodes are arranged in a strict linear pattern (since it's a railway scenario). For example:
SN.node[4].xCoor = 40 SN.node[5].xCoor = 50 ... SN.node[9].xCoor = 90
If any node's position is misconfigured (e.g., a gap or overlapping), the routing path might not be the expected multi-hop (9→8→...→0)—maybe node 9 is trying to communicate directly with node 0 (which uses way more power) or taking an unexpected route.
Castalia doesn't always auto-assign coordinator roles, so explicitly set node 0's role and node 9's sensing/forwarding behavior:
SN.node[0].applicationType = "Coordinator" SN.node[9].applicationType = "SensingNode" SN.node[9].application.destination = 0 # Ensure data is sent to node 0
Also verify node 9's data transmission interval—if it's sending data far more frequently than you intended, that'll blow up energy usage.
Linear WSNs rely on consistent routing paths, so check these details:
- Did you enable a routing protocol that fits linear topologies? For example, if using a custom linear routing module:
Or if using a standard protocol like AODV, ensure it's configured to prefer shortest paths in the linear layout.SN.node[*].routingProtocol = "LinearRouting" - Turn on routing debug logs to see the actual path node 9 uses:
Look for excessive route discovery broadcasts—these are hidden energy hogs that can skew results.SN.routing.debug = true
The ../Parameters/Castalia.ini include file has critical energy settings that might be mismatched with your hardware assumptions:
- Check radio power values:
radio.txPower,radio.rxPower, andradio.idlePower—if these are set for low-power sensors but you're simulating industrial railway hardware, the numbers will be off. - Verify sensor module power: Node 9 is a sensing node, so confirm
sensor.powerConsumptionmatches your expected sampling and data processing energy costs. - Ensure the battery model is correctly configured (e.g.,
battery.model = "BasicBattery"with the right initial capacity).
Your current config has repeat = 2 and sim-time-limit = 7000s:
- 2 repetitions are too few to get stable average energy results—bump this to 5-10 to account for simulation variance.
- Confirm 7000s is long enough to capture multiple data forwarding cycles from node 9. If your send interval is, say, 2000s, 7000s only covers 3 cycles—extend it if needed to get meaningful data.
Turn on full debug logging to see exactly where energy is being used:
SN.application.debug = true SN.radio.debug = true SN.battery.debug = true
These logs will show every transmit/receive event, idle period, and battery drain event. Focus on node 9 and the intermediate nodes (8,7,...) to see if:
- Nodes are staying in idle/rx mode when they should be sleeping
- There are unexpected retransmissions or control packet floods
- Node 9 is using more power for sensing than you calculated
内容的提问来源于stack exchange,提问作者xarokk

