DOC PREVIEW
CORNELL CS 414 - Assignment #5

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Assignment 5Reliable networking with minisocketsAri RabkinA filesystem postmortemIt’s hard, we know. We aren’t out to get you; grading won’t be too brutal.Late submission until 3am tonight without penalty.Also, we’ll drop lowest project scoreRemember; if you need extra time, or clarification, ask early.Project overviewDatagram networking is ugly: Packets get lostForces programmer to think about packets (too low level)We’re going to build reliable data streams, which have neither drawback.Closely mimics TCPSocketsA socket is an endpoint of a reliable communication streamProgram can read or write any quantity of data; stream interface divides into packets.Yours are called minisockets -- see minisocket.h and .cServer and Client SocketsSockets come in two kinds: server (listening) and clientServer socket created by minisocket_server_create(); call blocks until client connects.Clients create sockets with minisocket_client_create(), which connects.Creating a socketSYNSYNACKACKClient ServerThe three-way handshakeTwo-way-nessNote that after connection setup, the stream is two-way. The server and client sockets become interchangeable after the create succeeds.Closing sockets gracefullyEither side can send a close message. Other side responds with ACKAfter receiving ACK or timeout, close-initiator can treat socket as closed. Other side waits 15 seconds, then treats it as closed. (why?)Networks lose packets for lots of reasons.Easy fix: retransmit if needed.Catch: what if destination is down?Packet lossUsing ACKsDetecting failure perfectly is impossible. In practice, we do well enough.Send a packet with sequence #, wait for ACK to that packet.Resend if no ACK received by timeout.RetransmittingWait 100 ms for ACK, then retransmit Retransmit seven times, doubling wait each time after each failure.Use alarms and semaphores: note that if a packet arrives, should wake up right away.So sleep-with-timeout is no good here.Special casesIn the three-way handshake, the SYN and the SYNACK are retransmitted reliably.So is the CLOSE on socket teardown.Packet FormatsRemember that ‘type’ field in packets from Project 3? Here’s where it comes in handy.Need to separate minisocket and minimsg packets.Probably also wise to divide socket control and data packets.Minisocket PacketsYou need SYN, SYNACK, DATA, ACK, CLOSE.StreamsKey idea of streams is that the application doesn’t see packet boundaries.All app sees is a stream of data, some of which is available.Stream must be reliable, since app can’t easily implement reliability again on top.Read and writeWe’re building streams on packets: minisocket_send() with a big buffer should split it into packets and send them reliably.Likewise, minisocket_receive() should return whatever is available, or a full buffer.If more data than a buffer is available, can’t lose it. (Save it in queue somehow)The State MachineUse the state machine abstraction in designing, and also in implementing. Track a state for each socket, and when a packet comes in, switch on socket state and packet type.See the TCP state machine (online) for further insight.NotesThread safety is important here.Don’t sleep when you have work to do: need to wake listening thread as soon as packet


View Full Document

CORNELL CS 414 - Assignment #5

Documents in this Course
Security

Security

49 pages

Processes

Processes

24 pages

Deadlocks

Deadlocks

57 pages

Threads

Threads

5 pages

Threads

Threads

29 pages

Deadlocks

Deadlocks

36 pages

Load more
Download Assignment #5
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Assignment #5 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Assignment #5 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?