Bug 622 - [PATCH] Friendly names for pcap traces
: [PATCH] Friendly names for pcap traces
Status: NEW
: ns-3
helpers
: ns-3-dev
: All All
: P5 normal
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2009-07-03 08:51 EDT by
Modified: 2009-12-03 15:52 EDT (History)


Attachments
Patch to add friendly names for pcap traces (2.42 KB, patch)
2009-07-03 08:51 EDT, Antti Mäkelä
Details | Diff
Same patch against revision 5744:01f868cf15eb (2.00 KB, patch)
2009-11-17 10:35 EDT, Faker Moatamri
Details | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2009-07-03 08:51:42 EDT
Created an attachment (id=512) [details]
Patch to add friendly names for pcap traces

Attached is a patch that gives out more meaningful names for trace files.
Instead of filename-nodeid-deviceid, which can get quite cumbersome if you have
lots of devices, this one uses format filename-nodename-devname if they have
been given via Names::Add facility.

For Nodes, simply use 

Ptr<Node> TestBoxNode;
Names::Add("TestBox", TestBoxNode)

For devices, you need to specify the name belongs to specific node (so you can
use e.g. "eth0" for multiple nodes), like so:

Ptr<NetDevice> TestDev = TestBoxNode->GetDevice(0);
Names::Add(TestBoxNode, "eth0", TestDev);

End result what you'll see when you use e.g. 

PointToPointHelper::EnablePcapAll ("testtrace");

will be that instead of testrace-0-0.pcap, you get testrace-TestBox-eth0.pcap

...which I think is quite useful addition.
------- Comment #1 From 2009-07-03 08:54:36 EDT -------
*** Bug 617 has been marked as a duplicate of this bug. ***
------- Comment #2 From 2009-07-15 17:26:56 EDT -------
+1-- reassigning to Craig to review and hopefully merge
------- Comment #3 From 2009-10-23 05:42:55 EDT -------
Hi all,
I have been through this patch and I think small coding style stuff has to be
fixed:
-Coding style (space after parentheses, space before and after != & = ...)
Other than that +1 for patch to be added to ns-3-dev.
Anyone has comments about the patch?
Thanks
------- Comment #4 From 2009-10-23 08:31:12 EDT -------
Well, I guess this needs to be documented somewhere, but what is the
appropriate place? Doing it with every helper classes EnablePcap*-methods seems
a bit wrong - is there some more generic place that would cover them all?
------- Comment #5 From 2009-10-23 10:27:56 EDT -------
I think that the best way to do is to centralize the code and to delegate the
name creation to PcapWriter i.e. something like this:
Ptr<PcapWriter> pcap = Create<PcapWriter> ();
fileName = pcap->GetFileName (nodeid, deviceid)
pcap->Open (fileName);

This way the routine GetFileName will contain the job and you don't have to
repeat the same code in each helper class. The documentation would be in that
case in PcapWriter and the change is minor in the sense that the old style will
be maintained.

What do you think?

Faker
------- Comment #6 From 2009-11-17 10:35:15 EDT -------
Created an attachment (id=660) [details]
Same patch against revision 5744:01f868cf15eb

Here is the same patch but against the latest revision: 5744:01f868cf15eb
------- Comment #7 From 2009-11-17 10:36:30 EDT -------
I agree about the PCapwriter approach.
------- Comment #8 From 2009-12-03 15:52:52 EDT -------
I have a patch that I am not entirely satisfied with.  I will address this
after I complete some other work -- before code complete ns-3.7