appneta / tcpreplay

Pcap editing and replay tools for *NIX and Windows - Users please download source from
http://tcpreplay.appneta.com/wiki/installation.html#downloads
1.17k stars 268 forks source link

[Feature] help should print options in alphabetical order #671

Closed fklassen closed 2 years ago

fklassen commented 3 years ago

Would like to see options printed in alphabetical order. Current order is ...

$ tcpreplay -h
Warning: May need to run as root to get access to all network interfaces.
tcpreplay (tcpreplay) - Replay network traffic stored in pcap files
Usage:  tcpreplay [ -<flag> [<val>] | --<name>[{=| }<val>] ]... <pcap_file(s)>

   -q, --quiet                Quiet mode
   -T, --timer=str            Select packet timing mode: select, ioport, gtod, nano
       --maxsleep=num         Sleep for no more then X milliseconds between packets
   -v, --verbose              Print decoded packets via tcpdump to STDOUT
   -A, --decode=str           Arguments passed to tcpdump decoder
   -K, --preload-pcap         Preloads packets into RAM before sending
   -c, --cachefile=str        Split traffic via a tcpprep cache file
   -2, --dualfile             Replay two files at a time from a network tap
   -i, --intf1=str            Client to server/RX/primary traffic output interface
   -I, --intf2=str            Server to client/TX/secondary traffic output interface
       --listnics             List available network interfaces and exit
   -l, --loop=num             Loop through the capture file X times
       --loopdelay-ms=num     Delay between loops in milliseconds
       --pktlen               Override the snaplen and use the actual packet len
   -L, --limit=num            Limit the number of packets to send
       --duration=num         Limit the number of seconds to send
   -x, --multiplier=str       Modify replay speed to a given multiple
   -p, --pps=str              Replay packets at a given packets/sec
   -M, --mbps=str             Replay packets at a given Mbps
   -t, --topspeed             Replay packets as fast as possible
   -o, --oneatatime           Replay one packet at a time for each user input
       --pps-multi=num        Number of packets to send for each time interval
       --unique-ip            Modify IP addresses each loop iteration to generate unique flows
       --unique-ip-loops=str  Number of times to loop before assigning new unique ip
       --netmap               Write packets directly to netmap enabled network adapter
       --nm-delay=num         Netmap startup delay
       --no-flow-stats        Suppress printing and tracking flow count, rates and expirations
       --flow-expiry=num      Number of inactive seconds before a flow is considered expired
   -P, --pid                  Print the PID of tcpreplay at startup
       --stats=num            Print statistics every X seconds, or every loop if '0'
   -V, --version              Print version information
   -h, --less-help            Display less usage information and exit
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
       --save-opts[=arg]      save the option state to a config file
       --load-opts=str        load options from a config file

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
tcpreplay is a tool for replaying network traffic from files saved with
tcpdump or other tools which write pcap(3) files.

Please send bug reports to:  <tcpreplay-users@lists.sourceforge.net>
guijan commented 3 years ago

I'll get working on this. Should the sorting be done exclusively through the long options, or should the short options be considered too?

It would change the ordering because the short and the long forms of some flags start with different letters:

   -A, --decode=str           Arguments passed to tcpdump decoder

It's easy to come up with a mock up using a text editor, so I've made a list of all the options sorted exclusively through their long forms:

--cachefile
--decode
--dualfile
--duration
--flowexpiry
--help
--intf1
--intf2
--lesshelp
--limit
--listnics
--loadopts
--loop
--loopdelayms
--maxsleep
--mbps
--morehelp
--multiplier
--netmap
--nmdelay
--noflowstats
--oneatatime
--pid
--pktlen
--pps
--ppsmulti
--preloadpcap
--quiet
--saveopts
--stats
--timer
--topspeed
--uniqueip
--uniqueiploops
--verbose
--version
fklassen commented 2 years ago

Shelving for now. It seems to be difficult to do this with autogen especially with tcpreplay-edit. Will reopen if someone fixes this without introducing bugs.