2 Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
15 * Neither the name of Intel Corporation nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 QoS Metering Sample Application
32 ===============================
34 The QoS meter sample application is an example that demonstrates the use of DPDK to provide QoS marking and metering,
35 as defined by RFC2697 for Single Rate Three Color Marker (srTCM) and RFC 2698 for Two Rate Three Color Marker (trTCM) algorithm.
40 The application uses a single thread for reading the packets from the RX port,
41 metering, marking them with the appropriate color (green, yellow or red) and writing them to the TX port.
43 A policing scheme can be applied before writing the packets to the TX port by dropping or
44 changing the color of the packet in a static manner depending on both the input and output colors of the packets that are processed by the meter.
46 The operation mode can be selected as compile time out of the following options:
58 Please refer to RFC2697 and RFC2698 for details about the srTCM and trTCM configurable parameters
59 (CIR, CBS and EBS for srTCM; CIR, PIR, CBS and PBS for trTCM).
61 The color blind modes are functionally equivalent with the color-aware modes when
62 all the incoming packets are colored as green.
64 Compiling the Application
65 -------------------------
67 #. Go to the example directory:
69 .. code-block:: console
71 export RTE_SDK=/path/to/rte_sdk
72 cd ${RTE_SDK}/examples/qos_meter
75 (a default target is used if not specified):
79 This application is intended as a linuxapp only.
81 .. code-block:: console
83 export RTE_TARGET=x86_64-native-linuxapp-gcc
85 #. Build the application:
87 .. code-block:: console
91 Running the Application
92 -----------------------
94 The application execution command line is as below:
96 .. code-block:: console
98 ./qos_meter [EAL options] -- -p PORTMASK
100 The application is constrained to use a single core in the EAL core mask and 2 ports only in the application port mask
101 (first port from the port mask is used for RX and the other port in the core mask is used for TX).
103 Refer to *DPDK Getting Started Guide* for general information on running applications and
104 the Environment Abstraction Layer (EAL) options.
109 Selecting one of the metering modes is done with these defines:
113 #define APP_MODE_FWD 0
114 #define APP_MODE_SRTCM_COLOR_BLIND 1
115 #define APP_MODE_SRTCM_COLOR_AWARE 2
116 #define APP_MODE_TRTCM_COLOR_BLIND 3
117 #define APP_MODE_TRTCM_COLOR_AWARE 4
119 #define APP_MODE APP_MODE_SRTCM_COLOR_BLIND
121 To simplify debugging (for example, by using the traffic generator RX side MAC address based packet filtering feature),
122 the color is defined as the LSB byte of the destination MAC address.
124 The traffic meter parameters are configured in the application source code with following default values:
128 struct rte_meter_srtcm_params app_srtcm_params[] = {
130 {.cir = 1000000 * 46, .cbs = 2048, .ebs = 2048},
134 struct rte_meter_trtcm_params app_trtcm_params[] = {
136 {.cir = 1000000 * 46, .pir = 1500000 * 46, .cbs = 2048, .pbs = 2048},
140 Assuming the input traffic is generated at line rate and all packets are 64 bytes Ethernet frames (IPv4 packet size of 46 bytes)
141 and green, the expected output traffic should be marked as shown in the following table:
143 .. _table_qos_metering_1:
145 .. table:: Output Traffic Marking
147 +-------------+------------------+-------------------+----------------+
148 | **Mode** | **Green (Mpps)** | **Yellow (Mpps)** | **Red (Mpps)** |
150 +=============+==================+===================+================+
151 | srTCM blind | 1 | 1 | 12.88 |
153 +-------------+------------------+-------------------+----------------+
154 | srTCM color | 1 | 1 | 12.88 |
156 +-------------+------------------+-------------------+----------------+
157 | trTCM blind | 1 | 0.5 | 13.38 |
159 +-------------+------------------+-------------------+----------------+
160 | trTCM color | 1 | 0.5 | 13.38 |
162 +-------------+------------------+-------------------+----------------+
163 | FWD | 14.88 | 0 | 0 |
165 +-------------+------------------+-------------------+----------------+
167 To set up the policing scheme as desired, it is necessary to modify the main.h source file,
168 where this policy is implemented as a static structure, as follows:
172 int policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
175 { DROP, YELLOW, RED},
179 Where rows indicate the input color, columns indicate the output color,
180 and the value that is stored in the table indicates the action to be taken for that particular case.
182 There are four different actions:
184 * GREEN: The packet's color is changed to green.
186 * YELLOW: The packet's color is changed to yellow.
188 * RED: The packet's color is changed to red.
190 * DROP: The packet is dropped.
192 In this particular case:
194 * Every packet which input and output color are the same, keeps the same color.
196 * Every packet which color has improved is dropped (this particular case can't happen, so these values will not be used).
198 * For the rest of the cases, the color is changed to red.