Bug 405 - wifi log messages improvements
wifi log messages improvements
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: wifi
ns-3-dev
PC Linux
: P1 enhancement
Assigned To: Mathieu Lacage
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-07 12:22 EST by Gustavo J. A. M. Carneiro
Modified: 2008-12-10 04:43 EST (History)
3 users (show)

See Also:


Attachments
patch (9.08 KB, patch)
2008-11-07 12:22 EST, Gustavo J. A. M. Carneiro
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gustavo J. A. M. Carneiro 2008-11-07 12:22:31 EST
Created attachment 294 [details]
patch

Uses NS_LOG_APPEND_CONTEXT to add node and netdevice index.  This may not apply to ns-3-dev directly, as I am working in another branch, but you get the idea.  Logs become something like this:

0.000734987s [node 2 dev 0] MacLow:ReceiveOk(0x2d7b250, ns3::WifiMacHeader (CTL_ACK Duration/ID=0us, RA=d0:00:00:00:00:03) ns3::WifiMacTrailer (), 9.35955, wimax, 0)
0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): d0:00:00:00:00:03 duration/id=0ns
0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): hdr.IsCts (): 0; hdr.GetAddr1 (): d0:00:00:00:00:03; m_self: d0:00:00:00:00:03; m_ctsTimeoutEvent.IsRunning (): 0; m_currentPacket: 0
0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): d0:00:00:00:00:03 rx drop CTL_ACK
Comment 1 Tom Henderson 2008-11-10 13:31:57 EST
(In reply to comment #0)
> Created an attachment (id=294) [details]
> patch
> 
> Uses NS_LOG_APPEND_CONTEXT to add node and netdevice index.  This may not apply
> to ns-3-dev directly, as I am working in another branch, but you get the idea. 
> Logs become something like this:
> 
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(0x2d7b250, ns3::WifiMacHeader
> (CTL_ACK Duration/ID=0us, RA=d0:00:00:00:00:03) ns3::WifiMacTrailer (),
> 9.35955, wimax, 0)
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): d0:00:00:00:00:03
> duration/id=0ns
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): hdr.IsCts (): 0; hdr.GetAddr1
> (): d0:00:00:00:00:03; m_self: d0:00:00:00:00:03; m_ctsTimeoutEvent.IsRunning
> (): 0; m_currentPacket: 0
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): d0:00:00:00:00:03 rx drop
> CTL_ACK
> 

+1 from me.  We need to add similar to other devices, and to the internet stack.

By the way, I've never succeeded in getting NS_LOG output to print the time out in units of seconds rather than ns.  What setting or environment variable is needed to enable that?
Comment 2 Mathieu Lacage 2008-11-25 09:15:38 EST
(In reply to comment #0)
> Created an attachment (id=294) [details]
> patch
> 
> Uses NS_LOG_APPEND_CONTEXT to add node and netdevice index.  This may not apply
> to ns-3-dev directly, as I am working in another branch, but you get the idea. 
> Logs become something like this:
> 
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(0x2d7b250, ns3::WifiMacHeader
> (CTL_ACK Duration/ID=0us, RA=d0:00:00:00:00:03) ns3::WifiMacTrailer (),
> 9.35955, wimax, 0)
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): d0:00:00:00:00:03
> duration/id=0ns
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): hdr.IsCts (): 0; hdr.GetAddr1
> (): d0:00:00:00:00:03; m_self: d0:00:00:00:00:03; m_ctsTimeoutEvent.IsRunning
> (): 0; m_currentPacket: 0
> 0.000734987s [node 2 dev 0] MacLow:ReceiveOk(): d0:00:00:00:00:03 rx drop
> CTL_ACK

The problem is that I spent an inordinate amount of time making sure that the MacLow class does not depend on a pointer back to the NetDevice class. If you want to add context to the log output in the MacLow layer, you should consider printing the MAC address which is stored in the MacLow class.

In the higher MAC layers, they all have access to the MacLow class, so, you can invoke GetAddress on it and print it in the context without needing the extra back pointer to NetDevice.



Comment 3 Gustavo J. A. M. Carneiro 2008-11-25 09:35:08 EST
Mathieu, the MAC address is pretty useless to me.  If you are debugging the entire stack you need an identifier that is stable across all layers of the stack, and the only such identifier is the node ID.  If you do not have a pointer to the NetDevice, you also don't have a pointer to the Node.

I don't understand why you "spent an inordinate amount of time making sure that the MacLow class does not depend on a pointer back to the NetDevice class".  Why was it worth the effort?

Somehow I knew this was going to happen sooner or later.  And to think that I had a simple patch to store the "current node ID" in the Simulator class, which would avoid this whole mess... :-(
Comment 4 Tom Henderson 2008-11-25 10:18:51 EST
I agree with Gustavo about preferring nodeid/device id vs. mac address.  What about creating something like:

class MacLogContextHelper
{
 // returns "[node <id> device <id>]" string corresponding to addr
 std::string GetNodeAndDeviceContext (const Mac48Address addr);

}

and cache the value in a MacLow string?
Comment 5 Mathieu Lacage 2008-12-10 04:43:48 EST
applied a patch which adds the mac address as context.
changeset 49a08376f196