Reliable Networking Tom Roeder CS 415 2005 sp
Reliable Networking Tom Roeder CS 415 2005 sp
Last minute questions on Part II?
Goals n Add a reliable transmission layer q q n write test code q q n you discussed why in lecture: UDP is insufficient NB: TCP doesn’t interact well with ad hoc routing demonstrate to us that your code satisfies spec This will be the case for all future parts Non goals q q No nontrivial window (we use size 1) thus trivial congestion control, no AIMD n Would this still be TCP-friendly?
What to implement n minisockets q A connection-oriented networking layer n new header q q q n control packets q q fragmentation sequence numbers control types ACK, SYN, FIN Reliability n n duplicate detection retransmissions
Layered Implementation n Implement sockets on top of miniports q q q n Your code should just call send and receive When a port is created, it only accepts UDP When connected to a stream, it only accepts TCP No changes needed to the header q q q Received packets on a miniport are always passed up to the receiving “application” Sometimes this is an app, sometimes TCP This is a standard modular design
Stream Semantics n n Packets larger than max size are fragmented Two possible ways q q n We choose the latter q q n keep track of message size treat the socket as a byte stream can ignore packet boundaries at the receiver assume that multiple threads know how to reassemble if they get random pieces of the msg Easier for you to implement
minisockets minisocket_t minisocket_server_create(int port, minisocket_error *error); minisocket_t minisocket_client_create(network_address_t addr, int port, minisocket_error *error); int minisocket_send(minisocket_t socket, minimsg_t msg, int len, minisocket_error *error); int minisocket_receive(minisocket_t socket, minimsg_t msg, int max_len, minisocket_error *error); void minisocket_close(minisocket_t socket); n n A port can be taken either by TCP or UDP We give you the error messages The server is listening for a client to connect Send and receive happen as streams
Reliability n Retransmissions q q q May need to resend packets to account for loss Use an ACK to decide if need to resend interval: 100 ms. Try 7 times, doubling each time n n thus will wait about 12. 5 seconds Duplicate detection q q q Because of retransmissions, may get duplicates Need to keep track of old seq nums to supress Don’t forget to do this for control packets, too
minisockets as a state machine n Think of the states for each side q q q n The state transitions here are the messages and the timers q q n server: waiting for a connection, connected, closing socket, etc. client: various stages of connecting both: stages in sending a packet (which retransmission stage, ACK’ed or not, etc. ) open request, packet received, ACK timeout expired see http: //gmckinney. info/resources/TCPIP_State_Transition_Diagram. pdf
Implementation Issues n Multiple threads sending and receiving q only one minithreads client to one server n n n q each may have many threads on each side of the port thus need to coordinate ACKs and timeouts between them may want to have dedicated threads for this Should interact well with your scheduler n n Most should be blocked on I/O most of the time Should cause them to remain high priority
Questions?
- Slides: 11