Bug 622 - [PATCH] Friendly names for pcap traces
[PATCH] Friendly names for pcap traces
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: helpers
ns-3-dev
All All
: P5 normal
Assigned To: Craig Dowell
:
: 617 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-07-03 08:51 UTC by Antti Mäkelä
Modified: 2010-02-26 12:22 UTC (History)
3 users (show)

See Also:


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

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Mäkelä 2009-07-03 08:51:42 UTC
Created attachment 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 Antti Mäkelä 2009-07-03 08:54:36 UTC
*** Bug 617 has been marked as a duplicate of this bug. ***
Comment 2 Tom Henderson 2009-07-15 17:26:56 UTC
+1-- reassigning to Craig to review and hopefully merge
Comment 3 Faker Moatamri 2009-10-23 05:42:55 UTC
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 Antti Mäkelä 2009-10-23 08:31:12 UTC
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 Faker Moatamri 2009-10-23 10:27:56 UTC
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 Faker Moatamri 2009-11-17 10:35:15 UTC
Created attachment 660 [details]
Same patch against revision 5744:01f868cf15eb

Here is the same patch but against the latest revision: 5744:01f868cf15eb
Comment 7 Antti Mäkelä 2009-11-17 10:36:30 UTC
I agree about the PCapwriter approach.
Comment 8 Craig Dowell 2009-12-03 15:52:52 UTC
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