QUIC Protocol Implementation 1.0
A Python implementation of the QUIC (Quick UDP Internet Connections) protocol.
Loading...
Searching...
No Matches
constants.py
Go to the documentation of this file.
1"""
2@file constants.py
3@brief Constants used throughout the QUIC protocol implementation.
4@details Defines numerical constants, bit masks, and configuration values
5 used by the various components of the QUIC implementation.
6"""
7
8
10 """
11 @brief Constants used throughout the QUIC protocol implementation.
12
13 @details Constants are grouped by category for better organization.
14 """
15
16 # -------------------
17 # General constants
18 # -------------------
19 ZERO = 0 # !< Constant for zero value
20 ONE = 1 # !< Constant for one value
21 TWO = 2 # !< Constant for two value
22 THREE = 3 # !< Constant for three value
23 FOUR = 4 # !< Constant for four value
24 FIVE = 5 # !< Constant for five value
25 SIX = 6 # !< Constant for six value
26 SEVEN = 7 # !< Constant for seven value
27 EIGHT = 8 # !< Constant for eight value
28 START = ZERO # !< Alias for zero, used as index start
29 KILO = 1024 # !< Number of bytes in a kilobyte
30
31 # -------------------
32 # Frame-related constants
33 # -------------------
34 OFFSET_LENGTH = EIGHT # !< Length of the offset field in bytes
35 LEN_LENGTH = EIGHT # !< Length of the length field in bytes
36 FRAME_TYPE_FIELD_LENGTH = ONE # !< Length of the frame type field in bytes
37 MIN_TYPE_FIELD = 0x08 # !< Minimum value for the type field
38 OFF_BIT = 0x04 # !< Bit flag indicating offset presence
39 LEN_BIT = 0x02 # !< Bit flag indicating length presence
40 FIN_BIT = 0x01 # !< Bit flag indicating final frame
41
42 # -------------------
43 # Packet-related constants
44 # -------------------
45 HEADER_LENGTH = ONE # !< Length of the packet header in bytes
46 PACKET_NUMBER_LENGTH = FOUR # !< Length of the packet number in bytes
47 DEST_CONNECTION_ID_LENGTH = EIGHT # !< Length of the destination connection ID in bytes
48
49 # Packet-header pack shifts
50 FORM_SHIFT = SEVEN # !< Shift for header form bit
51 FIXED_SHIFT = SIX # !< Shift for fixed bit
52 SPIN_SHIFT = FIVE # !< Shift for spin bit
53 RES_SHIFT = THREE # !< Shift for reserved bits
54 KEY_SHIFT = TWO # !< Shift for key phase bit
55
56 # Packet-header unpack masks
57 FORM_MASK = 0b10000000 # !< Mask for header form bit
58 FIXED_MASK = 0b01000000 # !< Mask for fixed bit
59 SPIN_MASK = 0b00100000 # !< Mask for spin bit
60 RES_MASK = 0b00011000 # !< Mask for reserved bits
61 KEY_MASK = 0b00000100 # !< Mask for key phase bit
62 PACKET_NUMBER_LENGTH_MASK = 0b00000011 # !< Mask for packet number length
63
64 # -------------------
65 # Stream-related constants
66 # -------------------
67 STREAM_ID_LENGTH = EIGHT # !< Length of the stream ID in bytes
68 INIT_BY_MASK = 0x01 # !< Mask for stream initiated by bit
69 DIRECTION_MASK = 0x02 # !< Mask for stream direction bit
70
71 # Both endpoints state-related constants
72 DATA_RECVD = 3 # !< State indicating data received
73
74 # StreamSender state-related constants
75 READY = START # !< State indicating ready to send
76 SEND = ONE # !< State indicating sending
77 DATA_SENT = TWO # !< State indicating data sent
78
79 # StreamReceiver state-related constants
80 RECV = START # !< State indicating ready to receive
81 SIZE_KNOWN = ONE # !< State indicating size known
82 DATA_READ = TWO # !< State indicating data read
83
84 # -------------------
85 # QuicConnection-related constants
86 # -------------------
87 MIN_PACKET_SIZE = 1000 # !< Minimum size of a packet
88 MAX_PACKET_SIZE = 2000 # !< Maximum size of a packet
89 PACKET_SIZE_BYTES = TWO # !< Size of the packet size field in bytes
90 FRAMES_IN_PACKET = FIVE # !< Number of frames in a packet
91 BASE_TWO = TWO # !< Base for binary conversions
92 TIMEOUT = 100 # !< Timeout value for socket operations
93 BIDI = ZERO # !< Flag for bidirectional stream
94 UNIDI = ONE # !< Flag for unidirectional stream
95
96 # -------------------
97 # Network-related constants
98 # -------------------
99 CONNECTION_ID_SENDER = ZERO # !< Connection ID for sender
100 CONNECTION_ID_RECEIVER = ONE # !< Connection ID for receiver
101 LOOP_BACK_ADDR = '127.0.0.1' # !< Loopback address
102 PORT_RECEIVER = 3492 # !< Port for receiver
103 PORT_SENDER = 33336 # !< Port for sender
104 ADDR_RECEIVER = (LOOP_BACK_ADDR, PORT_RECEIVER) # !< Address tuple for receiver
105 ADDR_SENDER = (LOOP_BACK_ADDR, PORT_SENDER) # !< Address tuple for sender
106 MAX_STREAMS = 5 # !< Maximum number of streams
107 FILE_PATH = 'img.gif' # !< Path to the file to be sent
108 FILE_SIZE = 477 # !< Size of the file in kilobytes