align dhcp yang model in the spec with implementation
[netvirt.git] / docs / specs / 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:: json
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
285     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}]
286
287 Release handler:
288
289 .. code-block:: json
290
291     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}]
292
293 Get counters:
294
295 .. code-block:: json
296
297     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}]
298
299 Example counters output:
300
301 .. code-block:: json
302
303     {
304   "output": {
305     "counterResult": [
306       {
307         "id": "SOME UNIQUE ID",
308         "groups": [
309           {
310             "name": "Duration",
311             "counters": [
312               {
313                 "name": "durationNanoSecondCount",
314                 "value": 298000000
315               },
316               {
317                 "name": "durationSecondCount",
318                 "value": 10369
319               }
320             ]
321           },
322           {
323             "name": "Bytes",
324             "counters": [
325               {
326                 "name": "bytesTransmittedCount",
327                 "value": 648
328               },
329               {
330                 "name": "bytesReceivedCount",
331                 "value": 0
332               }
333             ]
334           },
335           {
336             "name": "Packets",
337             "counters": [
338               {
339                 "name": "packetsTransmittedCount",
340                 "value": 8
341               },
342               {
343                 "name": "packetsReceivedCount",
344                 "value": 0
345               }
346             ]
347           }
348         ]
349       }
350     ]
351   }
352
353 Features to Install
354 -------------------
355 odl-netvirt-openstack
356
357 REST API
358 --------
359
360 CLI
361 ---
362
363
364 Implementation
365 ==============
366
367 Assignee(s)
368 -----------
369
370 Primary assignee:
371   Guy Regev <guy.regev@hpe.com>
372
373 Other contributors:
374   TBD
375
376
377 Work Items
378 ----------
379 https://trello.com/c/88MnwGwb/129-element-to-element-counters
380
381 * Add new service in Genius.
382 * Implement new rules installation.
383 * Update Netvirt Statistics module to support the new counters request.
384
385 Dependencies
386 ============
387
388 None
389
390 Testing
391 =======
392
393 Unit Tests
394 ----------
395
396 Integration Tests
397 -----------------
398
399 CSIT
400 ----
401
402 Documentation Impact
403 ====================
404
405 References
406 ==========
407
408 Netvirt statistics feature: https://git.opendaylight.org/gerrit/#/c/50164/8
409
410
411