pktgen_bench_xmit_mode_queue_xmit.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. #
  3. # Benchmark script:
  4. # - developed for benchmarking egress qdisc path, derived (more
  5. # like cut'n'pasted) from ingress benchmark script.
  6. #
  7. # Script for injecting packets into egress qdisc path of the stack
  8. # with pktgen "xmit_mode queue_xmit".
  9. #
  10. basedir=`dirname $0`
  11. source ${basedir}/functions.sh
  12. root_check_run_with_sudo "$@"
  13. # Parameter parsing via include
  14. source ${basedir}/parameters.sh
  15. if [ -z "$DEST_IP" ]; then
  16. [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
  17. fi
  18. [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
  19. # Burst greater than 1 are invalid for queue_xmit mode
  20. if [[ -n "$BURST" ]]; then
  21. err 1 "Bursting not supported for this mode"
  22. fi
  23. # Base Config
  24. DELAY="0" # Zero means max speed
  25. COUNT="10000000" # Zero means indefinitely
  26. # General cleanup everything since last run
  27. pg_ctrl "reset"
  28. # Threads are specified with parameter -t value in $THREADS
  29. for ((thread = 0; thread < $THREADS; thread++)); do
  30. # The device name is extended with @name, using thread number to
  31. # make then unique, but any name will do.
  32. dev=${DEV}@${thread}
  33. # Add remove all other devices and add_device $dev to thread
  34. pg_thread $thread "rem_device_all"
  35. pg_thread $thread "add_device" $dev
  36. # Base config of dev
  37. pg_set $dev "flag QUEUE_MAP_CPU"
  38. pg_set $dev "count $COUNT"
  39. pg_set $dev "pkt_size $PKT_SIZE"
  40. pg_set $dev "delay $DELAY"
  41. pg_set $dev "flag NO_TIMESTAMP"
  42. # Destination
  43. pg_set $dev "dst_mac $DST_MAC"
  44. pg_set $dev "dst$IP6 $DEST_IP"
  45. # Inject packet into TX qdisc egress path of stack
  46. pg_set $dev "xmit_mode queue_xmit"
  47. done
  48. # start_run
  49. echo "Running... ctrl^C to stop" >&2
  50. pg_ctrl "start"
  51. echo "Done" >&2
  52. # Print results
  53. for ((thread = 0; thread < $THREADS; thread++)); do
  54. dev=${DEV}@${thread}
  55. echo "Device: $dev"
  56. cat /proc/net/pktgen/$dev | grep -A2 "Result:"
  57. done