feat(tests): IPv6 fixes
[csit.git] / docs / report / introduction / methodology_nat44.rst
1 .. _nat44_methodology:
2
3 Network Address Translation IPv4 to IPv4
4 ----------------------------------------
5
6 NAT44 Prefix Bindings
7 ^^^^^^^^^^^^^^^^^^^^^
8
9 NAT44 prefix bindings should be representative to target applications,
10 where a number of private IPv4 addresses from the range defined by
11 :rfc:`1918` is mapped to a smaller set of public IPv4 addresses from the
12 public range.
13
14 Following quantities are used to describe inside to outside IP address
15 and port bindings scenarios:
16
17 - Inside-addresses, number of inside source addresses
18   (representing inside hosts).
19 - Ports-per-inside-address, number of TCP/UDP source
20   ports per inside source address.
21 - Outside-addresses, number of outside (public) source addresses
22   allocated to NAT44.
23 - Ports-per-outside-address, number of TCP/UDP source
24   ports per outside source address. The maximal number of
25   ports-per-outside-address usable for NAT is 64 512
26   (in non-reserved port range 1024-65535, :rfc:`4787`).
27 - Sharing-ratio, equal to inside-addresses / outside-addresses.
28
29 CSIT NAT44 tests are designed to take into account the maximum number of
30 ports (sessions) required per inside host (inside-address) and at the
31 same time to maximize the use of outside-address range by using all
32 available outside ports. With this in mind, the following scheme of
33 NAT44 sharing ratios has been devised for use in CSIT:
34
35 +--------------------------+---------------+
36 | ports-per-inside-address | sharing-ratio |
37 +==========================+===============+
38 | 63                       | 1024          |
39 +--------------------------+---------------+
40 | 126                      | 512           |
41 +--------------------------+---------------+
42 | 252                      | 256           |
43 +--------------------------+---------------+
44 | 504                      | 128           |
45 +--------------------------+---------------+
46
47 Initial CSIT NAT44 tests, including associated TG/TRex traffic profiles,
48 are based on ports-per-inside-address set to 63 and the sharing ratio of
49 1024. This approach is currently used for all NAT44 tests including
50 NAT44det (NAT44 deterministic used for Carrier Grade NAT applications)
51 and NAT44ed (Endpoint Dependent).
52
53 Private address ranges to be used in tests:
54
55 - 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
56
57   - Total of 2^16 (65 536) of usable IPv4 addresses.
58   - Used in tests for up to 65 536 inside addresses (inside hosts).
59
60 - 172.16.0.0 - 172.31.255.255  (172.16/12 prefix)
61
62   - Total of 2^20 (1 048 576) of usable IPv4 addresses.
63   - Used in tests for up to 1 048 576 inside addresses (inside hosts).
64
65 NAT44 Session Scale
66 ~~~~~~~~~~~~~~~~~~~
67
68 NAT44 session scale tested is govern by the following logic:
69
70 - Number of inside-addresses(hosts) H[i] = (H[i-1] x 2^2) with H(0)=1 024,
71   i = 1,2,3, ...
72
73   - H[i] = 1 024, 4 096, 16 384, 65 536, 262 144, ...
74
75 - Number of sessions S[i] = H[i] * ports-per-inside-address
76
77   - ports-per-inside-address = 63
78
79 +---+---------+------------+
80 | i |   hosts |   sessions |
81 +===+=========+============+
82 | 0 |   1 024 |     64 512 |
83 +---+---------+------------+
84 | 1 |   4 096 |    258 048 |
85 +---+---------+------------+
86 | 2 |  16 384 |  1 032 192 |
87 +---+---------+------------+
88 | 3 |  65 536 |  4 128 768 |
89 +---+---------+------------+
90 | 4 | 262 144 | 16 515 072 |
91 +---+---------+------------+
92
93 NAT44 Deterministic
94 ^^^^^^^^^^^^^^^^^^^
95
96 NAT44det performance tests are using TRex STL (Stateless) API and traffic
97 profiles, similar to all other stateless packet forwarding tests like
98 ip4, ip6 and l2, sending UDP packets in both directions
99 inside-to-outside and outside-to-inside. See
100 :ref:`data_plane_throughput` for more detail.
101
102 The inside-to-outside traffic uses single destination address (20.0.0.0)
103 and port (1024).
104 The inside-to-outside traffic covers whole inside address and port range,
105 the outside-to-inside traffic covers whole outside address and port range.
106
107 NAT44det translation entries are created during the ramp-up phase,
108 followed by verification that all entries are present,
109 before proceeding to the main measurements of the test.
110 This ensures session setup does not impact the forwarding performance test.
111
112 Associated CSIT test cases use the following naming scheme to indicate
113 NAT44det scenario tested:
114
115 - ethip4udp-nat44det-h{H}-p{P}-s{S}-[mrr|ndrpdr|soak]
116
117   - {H}, number of inside hosts, H = 1024, 4096, 16384, 65536, 262144.
118   - {P}, number of ports per inside host, P = 63.
119   - {S}, number of sessions, S = 64512, 258048, 1032192, 4128768,
120     16515072.
121   - [mrr|ndrpdr|soak], MRR, NDRPDR or SOAK test.
122
123 ..
124     TODO: The -s{S} part is redundant,
125     we can save space by removing it.
126     TODO: Make traffic profile names resemble suite names more closely.
127
128 NAT44 Endpoint-Dependent
129 ^^^^^^^^^^^^^^^^^^^^^^^^
130
131 In order to excercise NAT44ed ability to translate based on both
132 source and destination address and port, the inside-to-outside traffic
133 varies also destination address and port. Destination port is the same
134 as source port, destination address has the same offset as the source address,
135 but applied to different subnet (starting with 20.0.0.0).
136
137 As the mapping is not deterministic (for security reasons),
138 we cannot easily use stateless bidirectional traffic profiles.
139 Outside address and port range is fully covered,
140 but we do not know which outside-to-inside source address and port to use
141 to hit an open session of a particular outside address and port.
142
143 Therefore, NAT44ed is benchmarked using following methodologies:
144
145 - Unidirectional throughput using *stateless* traffic profile.
146 - Connections-per-second using *stateful* traffic profile.
147 - Bidirectional PPS (see below) using *stateful* traffic profile.
148 - Bidirectional throughput (see below) using *stateful* traffic profile.
149
150 Unidirectional NAT44ed throughput tests are using TRex STL (Stateless)
151 APIs and traffic profiles, but with packets sent only in
152 inside-to-outside direction.
153 Similarly to NAT44det, NAT44ed unidirectional throughput tests include
154 a ramp-up phase to establish and verify the presence of required NAT44ed
155 binding entries. As the sessions have finite duration, the test code
156 keeps inserting ramp-up trials during the search, if it detects a risk
157 of sessions timing out. Any zero loss trial visits all sessions,
158 so it acts also as a ramp-up.
159
160 Stateful NAT44ed tests are using TRex ASTF (Advanced Stateful) APIs and
161 traffic profiles, with packets sent in both directions. Tests are run
162 with both UDP and TCP/IP sessions.
163 As both NAT44ed CPS (connections-per-second) and PPS (packets-per-second)
164 stateful tests measure (also) session opening performance,
165 they use state reset instead of ramp-up trial.
166 NAT44ed bidirectional throughput tests use the same traffic profile
167 as PPS tests, but also prepend ramp-up trials as in the unidirectional tests,
168 so the test results describe performance without session opening overhead.
169
170 Associated CSIT test cases use the following naming scheme to indicate
171 NAT44det case tested:
172
173 - Stateless: ethip4udp-nat44ed-h{H}-p{P}-s{S}-udir-[mrr|ndrpdr|soak]
174
175   - {H}, number of inside hosts, H = 1024, 4096, 16384, 65536, 262144.
176   - {P}, number of ports per inside host, P = 63.
177   - {S}, number of sessions, S = 64512, 258048, 1032192, 4128768,
178     16515072.
179   - udir-[mrr|ndrpdr|soak], unidirectional stateless tests MRR, NDRPDR
180     or SOAK.
181
182 - Stateful: ethip4[udp|tcp]-nat44ed-h{H}-p{P}-s{S}-[cps|pps|tput]-[mrr|ndrpdr]
183
184   - [udp|tcp], UDP or TCP/IP sessions
185   - {H}, number of inside hosts, H = 1024, 4096, 16384, 65536, 262144.
186   - {P}, number of ports per inside host, P = 63.
187   - {S}, number of sessions, S = 64512, 258048, 1032192, 4128768,
188     16515072.
189   - [cps|pps|tput], connections-per-second session establishment rate or
190     packets-per-second average rate, or packets-per-second rate
191     without session establishment.
192   - [mrr|ndrpdr], bidirectional stateful tests MRR, NDRPDR.
193
194 Stateful traffic profiles
195 ^^^^^^^^^^^^^^^^^^^^^^^^^
196
197 There are several important detais which distinguish ASTF profiles
198 from stateless profiles.
199
200 General considerations
201 ~~~~~~~~~~~~~~~~~~~~~~
202
203 Protocols
204 _________
205
206 ASTF profiles are limited to either UDP or TCP protocol.
207
208 Programs
209 ________
210
211 Each template in the profile defines two "programs", one for client side
212 and one for server side. Each program specifies when that side has to wait
213 until enough data is received (counted in packets for UDP and in bytes for TCP)
214 and when to send additional data. Together, the two programs
215 define a single transaction. Due to packet loss, transaction may take longer,
216 use more packets (retransmission) or never finish in its entirety.
217
218 Instances
219 _________
220
221 Client instance is created according to TPS parameter for the trial,
222 and sends the first packet of the transaction (in some cases more packets).
223 Server instance is created when first packet arrives on server side,
224 each instance has different address or port.
225 When a program reaches its end, the instance is deleted.
226
227 This creates possible issues with server instances. If the server instance
228 does not read all the data client has sent, late data packets
229 can cause second copy of server instance to be created,
230 which breaks assumptions on how many packet a transaction should have.
231
232 The need for server instances to read all the data reduces the overall
233 bandwidth TRex is able to create in ASTF mode.
234
235 Note that client instances are not created on packets,
236 so it is safe to end client program without reading all server data
237 (unless the definition of transaction success requires that).
238
239 Sequencing
240 __________
241
242 ASTF profiles offer two modes for choosing source and destination IP addresses
243 for client programs: seqential and pseudorandom.
244 In current tests we are using sequential addressing only (if destination
245 address varies at all).
246
247 For choosing client source UDP/TCP port, there is only one mode.
248 We have not investigated whether it results in sequential or pseudorandom order.
249
250 For client destination UDP/TCP port, we use a constant value,
251 as typical TRex usage pattern binds the server instances (of the same program)
252 to a single port. (If profile defines multiple server programs, different
253 programs use different ports.)
254
255 Transaction overlap
256 ___________________
257
258 If a transaction takes longer to finish, compared to period implied by TPS,
259 TRex will have multiple client or server instances active at a time.
260
261 During calibration testing we have found this increases CPU utilization,
262 and for high TPS it can lead to TRex's Rx or Tx buffers becoming full.
263 This generally leads to duration stretching, and/or packet loss on TRex.
264
265 Currently used transactions were chosen to be short, so risk of bad behavior
266 is decreased. But in MRR tests, where load is computed based on NIC ability,
267 not TRex ability, anomalous behavior is still possible.
268
269 Delays
270 ______
271
272 TRex supports adding constant delays to ASTF programs.
273 This can be useful, for example if we want to separate connection establishment
274 from data transfer.
275
276 But as TRex tracks delayed instances as active, this still results
277 in higher CPU utilization and reduced performance issues
278 (as other overlaping transactions). So the current tests do not use any delays.
279
280 Keepalives
281 __________
282
283 Both UDP and TCP protocol implementations in TRex programs support keepalive
284 duration. That means there is a configurable period of keepalive time,
285 and TRex sends keepalive packets automatically (outside the program)
286 for the time the program is active (started, not ended yet)
287 but not sending any packets.
288
289 For TCP this is generally not a big deal, as the other side usually
290 retransmits faster. But for UDP it means a packet loss may leave
291 the receiving program running.
292
293 In order to avoid keepalive packets, keepalive value is set to a high number.
294 Here, "high number" means that even at maximum scale and minimum TPS,
295 there are still no keepalive packets sent within the corresponding
296 (computed) trial duration. This number is kept the same also for
297 smaller scale traffic profiles, to simplify maintenance.
298
299 Transaction success
300 ___________________
301
302 The transaction is considered successful at Layer-7 (L7) level
303 when both program instances close. At this point, various L7 counters
304 (unofficial name) are updated on TRex.
305
306 We found that proper close and L7 counter update can be CPU intensive,
307 whereas lower-level counters (ipackets, opackets) called L2 counters
308 can keep up with higher loads.
309
310 For some tests, we do not need to confirm the whole transaction was successful.
311 CPS (connections per second) tests are a typical example.
312 We care only for NAT44ed creating a session (needs one packet in inside-to-outside
313 direction per session) and being able to use it (needs one packet
314 in outside-to-inside direction).
315
316 Similarly in PPS (packets per second, combining session creation
317 with data transfer) tests, we care about NAT44ed ability to forward packets,
318 we do not care whether aplications (TRex) can fully process them at that rate.
319
320 Therefore each type of tests has its own formula (usually just one counter
321 already provided by TRex) to count "successful enough" transactions
322 and attempted transactions. Currently, all tests relying on L7 counters
323 use size-limited profiles, so they know what the count of attempted
324 transactions should be, but due to duration stretching
325 TRex might have been unable to send that many packets.
326 For search purposes, unattempted transactions are treated the same
327 as attemted byt failed transactions.
328
329 Sometimes even the number of transactions as tracked by search algorithm
330 does not match the transactions as defined by ASTF programs.
331 See PPS profiles below.
332
333 UDP CPS
334 ~~~~~~~
335
336 This profile uses a minimalistic transaction to verify NAT44ed session has been
337 created and it allows outside-to-inside traffic.
338
339 Client instance sends one packet and ends.
340 Server instance sends one packet upon creation and ends.
341
342 In principle, packet size is configurable,
343 but currently used tests apply only one value (64 bytes frame).
344
345 Transaction counts as attempted when opackets counter increases on client side.
346 Transaction counts as successful when ipackets counter increases on client side.
347
348 TCP CPS
349 ~~~~~~~
350
351 This profile uses a minimalistic transaction to verify NAT44ed session has been
352 created and it allows outside-to-inside traffic.
353
354 Client initiates TCP connection. Client waits until connection is confirmed
355 (by reading zero data bytes). Client ends.
356 Server accepts the connection. Server waits for indirect confirmation
357 from client (by waiting for client to initiate close). Server ends.
358
359 Without packet loss, the whole transaction takes 7 packets to finish
360 (4 and 3 per direction, respectively).
361 From NAT44ed point of view, only the first two are needed to verify
362 the session got created.
363
364 Packet size is not configurable, but currently used tests report
365 frame size as 64 bytes.
366
367 Transaction counts as attempted when tcps_connattempt counter increases
368 on client side.
369 Transaction counts as successful when tcps_connects counter increases
370 on client side.
371
372 UDP PPS
373 ~~~~~~~
374
375 This profile uses a small transaction of "request-response" type,
376 with several packets simulating data payload.
377
378 Client sends 33 packets and closes immediately.
379 Server reads all 33 packets (needed to avoid late packets creating new
380 server instances), then sends 33 packets and closes.
381 The value 33 was chosen ad-hoc (1 "protocol" packet and 32 "data" packets).
382 It is possible other values would still be safe from avoiding overlapping
383 transactions point of view.
384
385 ..
386     TODO: 32 was chosen as it is a batch size DPDK driver puts on the PCIe bus
387     at a time. May want to verify this with TRex ASTF devs and see if better
388     UDP transaction sizes can be found to yield higher performance out of TRex.
389
390 In principle, packet size is configurable,
391 but currently used tests apply only one value (64 bytes frame)
392 for both "protocol" and "data" packets.
393
394 As this is a PPS tests, we do not track the big 66 packet transaction.
395 Similarly to stateless tests, we treat each packet as a "transaction"
396 for search algorthm purposes. Therefore a "transaction" is attempted
397 when opacket counter on client or server side is increased.
398 Transaction is successful if ipacket counter on client or server side
399 is increased.
400
401 If one of 33 client packets is lost, server instance will get stuck
402 in the reading phase. This probably decreases TRex performance,
403 but it leads to more stable results.
404
405 TCP PPS
406 ~~~~~~~
407
408 This profile uses a small transaction of "request-response" type,
409 with some data size to be transferred both ways.
410
411 Client connects, sends 11111 bytes of data, receives 11111 of data and closes.
412 Server accepts connection, reads 11111 bytes of data, sends 11111 bytes
413 of data and closes.
414 Server read is needed to avoid premature close and second server instance.
415 Client read is not stricly needed, but acks help TRex to close server quickly,
416 thus saving CPU and improving performance.
417
418 The value of 11111 bytes was chosen ad-hoc. It leads to 22 packets
419 (11 each direction) to be exchanged if no loss occurs.
420 In principle, size of data packets is configurable via setting
421 maximum segment size. Currently that is not applied, so the TRex default value
422 (1460 bytes) is used, while the test name still (wrongly) mentions
423 64 byte frame size.
424
425 Exactly as in UDP_PPS, ipackets and opackets counters are used for counting
426 "transactions" (in fact packets).
427
428 If packet loss occurs, there is large transaction overlap, even if most
429 ASTF programs finish eventually. This leads to big duration stretching
430 and somehow uneven rate of packets sent. This makes it hard to interpret
431 MRR results, but NDR and PDR results tend to be stable enough.
432
433 Ip4base tests
434 ^^^^^^^^^^^^^
435
436 Contrary to stateless traffic profiles, we do not have a simple limit
437 that would guarantee TRex is able to send traffic at specified load.
438 For that reason, we have added tests where "nat44ed" is replaced by "ip4base".
439 Instead of NAT44ed processing, the tests set minimalistic IPv4 routes,
440 so that packets are forwarded in both inside-to-outside and outside-to-inside
441 directions.
442
443 The packets arrive to server end of TRex with different source address&port
444 than in NAT44ed tests (no translation to outside values is done with ip4base),
445 but those are not specified in the stateful traffic profiles.
446 The server end uses the received address&port as destination
447 for outside-to-inside traffic. Therefore the same stateful traffic profile
448 works for both NAT44ed and ip4base test (of the same scale).
449
450 The NAT44ed results are displayed together with corresponding ip4base results.
451 If they are similar, TRex is probably the bottleneck.
452 If NAT44ed result is visibly smaller, it describes the real VPP performance.