On Thu, Oct 20, 2016 at 05:58:12AM -0700, Eddy G wrote:
> It does not seem like it is possible to do something like:
> 
>     const16(dinc(1,1023))
> 
> because 1) dinc() and ddec() are limited to single octets, and 2) you can't 
> nest dinc() or ddec() inside the c* helpers.
> 
> The above would be useful to allow a dynamic trafgen cfg that iterates 
> through a range of source/destination ports (for example).
> 
> Is expanding dinc()/ddec() to allow values larger than an octet and 
> "nesting" of other helper functions inside the c*() helpers something that 
> has been discussed?
> 
> Or perhaps a plan to add dinc16() / ddec16(), dinc32()/ddec32(), etc.?
> 
> 
> Also, the new protocol header functions are terrific, but are limited by 
> their inability to prevent more complex / partial dynamic configuration 
> parameters as values. For example:
> 
>     eth(da=00:53:00:dinc(0,1):drnd(2))
>     ipv4(da=1.2.drnd(2))
> 
> Any possibility this is something that has been discussed? Such partial 
> constructs would be *very* useful in generating randomized traffic for 
> testing purposes.
> 
> 
> Thanks,
> Eddy
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "netsniff-ng" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to netsniff-ng+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Hi Eddy,

I added ability to specify proto function at specified field's offset:

    <proto field>[<offset>:<length>]

    <offset> - starts from 0 byte in network order

    <length> - length of value which will be used which might be 1,2 or 4
             bytes (default 1 byte).

Changes added already into master, I have sent separate patch for
trafgen's man page regarding these changes. The similar syntax is used
in pcap filter to match headers field by offset & length. Here are some
examples with trafgen and output from netsniff-ng for better understand
how it can be used:


1) trafgen -o lo --cpus 1 -n 1 '{ eth(da[0]=dinc(), da=11:22:33:44:55:66), 
tcp() }'

        P lo 54 1482259546s.934331688ns #1 
         [ Eth MAC (00:00:00:00:00:00 => 00:22:33:44:55:66)


2) trafgen -o lo --cpus 1 -n 1 '{ eth(da=11:22:33:44:55:66, da[0]=dinc()), 
tcp() }'

        M lo 54 1482259682s.24357875ns #2 
         [ Eth MAC (00:00:00:00:00:00 => 11:22:33:44:55:66)

3) trafgen -o lo --cpus 1 -n 3 '{ eth(da=11:22:33:44:55:66, da[0]=dinc()), 
tcp() }'

        M lo 54 1482259851s.161018621ns #3 
         [ Eth MAC (00:00:00:00:00:00 => 11:22:33:44:55:66)

        P lo 54 1482259851s.161032201ns #4 
         [ Eth MAC (00:00:00:00:00:00 => 12:22:33:44:55:66)

        M lo 54 1482259851s.161033977ns #5 
         [ Eth MAC (00:00:00:00:00:00 => 13:22:33:44:55:66)

4) trafgen -o lo --cpus 1 -n 3 '{ ipv4(da=1.2.3.4, da[0]=dinc()), tcp() }'

        < lo 54 1482265434s.453794790ns #1 
         [ IPv4 Addr (127.0.0.1 => 1.2.3.4)

        < lo 54 1482265434s.453811528ns #2 
         [ IPv4 Addr (127.0.0.1 => 2.2.3.4)

        < lo 54 1482265434s.453815331ns #3 
         [ IPv4 Addr (127.0.0.1 => 3.2.3.4)

5) trafgen -o lo --cpus 1 -n 3 '{ ipv4(da=192.168.1.1, da[1]=dinc()), tcp() }'

        < lo 54 1482265603s.917104425ns #4 
         [ IPv4 Addr (127.0.0.1 => 192.168.1.1)

        < lo 54 1482265603s.917122777ns #5 
         [ IPv4 Addr (127.0.0.1 => 192.169.1.1)

        < lo 54 1482265603s.917127151ns #6 
         [ IPv4 Addr (127.0.0.1 => 192.170.1.1)


As you see you need to 1st set initial field value and then set this
field with dynamic function at specific offset, we will try to implement
some better short alternative syntax.

Let me know if you have some comments/suggestions.

Regards,
Vadim Kochan

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to