Add FrameBuilder for building frames with target packet length#39
Add FrameBuilder for building frames with target packet length#39
Conversation
|
Marked as draft because this doesn't do exactly what I want yet. We want to be able to specify the length of the entire packet (payload and header) and then add padding accordingly. The FrameBuilder does not have access to the header length (I don't think the header has even been built at this point) so I don't yet see a clean way to do this. |
|
I see what you meant there. Do we have any captured samples showing the variable length of Initial Packet header impacting the length of the frame section? Actually we DO have the complete header ready at the point we build frame sections (see Line 168 in cb2c7f1 Line 223 in cb2c7f1 I think originally quic-go does calculate the padding length at run-time. See Line 769 in cb2c7f1 (*uPacketPacker).appendInitialPacket.
|
gaukas
left a comment
There was a problem hiding this comment.
Looking good.
Can we move the definition and implementation of QUICPacket to after the end of `func (qfs QUICFrames) BuildFromFrames(frames []byte) (payload []byte, err error)? Just to keep each type definition and implementation together in one place.
| // and returns the byte representation of all frames as specified in | ||
| // the Frames slice. It then calculates the padding sizes needed to | ||
| // reach the specified Length and updates the PADDING frames accordingly. | ||
| func (qp QUICPacket) Build(cryptoData []byte) (payload []byte, err error) { |
There was a problem hiding this comment.
| func (qp QUICPacket) Build(cryptoData []byte) (payload []byte, err error) { | |
| func (qp *QUICPacket) Build(cryptoData []byte) (payload []byte, err error) { |
Let's make *QUICPacket instead of QUICPacket the one interfacing QUICFrameBuilder, just to align with the style of *QUICRandomFrames. (QUICFrames is an exception as it is a slice instead of a ground-truth struct)
Adds FrameBuilder that can adjust PADDING frame sizes to achieve a target length. Completes issue #38