Skip to content

feat: implement send_to() with packet building and API compatibility … - #3

Merged
gspivey merged 3 commits into
mainfrom
claude/tokio-dpdk-sample-app-wc3Om
Feb 4, 2026
Merged

gspivey merged 3 commits into
mainfrom
claude/tokio-dpdk-sample-app-wc3Om

Conversation

@gspivey

@gspivey gspivey commented Feb 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Port & Mempool infrastructure - Full DPDK port initialization, configuration, and mempool management with 48 unit tests
  • UDP send_to() - Complete packet building (Ethernet/IPv4/UDP) with checksums, transmits via tx_burst
  • API compatibility tests - 10 compile-time tests ensuring our UdpSocket matches std::net::UdpSocket signatures

Test plan

  • 74 tests pass (cargo test)
  • dpdk: 48 tests (port, mempool, mbuf)
  • dpdk-sys: 3 tests
  • dpdk-tokio: 8 tests
  • dpdk-udp: 15 tests (including 10 API compat tests)

What's implemented

  • bind() - initializes DPDK EAL, port, mempool
  • send_to() - builds Eth/IP/UDP packet, calls tx_burst
  • send(), connect(), local_addr(), peer_addr()
  • set_ttl(), ttl()
  • IPv4 and UDP checksum calculation

What's remaining

  • recv_from() - needs rx_burst + packet parsing
  • ARP handling (for real network deployment)

Implement UDP packet transmission in dpdk-udp:

dpdk-udp/src/lib.rs:

  • send_to() builds complete Ethernet/IPv4/UDP packets
  • build_udp_packet() constructs packet in mbuf with proper headers
  • ipv4_checksum() calculates IP header checksum
  • udp_checksum() calculates UDP checksum with pseudo-header
  • Shared DPDK resources (port, mempool) via Arc
  • Support for send(), connect(), set_ttl(), ttl()
  • Constants: ETH_HEADER_LEN, IPV4_HEADER_LEN, UDP_HEADER_LEN, MAX_UDP_PAYLOAD

API Compatibility Tests (10 new tests):

  • test_api_bind_signature
  • test_api_send_to_signature
  • test_api_recv_from_signature
  • test_api_local_addr_signature
  • test_api_peer_addr_signature
  • test_api_connect_signature
  • test_api_send_signature
  • test_api_recv_signature
  • test_api_set_ttl_signature
  • test_api_ttl_signature

dpdk/src/port.rs:

  • MacAddress::broadcast() - create ff:ff:ff:ff:ff:ff
  • MacAddress::zero() - create 00:00:00:00:00:00
  • MacAddress::octets() - get bytes as array

API_COMPATIBILITY.md:

  • Updated to reflect send_to() implementation
  • Added packet processing status
  • Added API compatibility test documentation

Total: 74 tests passing across all crates

https://claude.ai/code/session_01UiHnsVmMyk1CJgck3cCYZQ

claude and others added 3 commits February 4, 2026 01:30
…tests

Implement UDP packet transmission in dpdk-udp:

dpdk-udp/src/lib.rs:
- `send_to()` builds complete Ethernet/IPv4/UDP packets
- `build_udp_packet()` constructs packet in mbuf with proper headers
- `ipv4_checksum()` calculates IP header checksum
- `udp_checksum()` calculates UDP checksum with pseudo-header
- Shared DPDK resources (port, mempool) via Arc<Mutex>
- Support for `send()`, `connect()`, `set_ttl()`, `ttl()`
- Constants: ETH_HEADER_LEN, IPV4_HEADER_LEN, UDP_HEADER_LEN, MAX_UDP_PAYLOAD

API Compatibility Tests (10 new tests):
- test_api_bind_signature
- test_api_send_to_signature
- test_api_recv_from_signature
- test_api_local_addr_signature
- test_api_peer_addr_signature
- test_api_connect_signature
- test_api_send_signature
- test_api_recv_signature
- test_api_set_ttl_signature
- test_api_ttl_signature

