VPP/How To Use The Packet Generator and Packet Tracer

From fd.io
< VPP
Revision as of 03:00, 9 January 2016 by AustinMarcos (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

The VPP platform includes packet generation and packet tracing facilities.

The following example shows steps that you might typically use to run a debug version of the vpp executable file, generate packets, and to analyze results.

Example with IP4 ARP Messages

In the following steps, the VPP executable does not need to be started with superuser permissions. The VPP executable will not discover physical devices when run as a normal user.

Step 1. Start a debug version of vpp

From the command line, make the build-root directory the working directory and run vpe from the /bin directory as shown in the following example.

In the following example, including the dpdk argument means that no physical interfaces will be discovered.

$ cd .../build-root
$ ./install-vpp_debug-native/vpp/bin/vpe unix interactive dpdk {no-pci no-huge num-mbufs 8192}

Step 2. Execute the arp4 setup script

From the vpp debug command-line, execute the arp4 script.

DBGvpp# exec /home/vagrant/vpp/vnet/etc/scripts/arp4


Step 3. Examine the setup script

Let's tale a look at the contents of the setup script that you just executed. The script .../vpp/vnet/etc/scripts/arp4 contains:

packet-generator new {
  name x
  limit 1
  node ip4-input
  size 64-64
  no-recycle
  data {
    ICMP: 1.0.0.2 -> 2.0.0.2
    ICMP echo_request
    incrementing 100
  }
}
trace add pg-input 100
loop create
loop create
set int state loop0 up
set int state loop1 up

set int ip address loop0 1.0.0.1/24
set int ip address loop1 2.0.0.1/24

The first stanza creates a packet generator stream called "x" which sends a single ipv4 icmp echo-request when enabled. The trace add command arranges to trace 100 packets originating at the pg-input graph node. If you want to trace packets originating at the "dpdk-input" node - which is probably the most typical real-world use-case - make the substitution for that graph node.

Finally, the script configures a couple of loopback interfaces; primarily, so that ip4-input / ip4-lookup won't immediately ditch the generated packet.

Step 4. Generate packets

On the vpp debug command-line, enable the packet generator.

DBGvpp# packet-generator enable


Step 5. Run the packet tracer

Use the show trace command to run the packet tracer.

DBGvpp# show trace
DBGvpp# show trace
------------------- Start of thread 0  -------------------
Packet 1

00:02:37:928917: pg-input
  stream x, 64 bytes
  current data 0, length 64, free-list 2, trace 0x0
  ICMP: 1.0.0.2 -> 2.0.0.2
    tos 0x00, ttl 64, length 64, checksum 0x77ba
    fragment id 0x0000
  ICMP echo_request checksum 0x7a6e
00:02:37:928960: ip4-input
  ICMP: 1.0.0.2 -> 2.0.0.2
    tos 0x00, ttl 64, length 64, checksum 0x77ba
    fragment id 0x0000
  ICMP echo_request checksum 0x7a6e
00:02:37:928979: ip4-arp
  fib: 0 adjacency: arp loop1 2.0.0.1/24 flow hash: 0x00000000
00:02:37:929005: loop1-output
  loop1
  ARP: de:ad:00:00:00:01 -> ff:ff:ff:ff:ff:ff
  request, type ethernet/IP4, address size 6/4
  de:ad:00:00:00:01/2.0.0.1 -> 00:00:00:00:00:00/2.0.0.2
00:02:37:929010: error-drop
  ip4-arp: ARP requests sent
  loop1-output: interface is down

Step 6. Examine the IPv4 default VRF table

Use the show ip fib command to see the VRF table.

Here's the contents of the IPv4 default VRF table after the arp4 script was executed:

DBGvpp# show ip fib
Table 0, fib_index 0, flow hash: src dst sport dport proto 
     Destination         Packets          Bytes         Adjacency   
1.0.0.0/24                         0               0 weight 1, index 3
                                                     arp loop0 1.0.0.1/24
1.0.0.1/32                         0               0 weight 1, index 4
                                                     local 1.0.0.1/24
2.0.0.0/24                         0               0 weight 1, index 5
                                                     arp loop1 2.0.0.1/24
2.0.0.1/32                         0               0 weight 1, index 6
                                                    local 2.0.0.1/24

When we enable the packet generator stream, we observe a lookup hit on 2.0.0.0/24:

DBGvpp# sh ip fib
Table 0, fib_index 0, flow hash: src dst sport dport proto 
     Destination         Packets          Bytes         Adjacency   
1.0.0.0/24                         0               0 weight 1, index 3
                                                     arp loop0 1.0.0.1/24
1.0.0.1/32                         0               0 weight 1, index 4
                                                     local 1.0.0.1/24
2.0.0.0/24                         1              78 weight 1, index 5
                                                     arp loop1 2.0.0.1/24
2.0.0.1/32                         0               0 weight 1, index 6
                                                    local 2.0.0.1/24

Step 7. Analyze the information

Inspecting the error counters you see what we might expect in light of the packet tracer output:

DBGvpp# sh err
     Count                       Node                         Reason       
              1                 ip4-arp                ARP requests sent
              1              loop1-output              interface is down