[Click] ECN

JS njeanseb at gmail.com
Wed Aug 8 05:39:16 EDT 2007


Hi everyone,
I am writing a active queue management element and I need to access the ECN
bit, and I think I have found out how in the MarkIPCE element. But there are
a few line that I don't really understand in the MarkIPCE element I think
they have something to do with the checksum but if someone can explain me
what is going on here.
what is the IP_ECN_ECT2? does this code really have something to do with the
checksum?

    const click_ip *iph = p->ip_header();
    ....
    WritablePacket *q = p->uniqueify();
    click_ip *q_iph = q->ip_header();

    if ((q_iph->ip_tos & IP_ECNMASK) == IP_ECN_ECT2) {
      unsigned sum = (~ntohs(q_iph->ip_sum) & 0xFFFF) + 0x0001;
      q_iph->ip_sum = ~htons(sum + (sum >> 16));
    } else {
      unsigned sum = (~ntohs(q_iph->ip_sum) & 0xFFFF) + 0x0002;
      q_iph->ip_sum = ~htons(sum + (sum >> 16));
    }


More information about the click mailing list