b4ac79810d8fd163d835c7733f262dde0ae1ce7f
[netvirt.git] / docs / specs / element-counters.rst
1 ounters
2 ==============================================================
3
4 https://git.opendaylight.org/gerrit/#/q/spec-for-element-to-element-counters
5
6 This feature depends on the Netvirt statistics feature.
7
8 This feature enables collecting statistics on filtered traffic passed from/to a network element. For example: traffic outgoing/incoming from a specific IP, tcp traffic, udp traffic, incoming/outgoing traffic only.
9
10 Problem description
11 ===================
12
13 Collecting statistics on filtered traffic sent to/from a VM is currently not possible.
14
15 Use Cases
16 ---------
17
18 - Tracking East/West communication between local VMs.
19 - Tracking East/West communication between VMs that are located in different compute nodes.
20 - Tracking communication between a local VM and an IP located in an external network.
21 - Tracking TCP/UDP traffic sent from/to a VM.
22 - Tracking dropped packets between 2 VMs.
23
24 Proposed change
25 ===============
26
27 The Netvirt Statistics Plugin will receive requests regarding element filtered counters.
28 A new service will be implemented ("CounterService"), and will be associated with the relevant interfaces (either ingress side, egress sides or both of them).
29
30 * Ingress traffic: The service will be the first one in the pipeline after the Ingress ACL service.
31 * Egress traffic: The service will be the last one after the Egress ACL service.
32 * The input for counters request regarding VM A, and incoming and outgoing traffic from VM B, will be VM A interface uuid and VM B IP.
33 * The input can also include other filters like TCP only traffic, UDP only traffic, incoming/outgoing traffic.
34 * In order to track dropped traffic between VM A and VM B, the feature should be activated on both VMS (either in the same compute node or in different compute nodes). service binding will be done on both VMs relevant interfaces.
35 * If the counters request involves an external IP, service binding will be done only on the VM interface.
36 * Adding/Removing the "CounterService" should be dynamic and triggered by requesting element counters.
37
38
39 The Statistics Plugin will use OpenFlow flow statistic requests for these new rules,
40 allowing it to gather statistics regarding the traffic between the 2 elements.
41 It will be responsible to validate and filter the counters results.
42
43 Pipeline changes
44 ----------------
45
46 Two new tables will be used: table 219 for outgoing traffic from the VM, and table 249 for incoming traffic from the VM.
47 In both ingress and egress pipelines, the counter service will be just after the appropriate ACL service.
48 The default rule will resubmit traffic to the appropriate dispatcher table.
49
50 Assuming we want statistics on VM A traffic, received or sent from VM B.
51
52 VM A Outgoing Traffic (vm interface)
53 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54 In table 219 traffic will be matched against dst-ip and lport tag.
55
56   | Ingress dispatcher table (17): ``match: lport-tag=vmA-interface, actions: go to table 219`` =>
57   | Ingress counters table  (219): ``match: dst-ip=vmB-ip, lport-tag=vmA-interface, actions: resubmit to table 17`` =>
58
59 VM A Incoming Traffic (vm interface)
60 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61 In table 249 traffic will be matched against src-ip and lport tag.
62
63   | Egress dispatcher table (220): ``match: lport-tag=vmA-interface, actions: go to table 249`` =>
64   | Egress counters table (249): ``match: lport-tag=vmA-interface, src-ip=vmB-ip, actions: resubmit to table 220`` =>
65
66 Assuming we want statistics on VM A incoming TCP traffic.
67
68 VM A Outgoing Traffic (vm interface)
69 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70
71   | Egress dispatcher table (220): ``match: lport-tag=vmA-interface, actions: go to table 249`` =>
72   | Egress counters table (249): ``match: lport-tag=vmA-interface, tcp, actions: resubmit to table 220`` =>
73
74 Assuming we want statistics on VM A outgoing UDP traffic.
75
76 VM A Incoming traffic (vm interface)
77 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78
79    | Ingress dispatcher table (17): ``match: lport-tag=vmA-interface, actions: go to table 219`` =>
80    | Ingress counters table  (219): ``match: lport-tag=vmA-interface, udp, actions: resubmit to table 17`` =>
81
82 Assuming we want statistics on all traffic sent to VM A port.
83
84 VM A Incoming traffic (vm interface)
85 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
87    | Ingress dispatcher table (17): ``match: lport-tag=vmA-interface, actions: go to table 219`` =>
88    | Ingress counters table  (219): ``match: lport-tag=vmA-interface, actions: resubmit to table 17`` =>
89
90 Yang changes
91 ---------------
92 Netvirt Statistics module will be enhanced with the following RPC:
93 ::
94
95     grouping result {
96         list counterResult {
97             key id;
98             leaf id {
99                 type string;
100             }
101             list groups {
102                 key name;
103                 leaf name {
104                     type string;
105                 }
106                 list counters {
107                     key name;
108                     leaf name {
109                         type string;
110                     }
111                     leaf value {
112                         type uint64;
113                     }
114                 }
115             }
116         }
117     }
118
119     grouping filters {
120         leaf-list groupFilters {
121             type string;
122         }
123         leaf-list counterFilter {
124             type string;
125         }
126     }
127
128     grouping elementRequestData {
129         container filters {
130                 container tcpFilter {
131                 leaf on {
132                     type boolean;
133                 }
134                 leaf srcPort {
135                     type int32;
136                     default -1;
137                 }
138                 leaf dstPort {
139                     type int32;
140                     default -1;
141                 }
142             }
143
144             container udpFilter {
145                 leaf on {
146                     type boolean;
147                 }
148                 leaf dstPort {
149                     type int32;
150                     default -1;
151                 }
152                 leaf srcPort {
153                     type int32;
154                     default -1;
155                 }
156             }
157
158             container ipFilter {
159                 leaf ip {
160                     type string;
161                     default "";
162                 }
163             }
164         }
165     }
166
167     container elementCountersRequestConfig {
168         list counterRequests {
169             key "requestId";
170             leaf requestId {
171                 type string;
172             }
173             leaf lportTag {
174                 type int32;
175             }
176             leaf dpn {
177                 type uint64;
178             }
179             leaf portId {
180                 type string;
181             }
182             leaf trafficDirection {
183                 type string;
184             }
185             uses elementRequestData;
186         }
187     }
188
189     rpc acquireElementCountersRequestHandler {
190         input {
191             leaf portId {
192                 type string;
193             }
194             container incomingTraffic {
195                 uses elementRequestData;
196             }
197             container outgoingTraffic {
198                 uses elementRequestData;
199             }
200             uses filters;
201         }
202         output {
203             leaf incomingTrafficHandler {
204                 type string;
205             }
206             leaf outcoingTrafficHandler {
207                 type string;
208             }
209         }
210     }
211
212     rpc releaseElementCountersRequestHandler {
213         input {
214             leaf handler {
215                 type string;
216             }
217         }
218         output {
219         }
220     }
221
222     rpc getElementCountersByHandler {
223         input {
224             leaf handler {
225                 type string;
226             }
227         }
228         output {
229             uses result;
230         }
231     }
232
233 Configuration impact
234 ---------------------
235 The described above YANG model will be saved in the data store.
236
237 Clustering considerations
238 -------------------------
239 None
240
241 Other Infra considerations
242 --------------------------
243 None
244
245 Security considerations
246 -----------------------
247 None
248
249 Scale and Performance Impact
250 ----------------------------
251 Since adding the new service is done by a request (as well as removing it), not all packets will be sent to the new tables described above.
252
253 Targeted Release
254 -----------------
255 Carbon
256
257 Alternatives
258 ------------
259 None
260
261 Usage
262 =====
263
264 * Create router, network, 2 VMS, VXLAN tunnel.
265 * Connect to each one of the VMs and send ping to the other VM.
266 * Use REST to get the statistics.
267
268 Run the following to get interface ids:
269
270 .. code-block:: json
271
272     http://10.0.77.135:8181/restconf/operational/ietf-interfaces:interfaces-state/
273
274 Choose VM B interface and use the following REST in order to get the statistics:
275 Assuming VM A IP = 1.1.1.1, VM B IP = 2.2.2.2
276
277 Acquire counter request handler:
278
279 .. code-block:: json
280
281     10.0.77.135:8181/restconf/operations/statistics-plugin:acquireElementCountersRequestHandler, {"input":{"portId":"4073b4fe-a3d5-47c0-b37d-4fb9db4be9b1", "incomingTraffic":{"filters":{"ipFilter":{"ip":"1.1.3.9"}}}}}, headers={Authorization=Basic YWRtaW46YWRtaW4=, Cache-Control=no-cache, Content-Type=application/json}]
282
283 Release handler:
284
285 .. code-block:: json
286
287     10.0.77.135:8181/restconf/operations/statistics-plugin:releaseElementCountersRequestHandler, input={"input":{"handler":"1"}}, headers={Authorization=Basic YWRtaW46YWRtaW4=, Cache-Control=no-cache, Content-Type=application/json}]
288
289 Get counters:
290
291 .. code-block:: json
292
293     10.0.77.135:8181/restconf/operations/statistics-plugin:getElementCountersByHandler, input={"input":{"handler":"1"}}, headers={Authorization=Basic YWRtaW46YWRtaW4=, Cache-Control=no-cache, Content-Type=application/json}]
294
295 Example counters output:
296
297 .. code-block:: json
298
299     {
300   "output": {
301     "counterResult": [
302       {
303         "id": "SOME UNIQUE ID",
304         "groups": [
305           {
306             "name": "Duration",
307             "counters": [
308               {
309                 "name": "durationNanoSecondCount",
310                 "value": 298000000
311               },
312               {
313                 "name": "durationSecondCount",
314                 "value": 10369
315               }
316             ]
317           },
318           {
319             "name": "Bytes",
320             "counters": [
321               {
322                 "name": "bytesTransmittedCount",
323                 "value": 648
324               },
325               {
326                 "name": "bytesReceivedCount",
327                 "value": 0
328               }
329             ]
330           },
331           {
332             "name": "Packets",
333             "counters": [
334               {
335                 "name": "packetsTransmittedCount",
336                 "value": 8
337               },
338               {
339                 "name": "packetsReceivedCount",
340                 "value": 0
341               }
342             ]
343           }
344         ]
345       }
346     ]
347   }
348
349 Features to Install
350 -------------------
351 odl-netvirt-openstack
352
353 REST API
354 --------
355
356 CLI
357 ---
358
359
360 Implementation
361 ==============
362
363 Assignee(s)
364 -----------
365
366 Primary assignee:
367   Guy Regev <guy.regev@hpe.com>
368
369 Other contributors:
370   TBD
371
372
373 Work Items
374 ----------
375 https://trello.com/c/88MnwGwb/129-element-to-element-counters
376
377 * Add new service in Genius.
378 * Implement new rules installation.
379 * Update Netvirt Statistics module to support the new counters request.
380
381 Dependencies
382 ============
383
384 None
385
386 Testing
387 =======
388
389 Unit Tests
390 ----------
391
392 Integration Tests
393 -----------------
394
395 CSIT
396 ----
397
398 Documentation Impact
399 ====================
400
401 References
402 ==========
403
404 Netvirt statistics feature: https://git.opendaylight.org/gerrit/#/c/50164/8
405
406
407