summaryrefslogtreecommitdiff
path: root/docs/Lossless_UDP.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/Lossless_UDP.txt')
-rw-r--r--docs/Lossless_UDP.txt102
1 files changed, 0 insertions, 102 deletions
diff --git a/docs/Lossless_UDP.txt b/docs/Lossless_UDP.txt
deleted file mode 100644
index 1159feb6..00000000
--- a/docs/Lossless_UDP.txt
+++ /dev/null
@@ -1,102 +0,0 @@
1Lossless UDP:
2 A network protocol over UDP to transfer data without any loss.
3
4 Problems with conventional UDP:
5 -Packet loss.
6 -Packet mixup.
7 -No flow control.
8
9 Draft of Proposed protocol:
10
11 Connexion example:
12
13 Alice wants to connect to Bob (Connection handshake):
14 Alice generates a random 4 byte number.
15 Alice puts it in the handshake packet (handshake_id1).
16 Alice starts sending handshake packets to Bob (send 10 packets over 5 seconds if no response connection fails.)
17 Bob receives the packet.
18 Bob copies the handshake packet he got from alice but concatenates a random 4 byte number to it (handshake_id2)
19 Alice receives the packet, checks if handshake_id1 matches the one she sent.
20 If it does she starts sending SYNC packets with sent_packetnum = handshake_id2 and recv_packetnum = handshake_id1.
21 Bob receives the packet,
22 if (handshake_id2) matches Bob adds Alice to his connections list and starts sending SYNC packets to alice.
23 Alice receives the SYNC packets and starts sending them too.
24 Connection is now established.
25
26 Alice wants to send packets to Bob:
27 Alice sends packets to bob.
28 If bob receives the packets, his next SYNC packets reflect it.
29 Alice receives the SYNC packets which confirms that bob received them
30 Alice clears the packets from her buffer.
31
32 If bob does not receive any packets, but receives a SYNC packet with a larger sent_packetnum than his recv_packetnum:
33 bobs SYNC packets become request packets.
34 The packet id of the missing packet(s) are added to the end of the SYNC packet.
35 Alice resends the packets whose numbers appear at the end of the request packet.
36
37 If bob receives some packets but some are missing
38 bobs SYNC packets become request packets.
39 The packet id of the missing packet(s) are added to the end of the SYNC packet.
40 Alice resends the packets whose numbers appear at the end of the request packet.
41
42 Alice and bob disconnect suddenly:
43 Alice stops receiving SYNC packets from bob.
44 Bob stops receiving SYNC packets from Alice.
45 Connexion times out if no data is received for 5 seconds.
46
47 Packet handling:
48
49 The client receives a SYNC packet:
50 He checks if the packet is valid(sent_packetnum and counter make sense)
51 If the packet is valid:
52 If the client was currently trying to establish a connection.
53 If the handshake was done:
54 Start sending SYNC packets.
55 Add +1 to the counter of the SYNC packets we send.
56 Check to see if any packets were dropped when sending them to us (compare sent_packetnum with the number of packets we received.)
57 If some were, The next SYNC packets we send will be request packets requesting the missing packets.
58 Check if the other client received what we sent him (compare recv_packetnum with the number of packets we sent) and clear them from the buffer.
59 If the packet is a request packet.
60 Send the packets he requested.
61
62
63
64 The client receives a Connection handshake packet(not initiating connection):
65 If handshake_id2 is zero:
66 use the handshake_id1 in the packet as the handshake_id2 of the response.
67 use our random handshake_id1 as handshake_id1.
68 send the response packet.
69
70
71
72 The client receives a Connection handshake packet(initiating connection):
73 check if handshake_id1 matches what we sent.
74 If it does start sending SYNC packets with sent_packetnum as handshake_id2
75
76 The client receives a data packet:
77 Put the packet in the proper place in the receive buffer using packet_num as the reference.
78 If all the previous packets have been received correctly set recv_packetnum equal to packet_num
79
80
81
82 Keep track of the percent of packets dropped, if it is too high, lower the send rate. If it is low, increase it.
83
84 Have a send packets buffer that we can write to and a received packets buffer that we can read from.
85
86
87
88
89 Protocol:
90 Connection handshake packets:
91 [byte with value: 16 (10 in hex)][4 byte (handshake_id1)][4 bytes (handshake_id2)]
92
93 SYNC packets:
94 [byte with value: 17 (11 in hex)][byte (counter)][4 byte (recv_packetnum)][4 byte (sent_packetnum)][sequence of requested packet ids[4 bytes each](not present in keep alive)]
95
96
97 data packets:
98 [byte with value: 18 (12 in hex)][4 byte (packet_num)][data (arbitrary size)]
99
100
101
102 \ No newline at end of file