NS-3 Sniffing Passive ACKs

106 views Asked by At

I am editing the AODV module in NS-3.

When a node forwards a data packet to the next node, I want my AODV module to listen to overhear next node's forwarding process to make sure it is forwarding it right.

The pcap file correctly sniffs next node's transmission, but I cannot get my hands on it from the AODV module.

I am guessing that the packet is being dropped since it is not supposed to be involved on it, thus I want to know how to change that.

Can anyone give me clues on where to look to change any relevant codes?

Thanks

1

There are 1 answers

1
Tom Henderson On

Overhearing can be accomplished by hooking one of the Wi-Fi device trace sources. The MonitorSnifferRx in the WifiPhy object is probably what you want. There are two steps: 1) obtain a pointer to the Wi-Fi Phy somehow, and 2) attach a callback function to that trace source.

Step 1) is already mostly done in Aodv in an existing method:

RoutingProtocol::NotifyInterfaceUp ()
...
// Allow neighbor manager use this interface for layer 2 feedback if possible
Ptr<WifiNetDevice> wifi = dev->GetObject<WifiNetDevice> ();

From this point, you can get a Phy object pointer:

Ptr<WifiPhy> phy = wifi->GetPhy();

From here, you will want to use TraceConnectWithoutContext() to hook the trace souce, with a callback that has a matching function signature to what the MonitorSniffRx trace expects.

phy->TraceConnectWithoutContext ("MonitorSniffRx", MakeCallback (&InsertYourCallbackFunctionHere));

See how the Mac-level trace source "TxErrHeader" is similarly hooked in that same method.