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