Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 1 | Generating traffic with VPP |
| 2 | =========================== |
| 3 | |
| 4 | Vpp includes a fairly capable network simulator plugin, which can |
| 5 | simulate real-world round-trip times and a configurable network packet |
| 6 | loss rate. It’s perfect for evaluating the performance of a TCP stack |
| 7 | under specified delay/bandwidth/loss conditions. |
| 8 | |
| 9 | The “nsim” plugin cross-connects two physical interfaces at layer 2, |
| 10 | introducing the specified delay and network loss parameters. |
| 11 | Reconfiguration on the fly is OK, with the proviso that packets held in |
| 12 | the network simulator scheduling wheel will be lost. |
| 13 | |
| 14 | Configuration |
| 15 | ------------- |
| 16 | |
| 17 | Configuration by debug CLI is simple. First, specify the simulator |
| 18 | configuration: unidirectional delay (half of the desired RTT), the link |
| 19 | bandwidth, and the expected average packet size. These parameters allow |
| 20 | the network simulator allocate the right amount of buffering to produce |
| 21 | the requested delay/bandwidth product. |
| 22 | |
| 23 | :: |
| 24 | |
| 25 | set nsim delay 25.0 ms bandwidth 10 gbit packet-size 128 |
| 26 | |
| 27 | To simulate network packet drops, add either “packets-per-drop ” or |
| 28 | “drop-fraction [0.0 … 1.0]” parameters: |
| 29 | |
| 30 | :: |
| 31 | |
| 32 | set nsim delay 25.0 ms bandwidth 10 gbit packet-size 128 packets-per-drop 10000 |
| 33 | |
| 34 | Remember to configure the layer-2 cross-connect: |
| 35 | |
| 36 | :: |
| 37 | |
| 38 | nsim enable-disable <interface-1> <interface-2> |
| 39 | |
| 40 | Packet Generator Configuration |
| 41 | ------------------------------ |
| 42 | |
| 43 | Here’s a unit-test configuration for the vpp packet generator: |
| 44 | |
| 45 | :: |
| 46 | |
| 47 | loop cre |
| 48 | set int ip address loop0 11.22.33.1/24 |
| 49 | set int state loop0 up |
| 50 | |
| 51 | loop cre |
| 52 | set int ip address loop1 11.22.34.1/24 |
| 53 | set int state loop1 up |
| 54 | |
| 55 | set nsim delay 1.0 ms bandwidth 10 gbit packet-size 128 packets-per-drop 1000 |
| 56 | nsim enable-disable loop0 loop1 |
| 57 | |
| 58 | packet-generator new { |
| 59 | name s0 |
| 60 | limit 10000 |
| 61 | size 128-128 |
| 62 | interface loop0 |
| 63 | node ethernet-input |
| 64 | data { IP4: 1.2.3 -> 4.5.6 |
| 65 | UDP: 11.22.33.44 -> 11.22.34.44 |
| 66 | UDP: 1234 -> 2345 |
| 67 | incrementing 114 |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | For extra realism, the network simulator drops any specific packet with |
| 72 | the specified probability. In this example, we see that slight variation |
| 73 | from run to run occurs as it should. |
| 74 | |
| 75 | :: |
| 76 | |
| 77 | DBGvpp# pa en |
| 78 | DBGvpp# sh err |
| 79 | Count Node Reason |
| 80 | 9991 nsim Packets buffered |
| 81 | 9 nsim Network loss simulation drop packets |
| 82 | 9991 ethernet-input l3 mac mismatch |
| 83 | |
| 84 | DBGvpp# clear err |
| 85 | DBGvpp# pa en |
| 86 | DBGvpp# sh err |
| 87 | sh err |
| 88 | Count Node Reason |
| 89 | 9993 nsim Packets buffered |
| 90 | 7 nsim Network loss simulation drop packets |
| 91 | 9993 ethernet-input l3 mac mismatch |