This repository was archived by the owner on Apr 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkCommunicationConstants.py
More file actions
46 lines (30 loc) · 1.71 KB
/
Copy pathNetworkCommunicationConstants.py
File metadata and controls
46 lines (30 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def ms_to_ns(ms): return int(ms * 1_000_000)
def s_to_ns(s): return int(s * 1_000_000_000)
def ns_to_s(ns): return float(ns / 1_000_000_000)
MAXIMUM_PACKET_SIZE_BYTES: int = 982 - 512
''' Maximum packet size (bytes) sent by our protocol, keep in mind that this does not include UDP headers '''
HEARTBEAT_FREQUENCY_NS: int = 30_000_000_000
''' Frequency (ns) of heartbeats sent by client to server '''
HEARTBEAT_FREQUENCY_S = ns_to_s(HEARTBEAT_FREQUENCY_NS)
HEARTBEAT_TIMEOUT_NS: int = 180_000_000_000
''' Timeout (ns) of a client after not receiving a heartbeat '''
HEARTBEAT_POLL_TIME_NS: int = 20_000_000_000
''' Time (ns) between polls to determine if a client should be forcefully disconnected '''
HEARTBEAT_POLL_TIME_S = ns_to_s(HEARTBEAT_POLL_TIME_NS)
OUTGOING_BUFFER_SIZE_BYTES: int = 16_384
''' Size (bytes) of the output / send buffer '''
INCOMING_BUFFER_SIZE_BYTES: int = 16_384
''' Size (bytes) of the input / receive buffer '''
COMPLETED_MESSAGE_BUFFER_SIZE: int = 1000
''' Size (count) of the buffer that stores id's of previously completed communications '''
WAIT_TIME_BEFORE_REPEAT_REQUEST_NS: int = 50_000_000
''' Time (ns) waited after most recent packet before asking for a repeat '''
WAIT_TIME_BEFORE_REPEAT_REQUEST_S: float = ns_to_s(WAIT_TIME_BEFORE_REPEAT_REQUEST_NS)
WAIT_RESPONSE_TIME_NS: int = 200_000_000
''' Time (ns) waited for response before resending a message '''
WAIT_RESPONSE_TIME_S: float = ns_to_s(WAIT_RESPONSE_TIME_NS)
GIVE_UP_REATTEMPTS: int = 3
''' Attempts before giving up (int) '''
FIND_RESEND_REPEAT_FAIL_POLL_TIME_NS: int = 15_000_000
''' Time (ns) between polls for resend, repeats, and failed messages'''
FIND_RESEND_REPEAT_FAIL_POLL_TIME_S = ns_to_s(FIND_RESEND_REPEAT_FAIL_POLL_TIME_NS)