[Click] generating random destination IP packets?

Beyers Cronje bcronje at gmail.com
Tue Apr 17 07:28:53 EDT 2007


Hi Azeem,

SetRandIPAddress only sets the annotation, so it's not what you are looking
for.

You can have a look at
http://www.read.cs.ucla.edu/click/elements/anonymizeipaddr which changes
both src and dst addresses. Alternatively write your own element to change
the dest address, this should be really simple:

static uint32_t
rand32()
{
    return ((random() << 8) & 0xFFFF0000) | ((random() >> 12) & 0x0000FFFF);
}

in your push function:

const click_ip *in_iph = p->ip_header();
if (!in_iph || in_iph->ip_v != 4) {
    output(0).push(p);
    return 0;
} else if (WritablePacket *q = p->uniqueify()) {
    click_ip *iph = q->ip_header();
    iph->ip_dst.s_addr = rand32();
   output(0).push(q);
}

And then apply checksum elements.

Beyers


On 4/17/07, Azeem Khan <azeem_k at hotmail.com> wrote:
>
>
> Hello everyone,
>
>    I wish to generate UDP/IP packets with random destination IP addresses
> at different rates.  From reading the Click element documentation, I believe
> that FastUDPSource + SetRandIPAddress + SetUDPChecksum + SetIPChecksum
> should do the trick. Am I correct?
>
>    Will SetRandIPAddress also set the IP destination address randomly
> besides the annotation?
>
>    If so, can anyone give me an example on how to use the SetRandIPAddress
> element? I cannot seem to get it right. I am not clear on what the arguments
> mean.
>
>
> Thank You.
>
> Azeem Khan
> Bombay, India.
> _________________________________________________________________
> Get the new Windows Live Messenger!
> http://get.live.com/messenger/overview
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>


More information about the click mailing list