[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Packet::free(pkt)



Hi,

consider the following:

nodes A and B, both connected via UDP + my own application
(UDP slightly extended)

1. A sends packet with a datafield to B. datafield contains just an
identifier. (id_), like in HTTP
2. UDP agent at B passes the data to the applicatoin but also the packet
itselve (my own extension)
3. The application at B takes a different datatype which besides the id_
field, also contains a Packet* field. It stores the packet received from A
in that field. 
4. The UDP at B now thus sends a packet to A, contiaining a datafield in
which an integer AND a packet are included.
5. The Application at A receives this packet and accesses the datafield. It
finds a packet, extracts it and is able to retrieve that packet's id_ field
(e.g. the id field of the packet it originally send, in step 1, to B)

This works. However, I don't know why.

The UDP agent at B (after step 2) will perform Packet::free(pkt) after
passing the data + packet upto the application (just after the call to
process_data), thereby deleting all datafields of that packet. The packet
that the application at B stores therefore should have an empty data field
and thus no 'correct' value of the id_ field. Still, back at A, the
application can access that id_ field (which is normal) but it also  obtains
the correct id_ value.

How is this possible?

Regards, Sjoerd Janssen