Skip to content

Commit 4d6ca54

Browse files
committed
code cleanup
1 parent c88c2ec commit 4d6ca54

File tree

1 file changed

+184
-3
lines changed

1 file changed

+184
-3
lines changed

pytcp/tests/integration/test__packet_handler__ethernet__tx.py

Lines changed: 184 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030

3131
"""
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.
3333
34-
pytcp/tests/unit/test__packet_handler__ethernet__tx.py
34+
pytcp/tests/integration/test__packet_handler__ethernet__tx.py
3535
3636
ver 3.0.4
3737
"""
@@ -76,6 +76,25 @@
7676
"ip4__dst": HOST_A__IP4_ADDRESS,
7777
},
7878
"_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.
7998
b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00"
8099
b"\x00\x14\x00\x00\x00\x00\x40\xff\x63\x8a\x0a\x00\x01\x07\x0a\x00"
81100
b"\x01\x5b",
@@ -98,6 +117,25 @@
98117
"ip4__dst": IP4__MULTICAST__ALL_NODES,
99118
},
100119
"_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.
101139
b"\x01\x00\x5e\x00\x00\x01\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00"
102140
b"\x00\x14\x00\x00\x00\x00\x40\xff\x8e\xe3\x0a\x00\x01\x07\xe0\x00"
103141
b"\x00\x01",
@@ -120,6 +158,25 @@
120158
"ip4__dst": IP4__BROADCAST__LIMITED,
121159
},
122160
"_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.
123180
b"\xff\xff\xff\xff\xff\xff\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00"
124181
b"\x00\x14\x00\x00\x00\x00\x40\xff\x6e\xe5\x0a\x00\x01\x07\xff\xff"
125182
b"\xff\xff",
@@ -142,6 +199,25 @@
142199
"ip4__dst": STACK__IP4_HOST.network.broadcast,
143200
},
144201
"_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.
145221
b"\xff\xff\xff\xff\xff\xff\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00"
146222
b"\x00\x14\x00\x00\x00\x00\x40\xff\x62\xe6\x0a\x00\x01\x07\x0a\x00"
147223
b"\x01\xff",
@@ -164,6 +240,25 @@
164240
"ip4__dst": STACK__IP4_HOST.network.address,
165241
},
166242
"_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.
167262
b"\xff\xff\xff\xff\xff\xff\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00"
168263
b"\x00\x14\x00\x00\x00\x00\x40\xff\x63\xe5\x0a\x00\x01\x07\x0a\x00"
169264
b"\x01\x00",
@@ -204,6 +299,25 @@
204299
"ip4__dst": HOST_C__IP4_ADDRESS,
205300
},
206301
"_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.
207321
b"\x02\x00\x00\x00\x00\x01\x02\x00\x00\x00\x00\x07\x08\x00\x45\x00"
208322
b"\x00\x14\x00\x00\x00\x00\x40\xff\x62\xb3\x0a\x00\x01\x07\x0a\x00"
209323
b"\x02\x32",
@@ -262,6 +376,21 @@
262376
"ip6__dst": HOST_A__IP6_ADDRESS,
263377
},
264378
"_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.
265394
b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\x86\xdd\x60\x00"
266395
b"\x00\x00\x00\x00\xff\x40\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00"
267396
b"\x00\x00\x00\x00\x00\x07\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00"
@@ -285,6 +414,21 @@
285414
"ip6__dst": IP6__MULTICAST__ALL_NODES,
286415
},
287416
"_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.
288432
b"\x33\x33\x00\x00\x00\x01\x02\x00\x00\x00\x00\x07\x86\xdd\x60\x00"
289433
b"\x00\x00\x00\x00\xff\x40\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00"
290434
b"\x00\x00\x00\x00\x00\x07\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00"
@@ -326,6 +470,21 @@
326470
"ip6__dst": HOST_C__IP6_ADDRESS,
327471
},
328472
"_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.
329488
b"\x02\x00\x00\x00\x00\x01\x02\x00\x00\x00\x00\x07\x86\xdd\x60\x00"
330489
b"\x00\x00\x00\x00\xff\x40\x20\x01\x0d\xb8\x00\x00\x00\x01\x00\x00"
331490
b"\x00\x00\x00\x00\x00\x07\x20\x01\x0d\xb8\x00\x00\x00\x02\x00\x00"
@@ -385,6 +544,16 @@
385544
"ethernet__dst": HOST_A__MAC_ADDRESS,
386545
},
387546
"_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.
388557
b"\x02\x00\x00\x00\x00\x91\x02\x00\x00\x00\x00\x07\xff\xff",
389558
],
390559
"_expected__tx_status": TxStatus.PASSED__ETHERNET__TO_TX_RING,
@@ -401,7 +570,19 @@
401570
"ethernet__src": MAC__UNSPECIFIED,
402571
"ethernet__dst": HOST_A__MAC_ADDRESS,
403572
},
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+
],
405586
"_expected__tx_status": TxStatus.PASSED__ETHERNET__TO_TX_RING,
406587
"_expected__packet_stats_tx": PacketStatsTx(
407588
ethernet__pre_assemble=1,

0 commit comments

Comments
 (0)