# P4-KBR: A Key-Based Routing System for P4-Programmable Networks
## 6 Testbed and Experimental Results  
The P4-KBR system was implemented in a virtualized environment. We use Mininet to create network topologies that consist of bmv2 P4 switches and network hosts. Mininet is executed in a Docker container and ONOS controller is launched in other container. P4 Runtime interface is used by ONOS to manage the network elements. With this testbed, we want to verify the correct functionality of the P4 program and the P4-KBR system implementation as a whole and, also, to corroborate the improvement obtained by the P4-based solution compared with the previous OpenFlow-based solution. As a first step, a python-based data plane test framework (PTF) [24] is used to validate the P4 program (see Figure 9). PTF allows programmers the definition of unity tests in devices with P4-Runtime support. For each test, a set of rule(s) is inserted in the bmv2 switch by the PTF. Then, using the Scapy library [25], synthetic packets are created and injected into the P4 bmv2 switch. Finally, PTF checks if packets are forwarded through the expected port according to the program behavior being tested. The main objective of our PTF tests was to verify the correct functionality of the key-based routing. The LPM matching-based implementation which involves the adequate programming of _subtract_sw_  
Figure 8: “Translation of ranges solution”: Tables and actions in the ingress pipeline  
_id_value_ action used in the _pre_key_routing_ table was checked. The RANGE matching-based implementation was also checked. Now, we focus on evaluating the performance of P4-KBR solution in a network controlled by ONOS. The tests were performed on the Abilene network topology (see Figure 10), a well-known topology from the Internet topology zoo [26]. Bmv2 is meant to be used as a tool for developing, testing and debugging P4 data planes and control plane software written for them [20]. As such, the performance of bmv2 (in terms of throughput and latency) is significantly less than that of a production-grade software switch like Open vSwitch, and it also presents some constraints related to the amount of devices used in a virtualized network scenario using mininet and ONOS. Even not being a large topology, results shown below let us to verify the functionality of P4-KBR system and to demonstrate the improvement provided by this proposal over OFC-KBR solution. Figure 11 shows the number of entries in the _key_routing_ table and the _mpls_forward_ table of each bmv2 device. A total of 10 simulations were carried out, assigning a different set of switch identifiers to the nodes for each simulation. The dark green values correspond to the optimal P4-KBR system implementation, that is, using RANGE matching. The light green values correspond to the \"translation of ranges solution\" implementation, using LPM matching. Figure 10: Abilene network topology from the Internet network topology zoo [26]. Figure 9: Unity test environment using the Plane Test Framework (PTF). As expected, in the first case, the number of _key_routing_ table entries is 32, being L = 32 the number of bits used to define the virtual id space. With the RANGE matching type, each of the obtained ranges (which are generally described in Figure 2) and their associated actions just require a table entry independently of the range limits. In the second case, the number of the _key_routing_ table's entries is also close to 32, but it is a bit larger. The last L \(-\) 1 ranges (that is, from range \([n+2^{0},n+2^{1}[\) to range \([n+2^{L-2},n+2^{L-1}[\) range) are translated to an equivalent bitmasked range (that is, range \([2^{0},2^{1}[\) to range \([2^{L-2},2^{L-1}[\) range) which just require a table entry for each one. However, the first two ranges, which involve the node's predecessor in their limits, cannot be expressed as bitmasked ranges despite the range movement. The prefix expansion algorithm is applied to convert them into a set of bitmasked ranges.