Re: [netsniff-ng] trafgen cfg: automatically padding dynamic values to sizes larger than 1 octet

2016-12-21 Thread Vadim Kochan
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:

[:]

 - starts from 0 byte in network order

 - 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.


Re: [netsniff-ng] trafgen cfg: automatically padding dynamic values to sizes larger than 1 octet

2016-10-24 Thread Vadim Kochan
Hi Eddy,


On Thu, Oct 20, 2016 at 3:58 PM, 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.?

Well, the easier way might be to add new dinc16/32  ddec16/32 in the
way like there
are other func16/32(...).

>
>
> 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.

I'd focus 1st on proto functions and then move to the low-level functions,
and I'd propose the following (for example) way to apply
dynamic funcs to the part of field:

eth(sa=, sa[from:to]=dinc())

ftom:to - in bytes offset, it might be also [from:len], not sure what
would be better.

Currently I don't know exactly if it will hard to parse this, just an
proposal for the syntax.

>
>
> 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.

All these ideas look reasonable to add to trafgen.

Thanks,
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.


[netsniff-ng] trafgen cfg: automatically padding dynamic values to sizes larger than 1 octet

2016-10-20 Thread Eddy G
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.