Skip to content

Add reassembly support for fragmented IPv4 packets in Swift IP#32

Open
agnosticdev wants to merge 1 commit into
mainfrom
agnosticdev/FragmentedIPv4
Open

Add reassembly support for fragmented IPv4 packets in Swift IP#32
agnosticdev wants to merge 1 commit into
mainfrom
agnosticdev/FragmentedIPv4

Conversation

@agnosticdev

Copy link
Copy Markdown
Collaborator

The goal here is to add reassembly support for fragmented IPv4 packets in Swift IP without impacting performance and on standard path.
Since IP fragmentation is not very common there needs to be fall-back behavior for reassembly when IP fragments are detected in processInboundFrames to ensure performance.

This change includes such fall-back behavior for reassembly and I verified the performance with QUICTransfer:

Top of tree:
213.05 M  47.9%	-	 IPProtocol.IPInstance.IPv4Instance.processInboundFrames(_:_:)

With this change
226.35 M  46.7%	-	 IPProtocol.IPInstance.IPv4Instance.processInboundFrames(_:_:)

Adds support for reassembly IPv4 fragments only. IPv6 support will come in a future change.

@agnosticdev agnosticdev requested review from rnro and rpaulo June 27, 2026 20:56
@agnosticdev

Copy link
Copy Markdown
Collaborator Author

Outbound fragmentation support for IPv4 will also come in a future change.

}
}

public mutating func prepend(frame: consuming Frame) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of this function should just be

        self.frames.prepend(frame)

var log = NetworkLoggerState()
var eventManager = ProtocolEventManager()

static let IP_MF: UInt16 = 0x2000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make these use more swift-styled names: IPMoreFragmentsFlag, etc.

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