ba12f7d49b0b6eb6ca9dd3c9f09bc43dbb994134
[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 ..
132     TODO: Is it possible to test a NAT44ed scenario where the outside source
133     address and port is limited to just one value?
134     In theory, as long as every inside source address&port traffic
135     uses a different destination address&port, there will be no conflicts,
136     and we could use bidirectional stateless profiles.
137     Possibly, VPP requires some amount of outside source address&port
138     to remain unused for security reasons. But we can try to see what happens.
139
140 In order to excercise NAT44ed ability to translate based on both
141 source and destination address and port, the inside-to-outside traffic
142 varies also destination address and port. Destination port is the same
143 as source port, destination address has the same offset as the source address,
144 but applied to different subnet (starting with 20.0.0.0).
145
146 As the mapping is not deterministic (for security reasons),
147 we cannot easily use stateless bidirectional traffic profiles.
148 Outside address and port range is fully covered,
149 but we do not know which outside-to-inside source address and port to use
150 to hit an open session of a particular outside address and port.
151
152 Therefore, NAT44ed is benchmarked using following methodologies:
153
154 - Unidirectional throughput using *stateless* traffic profile.
155 - Connections-per-second using *stateful* traffic profile.
156 - Bidirectional PPS (see below) using *stateful* traffic profile.
157
158 Unidirectional NAT44ed throughput tests are using TRex STL (Stateless)
159 APIs and traffic profiles, but with packets sent only in
160 inside-to-outside direction.
161 Similarly to NAT44det, NAT44ed unidirectional throughput tests include
162 a ramp-up phase to establish and verify the presence of required NAT44ed
163 binding entries.
164
165 Stateful NAT44ed tests are using TRex ASTF (Advanced Stateful) APIs and
166 traffic profiles, with packets sent in both directions. Tests are run
167 with both UDP and TCP/IP sessions.
168 As both NAT44ed CPS (connections-per-second) and PPS (packets-per-second)
169 stateful tests measure (also) session opening performance,
170 they use state reset instead of ramp-up trial.
171 That is also the reason why PPS tests are not called throughput tests.
172
173 Associated CSIT test cases use the following naming scheme to indicate
174 NAT44det case tested:
175
176 - Stateless: ethip4udp-nat44ed-h{H}-p{P}-s{S}-udir-[mrr|ndrpdr|soak]
177
178   - {H}, number of inside hosts, H = 1024, 4096, 16384, 65536, 262144.
179   - {P}, number of ports per inside host, P = 63.
180   - {S}, number of sessions, S = 64512, 258048, 1032192, 4128768,
181     16515072.
182   - udir-[mrr|ndrpdr|soak], unidirectional stateless tests MRR, NDRPDR
183     or SOAK.
184
185 - Stateful: ethip4[udp|tcp]-nat44ed-h{H}-p{P}-s{S}-[cps|pps]-[mrr|ndrpdr]
186
187   - [udp|tcp], UDP or TCP/IP sessions
188   - {H}, number of inside hosts, H = 1024, 4096, 16384, 65536, 262144.
189   - {P}, number of ports per inside host, P = 63.
190   - {S}, number of sessions, S = 64512, 258048, 1032192, 4128768,
191     16515072.
192   - [cps|pps], connections-per-second session establishment rate or
193     packets-per-second average rate.
194   - [mrr|ndrpdr], bidirectional stateful tests MRR, NDRPDR.
195
196 Stateful traffic profiles
197 ^^^^^^^^^^^^^^^^^^^^^^^^^
198
199 There are several important detais which distinguish ASTF profiles
200 from stateless profiles.
201
202 General considerations
203 ~~~~~~~~~~~~~~~~~~~~~~
204
205 Protocols
206 _________
207
208 ASTF profiles are limited to either UDP or TCP protocol.
209
210 Programs
211 ________
212
213 Each template in the profile defines two "programs", one for client side
214 and one for server side. Each program specifies when that side has to wait
215 until enough data is received (counted in packets for UDP and in bytes for TCP)
216 and when to send additional data. Together, the two programs
217 define a single transaction. Due to packet loss, transaction may take longer,
218 use more packets (retransmission) or never finish in its entirety.
219
220 Instances
221 _________
222
223 Client instance is created according to TPS parameter for the trial,
224 and sends the first packet of the transaction (in some cases more packets).
225 Server instance is created when first packet arrives on server side,
226 each instance has different address or port.
227 When a program reaches its end, the instance is deleted.
228
229 This creates possible issues with server instances. If the server instance
230 does not read all the data client has sent, late data packets
231 can cause second copy of server instance to be created,
232 which breaks assumptions on how many packet a transaction should have.
233
234 The need for server instances to read all the data reduces the overall
235 bandwidth TRex is able to create in ASTF mode.
236
237 Note that client instances are not created on packets,
238 so it is safe to end client program without reading all server data
239 (unless the definition of transaction success requires that).
240
241 Sequencing
242 __________
243
244 ASTF profiles offer two modes for choosing source and destination IP addresses
245 for client programs: seqential and pseudorandom.
246 In current tests we are using sequential addressing only (if destination
247 address varies at all).
248
249 For choosing client source UDP/TCP port, there is only one mode.
250 We have not investigated whether it results in sequential or pseudorandom order.
251
252 For client destination UDP/TCP port, we use a constant value,
253 as typical TRex usage pattern binds the server instances (of the same program)
254 to a single port. (If profile defines multiple server programs, different
255 programs use different ports.)
256
257 Transaction overlap
258 ___________________
259
260 If a transaction takes longer to finish, compared to period implied by TPS,
261 TRex will have multiple client or server instances active at a time.
262
263 During calibration testing we have found this increases CPU utilization,
264 and for high TPS it can lead to TRex's Rx or Tx buffers becoming full.
265 This generally leads to duration stretching, and/or packet loss on TRex.
266
267 Currently used transactions were chosen to be short, so risk of bad behavior
268 is decreased. But in MRR tests, where load is computed based on NIC ability,
269 not TRex ability, anomalous behavior is still possible.
270
271 Delays
272 ______
273
274 TRex supports adding constant delays to ASTF programs.
275 This can be useful, for example if we want to separate connection establishment
276 from data transfer.
277
278 But as TRex tracks delayed instances as active, this still results
279 in higher CPU utilization and reduced performance issues
280 (as other overlaping transactions). So the current tests do not use any delays.
281
282 Keepalives
283 __________
284
285 Both UDP and TCP protocol implementations in TRex programs support keepalive
286 duration. That means there is a configurable period of keepalive time,
287 and TRex sends keepalive packets automatically (outside the program)
288 for the time the program is active (started, not ended yet)
289 but not sending any packets.
290
291 For TCP this is generally not a big deal, as the other side usually
292 retransmits faster. But for UDP it means a packet loss may leave
293 the receiving program running.
294
295 In order to avoid keepalive packets, keepalive value is set to a high number.
296 Here, "high number" means that even at maximum scale and minimum TPS,
297 there are still no keepalive packets sent within the corresponding
298 (computed) trial duration. This number is kept the same also for
299 smaller scale traffic profiles, to simplify maintenance.
300
301 Transaction success
302 ___________________
303
304 The transaction is considered successful at Layer-7 (L7) level
305 when both program instances close. At this point, various L7 counters
306 (unofficial name) are updated on TRex.
307
308 We found that proper close and L7 counter update can be CPU intensive,
309 whereas lower-level counters (ipackets, opackets) called L2 counters
310 can keep up with higher loads.
311
312 For some tests, we do not need to confirm the whole transaction was successful.
313 CPS (connections per second) tests are a typical example.
314 We care only for NAT44ed creating a session (needs one packet in inside-to-outside
315 direction per session) and being able to use it (needs one packet
316 in outside-to-inside direction).
317
318 Similarly in PPS (packets per second, combining session creation
319 with data transfer) tests, we care about NAT44ed ability to forward packets,
320 we do not care whether aplications (TRex) can fully process them at that rate.
321
322 Therefore each type of tests has its own formula (usually just one counter
323 already provided by TRex) to count "successful enough" transactions
324 and attempted transactions. Currently, all tests relying on L7 counters
325 use size-limited profiles, so they know what the count of attempted
326 transactions should be, but due to duration stretching
327 TRex might have been unable to send that many packets.
328 For search purposes, unattempted transactions are treated the same
329 as attemted byt failed transactions.
330
331 Sometimes even the number of transactions as tracked by search algorithm
332 does not match the transactions as defined by ASTF programs.
333 See PPS profiles below.
334
335 UDP CPS
336 ~~~~~~~
337
338 This profile uses a minimalistic transaction to verify NAT44ed session has been
339 created and it allows outside-to-inside traffic.
340
341 Client instance sends one packet and ends.
342 Server instance sends one packet upon creation and ends.
343
344 In principle, packet size is configurable,
345 but currently used tests apply only one value (64 bytes frame).
346
347 Transaction counts as attempted when opackets counter increases on client side.
348 Transaction counts as successful when ipackets counter increases on client side.
349
350 TCP CPS
351 ~~~~~~~
352
353 This profile uses a minimalistic transaction to verify NAT44ed session has been
354 created and it allows outside-to-inside traffic.
355
356 Client initiates TCP connection. Client waits until connection is confirmed
357 (by reading zero data bytes). Client ends.
358 Server accepts the connection. Server waits for indirect confirmation
359 from client (by waiting for client to initiate close). Server ends.
360
361 Without packet loss, the whole transaction takes 7 packets to finish
362 (4 and 3 per direction, respectively).
363 From NAT44ed point of view, only the first two are needed to verify
364 the session got created.
365
366 Packet size is not configurable, but currently used tests report
367 frame size as 64 bytes.
368
369 Transaction counts as attempted when tcps_connattempt counter increases
370 on client side.
371 Transaction counts as successful when tcps_connects counter increases
372 on client side.
373
374 UDP PPS
375 ~~~~~~~
376
377 This profile uses a small transaction of "request-response" type,
378 with several packets simulating data payload.
379
380 Client sends 33 packets and closes immediately.
381 Server reads all 33 packets (needed to avoid late packets creating new
382 server instances), then sends 33 packets and closes.
383 The value 33 was chosen ad-hoc (1 "protocol" packet and 32 "data" packets).
384 It is possible other values would still be safe from avoiding overlapping
385 transactions point of view.
386
387 ..
388     TODO: 32 was chosen as it is a batch size DPDK driver puts on the PCIe bus
389     at a time. May want to verify this with TRex ASTF devs and see if better
390     UDP transaction sizes can be found to yield higher performance out of TRex.
391
392 In principle, packet size is configurable,
393 but currently used tests apply only one value (64 bytes frame)
394 for both "protocol" and "data" packets.
395
396 As this is a PPS tests, we do not track the big 66 packet transaction.
397 Similarly to stateless tests, we treat each packet as a "transaction"
398 for search algorthm purposes. Therefore a "transaction" is attempted
399 when opacket counter on client or server side is increased.
400 Transaction is successful if ipacket counter on client or server side
401 is increased.
402
403 If one of 33 client packets is lost, server instance will get stuck
404 in the reading phase. This probably decreases TRex performance,
405 but it leads to more stable results.
406
407 TCP PPS
408 ~~~~~~~
409
410 This profile uses a small transaction of "request-response" type,
411 with some data size to be transferred both ways.
412
413 Client connects, sends 11111 bytes of data, receives 11111 of data and closes.
414 Server accepts connection, reads 11111 bytes of data, sends 11111 bytes
415 of data and closes.
416 Server read is needed to avoid premature close and second server instance.
417 Client read is not stricly needed, but acks help TRex to close server quickly,
418 thus saving CPU and improving performance.
419
420 The value of 11111 bytes was chosen ad-hoc. It leads to 22 packets
421 (11 each direction) to be exchanged if no loss occurs.
422 In principle, size of data packets is configurable via setting
423 maximum segment size. Currently that is not applied, so the TRex default value
424 (1460 bytes) is used, while the test name still (wrongly) mentions
425 64 byte frame size.
426
427 Exactly as in UDP_PPS, ipackets and opackets counters are used for counting
428 "transactions" (in fact packets).
429
430 If packet loss occurs, there is large transaction overlap, even if most
431 ASTF programs finish eventually. This leads to big duration stretching
432 and somehow uneven rate of packets sent. This makes it hard to interpret
433 MRR results, but NDR and PDR results tend to be stable enough.
434
435 Ip4base tests
436 ^^^^^^^^^^^^^
437
438 Contrary to stateless traffic profiles, we do not have a simple limit
439 that would guarantee TRex is able to send traffic at specified load.
440 For that reason, we have added tests where "nat44ed" is replaced by "ip4base".
441 Instead of NAT44ed processing, the tests set minimalistic IPv4 routes,
442 so that packets are forwarded in both inside-to-outside and outside-to-inside
443 directions.
444
445 The packets arrive to server end of TRex with different source address&port
446 than in NAT44ed tests (no translation to outside values is done with ip4base),
447 but those are not specified in the stateful traffic profiles.
448 The server end uses the received address&port as destination
449 for outside-to-inside traffic. Therefore the same stateful traffic profile
450 works for both NAT44ed and ip4base test (of the same scale).
451
452 The NAT44ed results are displayed together with corresponding ip4base results.
453 If they are similar, TRex is probably the bottleneck.
454 If NAT44ed result is visibly smaller, it describes the real VPP performance.