[Ns-developers] DelayBox - ns-3

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Mon Apr 7 09:12:02 PDT 2008


On Mon, 2008-04-07 at 08:58 -0700, Mathieu Lacage wrote:
> On Sat, 2008-04-05 at 16:17 -0400, Matt Crinklaw wrote:
> 
> > DelayBox doesn't actually do the packet classification.  Packets are
> > given a flow id by the TCP Agent (this is the ns-2 equivalent of
> > ns-3's TCP Socket) which generated them.
> 
> Ok. Thanks for the precision.
> 
> > Flow ids (in my mind) are something that should be assigned on a per
> > connection basis.  Since this is the case, it seems that the most
> > logical thing to do would be to add functionality to the TCP Socket
> > code.  This added functionality would allow the code using the socket
> > to assign a flowid to that socket.  The socket would then assign its
> > flowid to each packet that it generates.
> 
> I think that it would be nice to avoid adding cruft to the socket code
> and to leave this to the application generating traffic or to move this
> in some more generic packet classification facility.

Erm, it occured to me that I did not explain how you can leave this to
the application generating traffic. Here is a rough outline:

1) make sure that you application has a trace source triggered for each
packet sent down the socket

2) define a 'flow tagging' callback

static void
MyFlowTaggingFunction (uint32_t flowid, std::string context, Ptr<const
Packet> packet, ...)
{
  FlowIdTag tag;
  tag.Set (flowid);
  packet->AddTag (tag);
}

You could also implement a more fancy flow tagging callback which tags
the packet with a flowid calculated from the nodeid/applicationid/socket
itself to save you from having to specify a single flowid by hand for
each of the flows you are interested in.

3) connect flow tagging callback to the application trace source.

uint32_t flowid = yourmagicnumber;

Config::Connect ("/NodeList/XX/ApplicationList/XX/MyTraceSource",
MakeBoundCallback (&MyFlowTaggingFunction, flowid));

If this is felt like a generic-enough facility, it should be easy to add
the FlowIdTag class to src/node or src/common.

The code in src/contrib/delay-jitter-estimator.h|cc does something very
similar to what is shown here.

Mathieu



More information about the Ns-developers mailing list