Modifying rated source

Eddie Kohler kohler at aciri.org
Tue Jul 3 17:27:43 EDT 2001


Hi Werner,

I agree with Benjie: you probably want to write new elements to do this,
but keep RatedSource. One element would store the packet's timestamp
annotation into the packet data, and one would copy a portion of the packet
data into the timestamp annotation. Those elements would be a pleasant
exercise to write!

> I need for my measurements an UDP packet generator which is able to set
> the current timestamp in the packet (not the click annotation) in order
> to measure the delay between sender and receiver. Because there is no
> such click element available yet I intend to modify the RatedSource
> element and write the timestamp which I get with the
> click_gettimeofday(&now) after a conversion to a string as a packet
> payload instead of the default string data in RatedSource::configure().
> My question: is this data string read for each new created packet?

The answer to your question is "No". The RatedSource element creates a
single packet, "_packet", from the data string. Then it just outputs clones
of this packet, while keeping the old packet around for later. (A "clone"
of a packet is a new packet header that shares the old packet's data. This
makes packets copy-on-write and reduces data copies.) The relevant lines:
(114-116 of ratedsource.cc in CVS)

    Packet *p = _packet->clone();
    p->set_timestamp_anno(now);
    output(0).push(p);

You could change this behavior, but I think the elements Benjie suggests
are a better idea.

I would call the elements StoreTimestamp and GetTimestamp, by analogy with
StoreIPAddress and GetIPAddress.

> What element could I use on the
> receiver side for reading the packet stamp (e.g. Print)?

If you write GetTimestamp (which would take the stored timestamp and put it
in the timestamp annotation), then Print or IPPrint's "TIMESTAMP true"
keyword argument will work.

love,
ed



More information about the click mailing list