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