(do not merge) Hummingbird current implementation for visibility #4850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR shows the current implementation of the Hummingbird border router for visibility.
This implementation is not intended to land in
scionproto/scionas is.Some explanation and questions are documented below:
Implementation
The implementation requires changes in the border router and
slayers, namely:Hummingbirdpath type, allowing its (de)serialization.The requirement to support priorities by the border router can be relaxed to only support
priority egress queues, if we assume that forwarding packets at the border router is not bottlenecked
by the processing of the packets. If so, this can be done in a similar way to what we see in #4054.
Questions
I find two main questions to finish a design to the implementation:
I.e., is the existence of priority egress queues enough?
If the reason to drop packets is the bandwidth of the egress queue, the answer is "yes, it's enough".
If the reason to drop packets is CPU processing being a bottleneck, then the answer is "no, it's not enough".
Avoiding code duplication
To answer the second question above, which regards the code duplication,
a decision has to be made having the Go programming language in mind.
The solution would, ideally, remove all code duplication, and not introduce overhead,
or very little overhead, to the implementation with duplicated code.
Generics to avoid code duplication
Generics in Go do not allow the definition of a generic function that uses a generic type as a receiver of
a function, unless the type is constrained to an interface. The following is NOT allowed:
The following IS allowed:
This fact prevents us from simply writing a generic function with the correct text inside
(namely accessing the struct's fields and functions) because the compiler won't allow it:
an interface defining the common behavior of all paths must be defined.
Even more, Go does not support template specialization with its generics.
This means that we can't modify a default behavior (e.g. SCION packet processing) with the definition
of a function only for a specialized type (e.g. a Hummingbird path type).
Possibly, the only advantage of using generics here would be easing the task of the compiler to remove
type assertions when using the interface.
The Go compiler has proven to be very efficient in removing this superfluous type assertion code
in the presence of only one type in the call stack, although this would be true only when all functions are
inlined.
With the use of generics we would be forcing the compiler to effectively create distinct definitions
for the distinct path types, which is an assurance that the superfluous type assertion won't be there.
Interface at slayers
The need to create a common interface to express the processing of all path types is still present though.
This means that any existing path type in
slayerswhich we want to process with a common processing step,must follow a common
slayerspath type interface.Processing a Packet
In the border router, the processing of a packet with certain (segment-based) path type
requires these functions:
These functions on the packet processor would be written once, dealing with a generic path type.
As an example, let's consider a
ingressRouterAlertfunction:Common parts of
procthat don't depend on the path type (such asingressFromLink)could be extracted and promoted to a
baseProctype.Following this approach with interfaces,
the path types declared a the
slayerslevel would eitherhave to support this
SlayersPathTypeinterface,or we would create wrappers around them to support the interface.
Summary
Regarding the implementation, it can be designed as follows:
A new field
trafficClassinside thePacketstructcan be declared to support priorities.
basically, the functions we already have in
dataplane.goto process a SCION packet.These functions will operate on an interface (aka
SlayersPathTypeor similar).slayerswill be each wrapped in a struct to support theSlayersPathTypeinterface,or themselves support the
SlayersPathTypeinterface.