[Click] Implementing a packet cache for selective ACKs and ReTx
Ashish Sharma
ashishs.sharma at gmail.com
Wed Oct 28 21:33:41 EDT 2009
Thank you Roman and Cliff. I followed Cliff's advice as it seemed easier and
a cleaner way of copying a packet, and it fixed my issue. Another great
suggestion from Cliff that helped me debug was the following: If the packet
in cached may be retrieved more than once (fore multiple retries), each time
a clone of the cached packet should be used.
Cheers and many thanks.
- Ashish
On Wed, Oct 28, 2009 at 10:09 AM, Cliff Frey <cliff at meraki.com> wrote:
> As long as your code always does p->uniqueify *immediately before*
> modifying the packet contents, you should be fine.
>
> So something like:
>
> simple_action(Packet *p) {
> if (Packet *p2 = p->clone()) {
> insert_in_cache(p2);
> }
> WritablePacket *wp = p->uniqueify();
> // never access p again
> ...
> }
>
> your code should be totally safe.
>
> However, functionally this should essentially be the same as what Roman
> Chertov suggests, in that it will actually memcpy the packet contents.
>
> If you are getting segfaults, I strongly recommend running with valgrind...
>
> valgrind click myconfig.click
>
> clearly this won't work in the kernel, but often you can simulate enough of
> your config to get the appropriate elements to work at userlevel.
>
> If you have to use the kernel, then you can build click with
> --enable-dmalloc and you can build linux with DEBUG_SLAB and it gets you
> many of the same protections.
>
> Cliff
>
> On Wed, Oct 28, 2009 at 3:08 AM, Ashish Sharma <ashishs.sharma at gmail.com>wrote:
>
>> Hi,
>>
>> I am trying to implement a bulk acknowledgement scheme with selective
>> retransmits for wireless. I have implemented a TDMA based MAC for wireless
>> wherein a node sends multiple packets during its slot. Instead of
>> per-packet
>> 802.11 acks, I am trying to implement a piggy-backed bulk ACK scheme where
>> the recipient responds with a bitmap of the received packets that it is
>> trying to acknowledge. For this I have implemented my own sequence number
>> management in a separate header.
>>
>> The issue is, that after I assign it my custom sequence number, I need to
>> create a copy of the packet along with all the headers and data so that it
>> can be retransmitted at a later time if it is not ACKed by the recipient.
>>
>> My question is how do I do this, since Packet::clone shares the data with
>> the original packet (which is killed after being send to ToDevice ?) and
>> with Packet::uniqueify() I can only create one copy? Documentation in
>> packet.cc mentions that
>>
>> Packet *p = ...;
>> if (WritablePacket *q = p->uniqueify()) {
>> Packet *p2 = q->clone();
>> assert(p2);
>> }
>> is buggy and WritablePacket::clone() is discouraged.
>>
>> My function looks something like this:
>>
>> Packet * BulkAckManager::handle_outgoing_pkt(Packet *p,..) {
>> WritablePacket *p_out = p->uniqueify();
>> if (p_out) {
>> // Put sequence number in p_out->bulk_ack_hdr;
>> * WritablePacket *q_copy = p_out->clone(); *or *
>> p_out->uniqueify()*or *p->uniqueify(*);
>> insert_in_cache(seq_num, q_copy);
>> return p_out;
>> }
>> }
>>
>> Packet * BulkAckManager::Retransmit(seq_num) {
>> Packet* p_retx = fetch_from_cache(seq_num);
>> return p_retx;
>> }
>>
>> I have tried p_out->clone(), p_out->uniqueify and p->uniqueify and each
>> time I get a Seg Fault when trying to retransmit this packet at a later
>> stage.
>>
>> I will be grateful for any suggestions. Thanks for your time.
>>
>> Ashish
>>
>> P.S. : I looked at snooptcp.cc and it also maintains a packet cache,
>> however I believe it never modifies the packets, so
>> WritablePacket->uniqueify followed by another copy is not required there.
>> _______________________________________________
>> click mailing list
>> click at amsterdam.lcs.mit.edu
>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>
>
>
More information about the click
mailing list