[ns] Dropping packets at the MAC layer

Tae Dempsey dempsetl at muohio.edu
Wed Feb 6 08:52:13 PST 2008


Hi all,

I am trying to drop packets in a wireless situation. I have written code in
the mac-802_11.cc file to do such dropping. Even though the logic works, and
output (to the console) shows I should be dropping, the packet somehow still
gets sent to the link layer and gets processed (it shows up in the trace
file as the node receiving the ACK)


Can anybody help me resolve the issue? I want to actually drop the packet
for good to force a resend of the data packet.

Thanks!


Here I am trying to drop ACKs to force the source to resend packets....




static bool PACKET_DROP_FLAG = 1;                               // Do I want
to drop packets or not?
static int PACKET_COUNT = 0;                                    // Keep
track of how many "interesting" packets I have encountered
static int PACKET_DROP_COUNT = 0;                               // Keep
track of how many "interesting" packets I have actually dropped
static int PACKET_TYPE = PT_ACK;                                // Specify
what kind of packet to drop
static int PACKET_LOSS_MODULUS = 10;                            // Specify
how often to drop the packet

static int BUFFER_COUNT = 10;                                   // Don't
drop the first 10 packets

static char* PKT_SENDER = "2";                                  // Where is
the packet going to be coming from?
static char* PKT_RECVR = "0";                                   // Who
should receive the packet under ideal situations?
static int MALICIOUS_NODE = 0;                                  // Who is
the one dropping the packet?

void
Mac802_11::recvDATA(Packet *p)
{
        struct hdr_mac802_11 *dh = HDR_MAC802_11(p);
        u_int32_t dst, src, size;
        struct hdr_cmn *ch = HDR_CMN(p);


        /*
         * Going to drop ACK packets using the static constants provided
above this method.
         *
         */

        int dest_match =
strcmp(Address::instance().print_nodeaddr(hdr_ip::access(p)->daddr()),
PKT_RECVR);
        int src_match =
strcmp(Address::instance().print_nodeaddr(hdr_ip::access(p)->saddr()),
PKT_SENDER);

        if (PACKET_DROP_FLAG && hdr_cmn::access(p)->ptype() == PACKET_TYPE
&& index_ == MALICIOUS_NODE && dest_match == 0 && src_match == 0) {

                PACKET_COUNT ++;

                if (BUFFER_COUNT > 0) {
                        BUFFER_COUNT --;
                }
                else if (PACKET_COUNT % PACKET_LOSS_MODULUS == 0) {
                        PACKET_DROP_COUNT ++;
                        int SEQ_NO = hdr_tcp::access(p)->seqno();

                        fprintf(stdout, "at node %d; packet type = %d;
counted = %d; dropped = %d ; seq_no = %d \n",
                                                        index_,
                                                        PACKET_TYPE,
                                                        PACKET_COUNT,
                                                        PACKET_DROP_COUNT,
                                                        SEQ_NO);

                        //drop(p);
                        discard(p, DROP_MAC_BUSY);  // using some dummy
constant as "why"
                        return;
                }
        }

        /*
         * End my code
         *
         */


More information about the Ns-users mailing list