Is there a unique packet identifier in ns3? If so, how do we trace it?
I want to calculate instantaneous delay and throughput for udp based
simulations. I understand that in certain cases, there might a
combination of attributes that can be used to identify packets. For
example, if I use UDP with wifi, the MAC SeqNumber along with source
and destination IP address can identify a packet uniquely. But what
about the case where UDP is being used with point-to-point links?
Thanks,
Abdul.
You can:
1) hook in your traffic-generator's Tx event
2) add a 'tag' which contains a unique id to each packet from the Tx
event
3) hook in your receiver's Rx trace event (or in any other trace
event)
4) lookup the relevant tag and print its uniqueid.
Here is a rough outline of how the above could be done:
static UniquePacketIdManager g_manager;
static void TxHook (std::string path, Ptr<const Packet> p)
{
g_manager.Set (p);
}
static void RxHook (std::string path, Ptr<const Packet> p)
{
NS_ASSERT (g_manager.Has (p));
UniqueId uid = g_manager.Get (p);
std::cout << uid.packetId << std::endl;
// or, p->PrintTags (std::cout);
}
int main (int argc, char *argv[])
{
g_manager = UniquePacketIdManager (1);
Config::Connect ("/NodeList/x1/ApplicationList/y1/Tx", MakeCallback (&TxHook));
Config::Connect ("/NodeList/x2/ApplicationList/y2/Rx", MakeCallback (&RxHook));
}
I hope that the above helps,
Mathieu
On Tue, 2008-10-14 at 17:37 -0500, Abdul Jabbar wrote:You can:
> Hi,
>
> Is there a unique packet identifier in ns3? If so, how do we trace it?
> I want to calculate instantaneous delay and throughput for udp based
> simulations. I understand that in certain cases, there might a
> combination of attributes that can be used to identify packets. For
> example, if I use UDP with wifi, the MAC SeqNumber along with source
> and destination IP address can identify a packet uniquely. But what
> about the case where UDP is being used with point-to-point links?
1) hook in your traffic-generator's Tx event
2) add a 'tag' which contains a unique id to each packet from the Tx
event
3) hook in your receiver's Rx trace event (or in any other trace
event)
4) lookup the relevant tag and print its uniqueid.
>
> I am surprised by this answer. I would have guessed packet->GetUid ()
> is all what Abdul would need...
I think you caught me over-engineering this: you are right.
Mathieu
>
Secondly, I would still need to trace this Uid every time a packet is
transmitted, received, forwarded or dropped. Would you suggest an
optimal way to achieve this? Hook in to the respective trace events?
Thanks,
Abdul.
So, it appears that the consensus is that ns3 already uses a unique
packet id, Uid. I guess this implies that all traffic sources use it
and any future user defined applications based on packet class will
use it. Please correct me if I am wrong.
Secondly, I would still need to trace this Uid every time a packet is
transmitted, received, forwarded or dropped. Would you suggest an
optimal way to achieve this? Hook in to the respective trace events?
Thanks,
Abdul.
On Oct 15, 2008, at 6:04 AM, Mathieu Lacage wrote:
>
> On Wed, 2008-10-15 at 11:20 +0100, Gustavo Carneiro wrote:
>
>>
>> I am surprised by this answer. I would have guessed packet->GetUid
>> ()
>> is all what Abdul would need...
>
> I think you caught me over-engineering this: you are right.
>
> Mathieu
>>
>
>
> >
With ns2 we did this by keeping track the unique pid in the trace file
using post-processing scripts and hence the interest in getting access
to the uid again to trace it, but perhaps this is not the best
approach with ns3? We were wondering if there has been thought given
already to instrumenting delay in the network simulations, or if there
is a vision of how this would be accomplished in the future. Besides
tracing the uid we have also thought of options such as a special
application which sends timestamps in the payload or doing and icmp
implementation, but neither of these options seem ideal. We are
looking forward to others feedback on this question.
Thanks!
Justin P. Rohrer
http://www.ittc.ku.edu/~rohrej
Graduate Research Assistant
Information and Telecommunications Technology Center
The University of Kansas
> Could you clarify on when the UID is generated in the system really?
> Based on what you are saying regarding
> problems with ip fragmentation and tcp aggregation, it implies that
> the UID is generated
> when an application sends data to tcp/udp socket? Or is it generated
> at the netdevice layer?
It is generated whenever someone calls one of the non-default
constructors of the Packet class. You can trivially see in packet.cc
where m_globalUid is incremented.
Mathieu
On Wed, 2008-10-15 at 18:41 -0500, Justin P. Rohrer wrote:
> I'm working with Abdul on migrating our simulation models from ns2 to
> ns3 and wanted to branch off from the unique pid discussion to a
> higher level question: What is the correct way to instrument
> instantaneous and average per-packet delay?
>
> With ns2 we did this by keeping track the unique pid in the trace file
> using post-processing scripts and hence the interest in getting access
> to the uid again to trace it, but perhaps this is not the best
> approach with ns3? We were wondering if there has been thought given
I would hope that we can leverage the packet tag stuff I mentioned in my
first email to perform online calculations of all these metrics and
avoid post-processing.
> already to instrumenting delay in the network simulations, or if there
> is a vision of how this would be accomplished in the future. Besides
> tracing the uid we have also thought of options such as a special
> application which sends timestamps in the payload or doing and icmp
There is already some code which can be used to attach timestamps to
packets and calculate delay and jitter. See
src/contrib/delay-jitter-estimation.h
> implementation, but neither of these options seem ideal. We are
There is already an icmp implementation in a branch and I plan to submit
it for inclusion soon. It was reviewed on ns-developers a couple of
weeks ago.
Mathieu