dpdk/src/port.rs:
- MacAddress::broadcast() - create ff:ff:ff:ff:ff:ff
- MacAddress::zero() - create 00:00:00:00:00:00
- MacAddress::octets() - get bytes as array

API_COMPATIBILITY.md:
- Updated to reflect send_to() implementation
- Added packet processing status
- Added API compatibility test documentation

Total: 74 tests passing across all crates

https://claude.ai/code/session_01UiHnsVmMyk1CJgck3cCYZQ
rust build github action
Implement UDP packet receiving in dpdk-udp:

recv_from():
- Calls rx_burst to receive packets from DPDK port
- Filters packets by destination port
- Parses Ethernet/IPv4/UDP headers
- Copies payload to user buffer
- Returns source address

Packet Parsing:
- ParsedUdpPacket struct with src/dst MAC, IP, port, payload
- parse_udp_packet() - parse raw Ethernet frame
- parse_udp_from_mbuf() - parse from mbuf
- Validates ethertype (IPv4), protocol (UDP), header lengths

New Tests (7):
- test_parse_udp_packet_valid
- test_parse_udp_packet_empty_payload
- test_parse_udp_packet_too_short
- test_parse_udp_packet_wrong_ethertype
- test_parse_udp_packet_not_udp
- test_parse_udp_packet_extracts_macs
- test_parsed_udp_packet_debug

Updated API_COMPATIBILITY.md:
- recv_from() and recv() marked as implemented
- Packet parsing marked as implemented
- Phase 2 marked complete

Total: 81 tests passing (22 in dpdk-udp)

https://claude.ai/code/session_01UiHnsVmMyk1CJgck3cCYZQ
@gspivey
gspivey merged commit 2bda682 into main Feb 4, 2026
1 check passed
gspivey pushed a commit that referenced this pull request Mar 13, 2026
Mark P3.1-P3.4, P3.6, P3.8 complete. Add preliminary Run #3 entry to
perf-test-log.md with pending benchmark results (perf-tests.yml running).

https://claude.ai/code/session_01AX56ktjxp4ybrKFqAg7mMu
gspivey added a commit that referenced this pull request May 21, 2026
## Roadmap item

IPv6 sub-task #2: **UDP over IPv6 checksum** — mandatory IPv6
pseudo-header checksum validation (RFC 8200 §8.1).

## Changes

- Integrated `verify_udp6_checksum` into the RX path
(`process_frame_zerocopy`)
- IPv6 UDP packets are now parsed and checksum-validated before delivery
to the application
- Zero checksums are rejected (mandatory for IPv6, unlike IPv4 where 0
means disabled)
- Valid IPv6 UDP packets are delivered with `SocketAddrV6` source
addresses

## Tests added (21 new tests)

**Checksum verification (ipv6.rs):**
- VLAN-tagged IPv6 frame checksum verification
- Extension header (Hop-by-Hop) checksum verification
- Various payload sizes: empty, 1-byte, odd-length, max (1452B)
- Corruption detection: src/dst IP, src/dst port, payload
- Edge cases: truncated frames, non-IPv6 frames, too-short frames
- Pseudo-header checksum properties (different lengths, addresses, large
lengths)
- Zero-becomes-0xFFFF contract verification (RFC 8200 §8.1)

**RX path integration (lib.rs):**
- `process_frame_zerocopy_accepts_valid_ipv6_udp`
- `process_frame_zerocopy_rejects_corrupted_ipv6_checksum`
- `process_frame_zerocopy_rejects_zero_ipv6_checksum`

## Tradeoffs

- The RX path tries IPv4 parsing first, then falls back to IPv6. This
adds one failed parse attempt for IPv6-only traffic. The cost is
negligible (a few comparisons) and avoids changing the hot path for
existing IPv4 workloads.
- No topology worker integration yet — that will come with sub-task #3
(SocketAddrV6 through UdpSocket) which adds full dual-stack socket
support.

## All 607 tests pass, no regressions.

---------

Co-authored-by: Agent Router <agent@agent-router.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants