|
29 | 29 |
|
30 | 30 |
|
31 | 31 | """ |
32 | | -This module contains unit tests for the Packet Handler Ethernet TX operations. |
| 32 | +This module contains integration tests for the Packet Handler Ethernet TX operations. |
33 | 33 |
|
34 | | -pytcp/tests/unit/test__packet_handler__ethernet__tx.py |
| 34 | +pytcp/tests/integration/test__packet_handler__ethernet__tx.py |
35 | 35 |
|
36 | 36 | ver 3.0.4 |
37 | 37 | """ |
|
76 | 76 | "ip4__dst": HOST_A__IP4_ADDRESS, |
77 | 77 | }, |
78 | 78 | "_expected__frames_tx": [ |
| 79 | + # Ethernet II |
| 80 | + # Destination MAC : 02:00:00:00:00:91 |
| 81 | + # Source MAC : 02:00:00:00:00:07 |
| 82 | + # Ethertype : 0x0800 (IPv4) |
| 83 | + # Frame length : 34 bytes |
| 84 | + # |
| 85 | + # IPv4 |
| 86 | + # Version / IHL : 4 / 5 |
| 87 | + # DSCP / ECN : 0x00 |
| 88 | + # Total Length : 20 bytes |
| 89 | + # Identification : 0x0000 |
| 90 | + # Flags / Offset : 0x0000 |
| 91 | + # TTL : 64 |
| 92 | + # Protocol : 255 (Reserved) |
| 93 | + # Header Checksum : 0x638a |
| 94 | + # Source IP : 10.0.1.7 |
| 95 | + # Destination IP : 10.0.1.91 |
| 96 | + # |
| 97 | + # Summary: Minimal IPv4 header-only packet to host A resolved via ARP cache hit on the local LAN. |
79 | 98 | b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00" |
80 | 99 | b"\x00\x14\x00\x00\x00\x00\x40\xff\x63\x8a\x0a\x00\x01\x07\x0a\x00" |
81 | 100 | b"\x01\x5b", |
|
98 | 117 | "ip4__dst": IP4__MULTICAST__ALL_NODES, |
99 | 118 | }, |
100 | 119 | "_expected__frames_tx": [ |
| 120 | + # Ethernet II |
| 121 | + # Destination MAC : 01:00:5e:00:00:01 (IPv4 multicast) |
| 122 | + # Source MAC : 02:00:00:00:00:07 |
| 123 | + # Ethertype : 0x0800 (IPv4) |
| 124 | + # Frame length : 34 bytes |
| 125 | + # |
| 126 | + # IPv4 |
| 127 | + # Version / IHL : 4 / 5 |
| 128 | + # DSCP / ECN : 0x00 |
| 129 | + # Total Length : 20 bytes |
| 130 | + # Identification : 0x0000 |
| 131 | + # Flags / Offset : 0x0000 |
| 132 | + # TTL : 64 |
| 133 | + # Protocol : 255 (Reserved) |
| 134 | + # Header Checksum : 0x8ee3 |
| 135 | + # Source IP : 10.0.1.7 |
| 136 | + # Destination IP : 224.0.0.1 |
| 137 | + # |
| 138 | + # Summary: IPv4 header-only multicast packet mapped to the all-nodes MAC address. |
101 | 139 | b"\x01\x00\x5e\x00\x00\x01\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00" |
102 | 140 | b"\x00\x14\x00\x00\x00\x00\x40\xff\x8e\xe3\x0a\x00\x01\x07\xe0\x00" |
103 | 141 | b"\x00\x01", |
|
120 | 158 | "ip4__dst": IP4__BROADCAST__LIMITED, |
121 | 159 | }, |
122 | 160 | "_expected__frames_tx": [ |
| 161 | + # Ethernet II |
| 162 | + # Destination MAC : ff:ff:ff:ff:ff:ff (broadcast) |
| 163 | + # Source MAC : 02:00:00:00:00:07 |
| 164 | + # Ethertype : 0x0800 (IPv4) |
| 165 | + # Frame length : 34 bytes |
| 166 | + # |
| 167 | + # IPv4 |
| 168 | + # Version / IHL : 4 / 5 |
| 169 | + # DSCP / ECN : 0x00 |
| 170 | + # Total Length : 20 bytes |
| 171 | + # Identification : 0x0000 |
| 172 | + # Flags / Offset : 0x0000 |
| 173 | + # TTL : 64 |
| 174 | + # Protocol : 255 (Reserved) |
| 175 | + # Header Checksum : 0x6ee5 |
| 176 | + # Source IP : 10.0.1.7 |
| 177 | + # Destination IP : 255.255.255.255 |
| 178 | + # |
| 179 | + # Summary: IPv4 limited broadcast emitted with Ethernet broadcast destination. |
123 | 180 | b"\xff\xff\xff\xff\xff\xff\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00" |
124 | 181 | b"\x00\x14\x00\x00\x00\x00\x40\xff\x6e\xe5\x0a\x00\x01\x07\xff\xff" |
125 | 182 | b"\xff\xff", |
|
142 | 199 | "ip4__dst": STACK__IP4_HOST.network.broadcast, |
143 | 200 | }, |
144 | 201 | "_expected__frames_tx": [ |
| 202 | + # Ethernet II |
| 203 | + # Destination MAC : ff:ff:ff:ff:ff:ff (broadcast) |
| 204 | + # Source MAC : 02:00:00:00:00:07 |
| 205 | + # Ethertype : 0x0800 (IPv4) |
| 206 | + # Frame length : 34 bytes |
| 207 | + # |
| 208 | + # IPv4 |
| 209 | + # Version / IHL : 4 / 5 |
| 210 | + # DSCP / ECN : 0x00 |
| 211 | + # Total Length : 20 bytes |
| 212 | + # Identification : 0x0000 |
| 213 | + # Flags / Offset : 0x0000 |
| 214 | + # TTL : 64 |
| 215 | + # Protocol : 255 (Reserved) |
| 216 | + # Header Checksum : 0x62e6 |
| 217 | + # Source IP : 10.0.1.7 |
| 218 | + # Destination IP : 10.0.1.255 |
| 219 | + # |
| 220 | + # Summary: IPv4 subnet broadcast mapped to Ethernet broadcast for the local LAN. |
145 | 221 | b"\xff\xff\xff\xff\xff\xff\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00" |
146 | 222 | b"\x00\x14\x00\x00\x00\x00\x40\xff\x62\xe6\x0a\x00\x01\x07\x0a\x00" |
147 | 223 | b"\x01\xff", |
|
164 | 240 | "ip4__dst": STACK__IP4_HOST.network.address, |
165 | 241 | }, |
166 | 242 | "_expected__frames_tx": [ |
| 243 | + # Ethernet II |
| 244 | + # Destination MAC : ff:ff:ff:ff:ff:ff (broadcast) |
| 245 | + # Source MAC : 02:00:00:00:00:07 |
| 246 | + # Ethertype : 0x0800 (IPv4) |
| 247 | + # Frame length : 34 bytes |
| 248 | + # |
| 249 | + # IPv4 |
| 250 | + # Version / IHL : 4 / 5 |
| 251 | + # DSCP / ECN : 0x00 |
| 252 | + # Total Length : 20 bytes |
| 253 | + # Identification : 0x0000 |
| 254 | + # Flags / Offset : 0x0000 |
| 255 | + # TTL : 64 |
| 256 | + # Protocol : 255 (Reserved) |
| 257 | + # Header Checksum : 0x63e5 |
| 258 | + # Source IP : 10.0.1.7 |
| 259 | + # Destination IP : 10.0.1.0 |
| 260 | + # |
| 261 | + # Summary: IPv4 packet aimed at the subnet network address, emitted as an Ethernet broadcast per stack rules. |
167 | 262 | b"\xff\xff\xff\xff\xff\xff\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00" |
168 | 263 | b"\x00\x14\x00\x00\x00\x00\x40\xff\x63\xe5\x0a\x00\x01\x07\x0a\x00" |
169 | 264 | b"\x01\x00", |
|
204 | 299 | "ip4__dst": HOST_C__IP4_ADDRESS, |
205 | 300 | }, |
206 | 301 | "_expected__frames_tx": [ |
| 302 | + # Ethernet II |
| 303 | + # Destination MAC : 02:00:00:00:00:01 (default gateway) |
| 304 | + # Source MAC : 02:00:00:00:00:07 |
| 305 | + # Ethertype : 0x0800 (IPv4) |
| 306 | + # Frame length : 34 bytes |
| 307 | + # |
| 308 | + # IPv4 |
| 309 | + # Version / IHL : 4 / 5 |
| 310 | + # DSCP / ECN : 0x00 |
| 311 | + # Total Length : 20 bytes |
| 312 | + # Identification : 0x0000 |
| 313 | + # Flags / Offset : 0x0000 |
| 314 | + # TTL : 64 |
| 315 | + # Protocol : 255 (Reserved) |
| 316 | + # Header Checksum : 0x62b3 |
| 317 | + # Source IP : 10.0.1.7 |
| 318 | + # Destination IP : 10.0.2.50 |
| 319 | + # |
| 320 | + # Summary: IPv4 packet for an external host forwarded to the gateway MAC from cache. |
207 | 321 | b"\x02\x00\x00\x00\x00\x01\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00" |
208 | 322 | b"\x00\x14\x00\x00\x00\x00\x40\xff\x62\xb3\x0a\x00\x01\x07\x0a\x00" |
209 | 323 | b"\x02\x32", |
|
262 | 376 | "ip6__dst": HOST_A__IP6_ADDRESS, |
263 | 377 | }, |
264 | 378 | "_expected__frames_tx": [ |
| 379 | + # Ethernet II |
| 380 | + # Destination MAC : 02:00:00:00:00:91 |
| 381 | + # Source MAC : 02:00:00:00:00:07 |
| 382 | + # Ethertype : 0x86DD (IPv6) |
| 383 | + # Frame length : 54 bytes |
| 384 | + # |
| 385 | + # IPv6 |
| 386 | + # Version / Traffic Class / Flow Label : 0x60000000 |
| 387 | + # Payload Length : 0 bytes |
| 388 | + # Next Header : 255 (Reserved) |
| 389 | + # Hop Limit : 64 |
| 390 | + # Source IP : 2001:db8:0:1::7 |
| 391 | + # Destination IP : 2001:db8:0:1::91 |
| 392 | + # |
| 393 | + # Summary: Minimal IPv6 packet to a local host delivered via ND cache hit. |
265 | 394 | b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\x86\xdd\x60\x00" |
266 | 395 | b"\x00\x00\x00\x00\xff\x40\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00" |
267 | 396 | b"\x00\x00\x00\x00\x00\x07\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00" |
|
285 | 414 | "ip6__dst": IP6__MULTICAST__ALL_NODES, |
286 | 415 | }, |
287 | 416 | "_expected__frames_tx": [ |
| 417 | + # Ethernet II |
| 418 | + # Destination MAC : 33:33:00:00:00:01 (IPv6 multicast) |
| 419 | + # Source MAC : 02:00:00:00:00:07 |
| 420 | + # Ethertype : 0x86DD (IPv6) |
| 421 | + # Frame length : 54 bytes |
| 422 | + # |
| 423 | + # IPv6 |
| 424 | + # Version / Traffic Class / Flow Label : 0x60000000 |
| 425 | + # Payload Length : 0 bytes |
| 426 | + # Next Header : 255 (Reserved) |
| 427 | + # Hop Limit : 64 |
| 428 | + # Source IP : 2001:db8:0:1::7 |
| 429 | + # Destination IP : ff02::1 |
| 430 | + # |
| 431 | + # Summary: IPv6 all-nodes multicast mapped to the corresponding Ethernet multicast MAC. |
288 | 432 | b"\x33\x33\x00\x00\x00\x01\x02\x00\x00\x00\x00\x07\x86\xdd\x60\x00" |
289 | 433 | b"\x00\x00\x00\x00\xff\x40\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00" |
290 | 434 | b"\x00\x00\x00\x00\x00\x07\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00" |
|
326 | 470 | "ip6__dst": HOST_C__IP6_ADDRESS, |
327 | 471 | }, |
328 | 472 | "_expected__frames_tx": [ |
| 473 | + # Ethernet II |
| 474 | + # Destination MAC : 02:00:00:00:00:01 (IPv6 gateway) |
| 475 | + # Source MAC : 02:00:00:00:00:07 |
| 476 | + # Ethertype : 0x86DD (IPv6) |
| 477 | + # Frame length : 54 bytes |
| 478 | + # |
| 479 | + # IPv6 |
| 480 | + # Version / Traffic Class / Flow Label : 0x60000000 |
| 481 | + # Payload Length : 0 bytes |
| 482 | + # Next Header : 255 (Reserved) |
| 483 | + # Hop Limit : 64 |
| 484 | + # Source IP : 2001:db8:0:1::7 |
| 485 | + # Destination IP : 2001:db8:0:2::50 |
| 486 | + # |
| 487 | + # Summary: IPv6 packet for an external peer, forwarded to the gateway MAC cached in ND. |
329 | 488 | b"\x02\x00\x00\x00\x00\x01\x02\x00\x00\x00\x00\x07\x86\xdd\x60\x00" |
330 | 489 | b"\x00\x00\x00\x00\xff\x40\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00" |
331 | 490 | b"\x00\x00\x00\x00\x00\x07\x20\x01\x0d\xb8\x00\x00\x00\x02\x00\x00" |
|
385 | 544 | "ethernet__dst": HOST_A__MAC_ADDRESS, |
386 | 545 | }, |
387 | 546 | "_expected__frames_tx": [ |
| 547 | + # Ethernet II |
| 548 | + # Destination MAC : 02:00:00:00:00:91 |
| 549 | + # Source MAC : 02:00:00:00:00:07 |
| 550 | + # Ethertype : 0xffff (experimental) |
| 551 | + # Frame length : 16 bytes |
| 552 | + # |
| 553 | + # Payload |
| 554 | + # Bytes : ffff (placeholder payload from test harness) |
| 555 | + # |
| 556 | + # Summary: Raw Ethernet frame with caller-provided MAC addresses forwarded unchanged. |
388 | 557 | b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\xff\xff", |
389 | 558 | ], |
390 | 559 | "_expected__tx_status": TxStatus.PASSED__ETHERNET__TO_TX_RING, |
|
401 | 570 | "ethernet__src": MAC__UNSPECIFIED, |
402 | 571 | "ethernet__dst": HOST_A__MAC_ADDRESS, |
403 | 572 | }, |
404 | | - "_expected__frames_tx": [b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\xff\xff"], |
| 573 | + "_expected__frames_tx": [ |
| 574 | + # Ethernet II |
| 575 | + # Destination MAC : 02:00:00:00:00:91 |
| 576 | + # Source MAC : 02:00:00:00:00:07 (stack filled) |
| 577 | + # Ethertype : 0xffff (experimental) |
| 578 | + # Frame length : 16 bytes |
| 579 | + # |
| 580 | + # Payload |
| 581 | + # Bytes : ffff (placeholder payload from test harness) |
| 582 | + # |
| 583 | + # Summary: Raw Ethernet frame with unspecified source automatically filled in before transmit. |
| 584 | + b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\xff\xff", |
| 585 | + ], |
405 | 586 | "_expected__tx_status": TxStatus.PASSED__ETHERNET__TO_TX_RING, |
406 | 587 | "_expected__packet_stats_tx": PacketStatsTx( |
407 | 588 | ethernet__pre_assemble=1, |
|
0 commit comments