UDP Clients and Servers
Pseudocode for a UDP server
main() { s = socket(... ) bind(s, ... recvfrom(s, ... sendto(s, ... } Pseudocode for a UDP client
main() { s = socket(... sendto(s, ... recvfrom(s, ... }
Here is a link to a web site that covers a lot of the same material that I covered in class.
Here are the formulas for determining how to set the timer.
RTTn - Round trip time for the nth packet
EstRTT - the estimated average round trip time, calculated with a a decay function. The following is recalculated each time a new segment is ack'ed.
EstRTT = (1 - α) * EstRTT + α * RTTn
A typical α is .125.
Originally TCP simply set the timer at 2 * EstRTT. However, more modern implementations also take the variance of RTT into account.
DevRTT = (1 - β) * DevRTT + (β * abs(RTTn - EstRTT))
A typical β is .25
TimeoutInterval = EstRTT + 4 * DevRTT