Bugzilla – Bug 1645
Visualizer crashes decoding a transmitted packet shorter than 23 bytes.
Last modified: 2013-10-26 15:27:55 EDT
I built a environment with two wifi nodes and run it with --vis argument
When device send packet smaller than 23 bytes. An "assert failed" occourred:
assert failed. cond="m_current >= m_dataStart && m_current <= m_dataEnd", msg="You have attempted to read beyond the bounds of the available buffer space. This usually indicates that a Header::Deserialize or Trailer::Deserialize method is trying to read data which was not written by a Header::Serialize or Trailer::Serialize method. In short: check the code of your Serialize and Deserialize methods.", file=./ns3/buffer.h, line=823
terminate called without an active exception
Here is the test code:
using namespace ns3;
int main (int argc, char *argv)
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default();
devices = wifi.Install(wifiPhy, wifiMac, nodes);
Ptr<Packet> p = Create<Packet>(22); // assert failed
//Ptr<Packet> p = Create<Packet>(23); // it works
devices.Get(0)->Send(p, Mac48Address::GetBroadcast(), 0x0);
Debugger: see http://en.wikipedia.org/wiki/Debugger
I know debugging a program with the visualizer module enabled isn't for all, but still...
Anyway, the bug isn't in the core. And it isn't in the WiFi either.
The bug is:
Visualizer hooks the WiFiNetDevice::NotifyTx function.
PyWiz::TraceNetDevTxWifi will attempt to deserialize the WiFiMacHeader. Which is NOT there, as it's added later on by WiFiMac (actually even below).
The only header available at that stage is LlcSnapHeader. This, at least, is what I could find. The ball goes to the visualizer master.
I am not sure how this happened, but somewhere along the way ns-3 must have changed the way it reports packets in wifi trace hooks. I'm pretty sure it used to have a WifiMacHeader, but it must have been removed at some point and I didn't notice this problem.
Anyway, I filed bug 1785 for the wifi part, and I will attach a corresponding patch for pyviz that fixes the issue.
Created attachment 1689 [details]
patch to fix it, builds on top of bug 1785