QUIC Protocol Implementation 1.0
A Python implementation of the QUIC (Quick UDP Internet Connections) protocol.
Loading...
Searching...
No Matches
packet.Packet Class Reference
Collaboration diagram for packet.Packet:

Public Member Functions

bytes pack (self)
 
'Packetunpack (cls, bytes packet_bytes)
 
 add_frame (self, 'FrameStream' frame)
 

Static Public Member Functions

list[FrameStreamget_frames_from_payload_bytes (bytes payload_bytes)
 

Static Public Attributes

int destination_connection_id
 
int packet_number
 
list payload = field(default_factory=list)
 

Detailed Description

@brief Represents a QUIC packet.

@details Contains a destination connection ID, packet number, 
         and payload as list of frames.

Definition at line 69 of file packet.py.

Member Function Documentation

◆ add_frame()

packet.Packet.add_frame (   self,
'FrameStream frame 
)
@brief Adds a frame to the packet's payload.

@param frame The frame to be added.

Definition at line 154 of file packet.py.

References packet.Packet.payload.

◆ get_frames_from_payload_bytes()

list[FrameStream] packet.Packet.get_frames_from_payload_bytes ( bytes  payload_bytes)
static
@brief Extracts frames from the payload bytes.

@details The process includes:
        - Iterating through the payload bytes.
        - Determining the end of attributes for each frame.
        - Determining the length of the frame data.
        - Decoding each frame and appending it to the list of frames.

@param payload_bytes The payload bytes.
@return The list of decoded FrameStream objects.

Definition at line 131 of file packet.py.

◆ pack()

bytes packet.Packet.pack (   self)
@brief Packs the packet into bytes.

@details The process includes:
        - Packing the header.
        - Converting the destination connection ID to bytes.
        - Converting the packet number to bytes based on its length.
        - Encoding each frame in the payload and appending it to the packed packet.

@return The packed packet as bytes.

Definition at line 81 of file packet.py.

References packet.Packet.destination_connection_id, test_packet.TestPacket.destination_connection_id, packet.Packet.pack(), packet.Packet.packet_number, test_packet.TestPacket.packet_number, and packet.Packet.payload.

Referenced by packet.Packet.pack().

◆ unpack()

'Packet' packet.Packet.unpack (   cls,
bytes  packet_bytes 
)
@brief Unpacks bytes into a Packet object.

@details The process includes:
        - Unpacking the header to get the packet number length.
        - Extracting the destination connection ID from the bytes.
        - Extracting the packet number from the bytes.
        - Extracting the payload frames from the remaining bytes.

@param packet_bytes The packed packet as bytes.
@return The unpacked Packet object.

Definition at line 103 of file packet.py.

Member Data Documentation

◆ destination_connection_id

int packet.Packet.destination_connection_id
static

Definition at line 77 of file packet.py.

Referenced by packet.Packet.pack(), and test_packet.TestPacket.test_init().

◆ packet_number

int packet.Packet.packet_number
static

Definition at line 78 of file packet.py.

Referenced by packet.Packet.pack(), and test_packet.TestPacket.test_init().

◆ payload

list packet.Packet.payload = field(default_factory=list)
static

Definition at line 79 of file packet.py.

Referenced by packet.Packet.add_frame(), and packet.Packet.pack().


The documentation for this class was generated from the following file: