USNavalResearchLaboratory / mgen

Multi-Generator (MGEN) traffic generation tool
https://www.nrl.navy.mil/itd/ncs/products/mgen
Other
83 stars 25 forks source link

Change the TOS value in IP header and the user payload #28

Closed szl0144 closed 3 years ago

szl0144 commented 3 years ago

Hi,

I'm revising the MGEN source code to let MGEN produce a traffic flow whose TOS value in IP header is different from the default code. I plan to change the 8th bit in type-of-service (TOS), which is a reserved bit, from 0 to 1. I try to use the command TOS 0x01 in the command line to change it, but it doesn't work. So I revise the c++ source code to change the default value of TOS. I change the the initialized value of the TOS in MGEN class constructor (line 56 in mgen.cpp) from 0 to 1 and set the default_tos_lock variable to be true.

_default_broadcast(true), defaulttos(1),
_default_tos_lock(true), default_multicast_ttllock(false),

However, the TOS value in traffic flow is still 0 after the package building. Can you please give me some suggestions about how to change the default TOS value?

One more thing I am working on is to assign each packet a different data value in user payload but not fixed data for all the packets in a flow. Can you please tell me how I can change this part? Thanks!

Best,

weston-nrl commented 3 years ago

TOS doesn't really exist as a field anymore. It's now DSCP+ECN (see https://en.wikipedia.org/wiki/Type_of_service). MGEN 'tos' parameter can still be used to change those fields (without code modification), but is limited in what it can do by the OS in some cases. For UDP, MGEN 'tos' lower 2 bits can control the ECN field (should only set to 00, 01, or 10, NOT 11). For TCP on Linux though, the ECN fields are controlled by the OS via sysctl net.ipv4.tcp_ecn. In any case, TOS 0x01 would at most set an ECN bit, not change the actual DSCP value.

As for different payload values for each packet, MGEN is not really designed to do that. The easiest way to accomplish it would probably be via the python interface (see src/python/mgen.py) -- you could use that supply a unique payload for each packet using a 'COUNT 1' type of operation, but it will put some limit on how many packets per second you can generate. I suppose you could also just generate an MGEN script with a bunch of 'count 1' operations as well.