[Click] Is it possible for a packet to exist twice inside of
a router?
Eddie Kohler
kohler at cs.ucla.edu
Sun Nov 28 14:29:06 EST 2004
Hi,
server at mail.utexas.edu wrote:
> Is it possible, for example, for the same exact packet to exist in multiple
> queues? I ask, because if you were storing your packets in a central location
> and then fetching them back when you got to transmit, you'd need to delete
> packets from that central location when they were no longer needed.
>
> If there can only be one copy, then a discard from a queue would always delete
> packets from that shared memory. If there can be multiple, you'd have to keep a
> counter of how many copies exist.
>
> Which is the case?
>
> Thanks!
It's a smidgeon more complicated than this.
Click Packets consist of a common header, with information like annotations
and packet length, and the packet data itself.
A Packet *header* exists at most once in the configuration. To make a packet
copy, you call "p->clone()", which returns a new Packet. But packet *data*
can be referred to by multiple Packet headers. It is reference counted; when
the last Packet header is deleted, the packet data goes away too. As Bart
points out, you can call Packet::uniqueify() to get a unique copy of the
packet data.
Eddie
More information about the click
mailing list