Download presentation
Presentation is loading. Please wait.
1
Reliable Networking Tom Roeder CS415 2005sp
2
Last minute questions on Part II?
3
Goals Add a reliable transmission layer you discussed why in lecture: UDP is insufficient NB: TCP doesn’t interact well with ad hoc routing write test code demonstrate to us that your code satisfies spec This will be the case for all future parts Non goals No nontrivial window (we use size 1) thus trivial congestion control, no AIMD Would this still be TCP-friendly?
4
What to implement minisockets A connection-oriented networking layer new header fragmentation sequence numbers control types control packets ACK, SYN, FIN Reliability duplicate detection retransmissions
5
Layered Implementation Implement sockets on top of miniports 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 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
6
Stream Semantics Packets larger than max size are fragmented Two possible ways keep track of message size treat the socket as a byte stream We choose the latter 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
7
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); 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
8
Reliability Retransmissions May need to resend packets to account for loss Use an ACK to decide if need to resend interval: 100ms. Try 7 times, doubling each time thus will wait about 12.5 seconds Duplicate detection 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
9
minisockets as a state machine Think of the states for each side 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.) The state transitions here are the messages and the timers open request, packet received, ACK timeout expired see http://gmckinney.info/resources/TCPIP_State_Transition_Diagram.pdf
10
Implementation Issues Multiple threads sending and receiving only one minithreads client to one server 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 Most should be blocked on I/O most of the time Should cause them to remain high priority
11
Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.