1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2010-2014 Intel Corporation.
4 QoS Metering Sample Application
5 ===============================
7 The QoS meter sample application is an example that demonstrates the use of DPDK to provide QoS marking and metering,
8 as defined by RFC2697 for Single Rate Three Color Marker (srTCM) and RFC 2698 for Two Rate Three Color Marker (trTCM) algorithm.
13 The application uses a single thread for reading the packets from the RX port,
14 metering, marking them with the appropriate color (green, yellow or red) and writing them to the TX port.
16 A policing scheme can be applied before writing the packets to the TX port by dropping or
17 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.
19 The operation mode can be selected as compile time out of the following options:
31 Please refer to RFC2697 and RFC2698 for details about the srTCM and trTCM configurable parameters
32 (CIR, CBS and EBS for srTCM; CIR, PIR, CBS and PBS for trTCM).
34 The color blind modes are functionally equivalent with the color-aware modes when
35 all the incoming packets are colored as green.
37 Compiling the Application
38 -------------------------
40 To compile the sample application see :doc:`compiling`.
42 The application is located in the ``qos_meter`` sub-directory.
44 Running the Application
45 -----------------------
47 The application execution command line is as below:
49 .. code-block:: console
51 ./qos_meter [EAL options] -- -p PORTMASK
53 The application is constrained to use a single core in the EAL core mask and 2 ports only in the application port mask
54 (first port from the port mask is used for RX and the other port in the core mask is used for TX).
56 Refer to *DPDK Getting Started Guide* for general information on running applications and
57 the Environment Abstraction Layer (EAL) options.
62 Selecting one of the metering modes is done with these defines:
66 #define APP_MODE_FWD 0
67 #define APP_MODE_SRTCM_COLOR_BLIND 1
68 #define APP_MODE_SRTCM_COLOR_AWARE 2
69 #define APP_MODE_TRTCM_COLOR_BLIND 3
70 #define APP_MODE_TRTCM_COLOR_AWARE 4
72 #define APP_MODE APP_MODE_SRTCM_COLOR_BLIND
74 To simplify debugging (for example, by using the traffic generator RX side MAC address based packet filtering feature),
75 the color is defined as the LSB byte of the destination MAC address.
77 The traffic meter parameters are configured in the application source code with following default values:
81 struct rte_meter_srtcm_params app_srtcm_params[] = {
83 {.cir = 1000000 * 46, .cbs = 2048, .ebs = 2048},
87 struct rte_meter_trtcm_params app_trtcm_params[] = {
89 {.cir = 1000000 * 46, .pir = 1500000 * 46, .cbs = 2048, .pbs = 2048},
93 Assuming the input traffic is generated at line rate and all packets are 64 bytes Ethernet frames (IPv4 packet size of 46 bytes)
94 and green, the expected output traffic should be marked as shown in the following table:
96 .. _table_qos_metering_1:
98 .. table:: Output Traffic Marking
100 +-------------+------------------+-------------------+----------------+
101 | **Mode** | **Green (Mpps)** | **Yellow (Mpps)** | **Red (Mpps)** |
103 +=============+==================+===================+================+
104 | srTCM blind | 1 | 1 | 12.88 |
106 +-------------+------------------+-------------------+----------------+
107 | srTCM color | 1 | 1 | 12.88 |
109 +-------------+------------------+-------------------+----------------+
110 | trTCM blind | 1 | 0.5 | 13.38 |
112 +-------------+------------------+-------------------+----------------+
113 | trTCM color | 1 | 0.5 | 13.38 |
115 +-------------+------------------+-------------------+----------------+
116 | FWD | 14.88 | 0 | 0 |
118 +-------------+------------------+-------------------+----------------+
120 To set up the policing scheme as desired, it is necessary to modify the main.h source file,
121 where this policy is implemented as a static structure, as follows:
125 int policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
128 { DROP, YELLOW, RED},
132 Where rows indicate the input color, columns indicate the output color,
133 and the value that is stored in the table indicates the action to be taken for that particular case.
135 There are four different actions:
137 * GREEN: The packet's color is changed to green.
139 * YELLOW: The packet's color is changed to yellow.
141 * RED: The packet's color is changed to red.
143 * DROP: The packet is dropped.
145 In this particular case:
147 * Every packet which input and output color are the same, keeps the same color.
149 * Every packet which color has improved is dropped (this particular case can't happen, so these values will not be used).
151 * For the rest of the cases, the color is changed to red.