DOC PREVIEW
Rutgers University CS 417 - Small worlds and giant epidemics

This preview shows page 1-2-3-27-28-29 out of 29 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 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 29 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 29 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 29 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 29 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 29 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CS 417Sockets and the operating system2CS 417Machine vs. transport endpoints• IP packets address only the machine– IP header identifies source IP address, destination IP address– IP address is a 32-bit address that refers to a machine• IP packet delivery is not guaranteed to be reliable or in-order• Transport-level protocols on top of IP:– Allow application-to-application communication–TCP/IP–UDP/IP– Port numbersProcess A Process Bport 1512port 25machine 192.168.1.5machine 192.168.1.7(This part is a review from the lecture)The IP protocol allows packets to be sent from one machine to another machine. Each IP packet header identifies the source and destination machines by their 32-bit IP address.The assumption at the IP layer is that the delivery of packets is unreliable (packets may get lost or data may get corrupted) and may not be in-order (packets may arrive in a different order than they were sent.Two transport-level protocols allow us to deal with application-to-application communication. These are TCP/IP and UDP/IP.Both TCP and UDP use port numbers to identify transport endpoints (applications). A port number is a 16-bit number that is associated with an application.For example, if Process A (which grabbed use of port number 1512) communicates with Process B (which grabbed the use of port 25), an IP packet from process A to process B will be addressed with a source address of 192.168.1.5 and a destination address of 192.168.1.7. The TCP or UDP header, which is encapsulated within the IP data will contain a source port of 1512 and a destination port of 25.3CS 417TCP/IP• Virtual circuit service• Sends ACK for each received packet• Checksum to validate data• Data may be transmitted simultaneously in both directions• No record markers but data arrives in sequenceSrc port Dest portSequence numberAcknowledgement numberOptions and padwindowchecksum Urgent ptrflagsHeaderlengthTCP header20 bytesTCP/IP – Transport Control ProtocolProvides virtual circuit service – connection oriented – you set up a connection and just read and write data on that connection. No need to address each packet.Packets are acknowledged by the protocol – no chance of packet lossA checksum is present to validate data – no data corruption. If there is, an acknowledgement is not sent and the packet is retransmittedTCP does not maintain record boundaries. For example, if you perform three writes: 5 bytes, 20 bytes, 15 bytes, the other side may receive all the data in a single read of 40 bytes. Or… it may not. If you want to preserve these boundaries, it is up to you to layer your own protocol on top of this. For example:send (length, data), (length, data), …Instead of data, data, data, …4CS 417UDP/IP• Datagram service• Packet may be lost• Data may arrive out of sequence• Checksum for data but no retransmitSrc port Dest portlemgth checksumUDP header8 bytesUDP/IP – User Datagram ProtocolProvides datagram service – connectionless– each packet must be addressed to the destinationData may be lost: it is up to the application to discover that a packet did not arrive at its destination. Application can send acknowledgements if this is needed.Data may arrive out of sequence: if packets take a different route via IP they may arrive in a different order from the one sent. TCP buffers up out-of-order packets in the kernel and presents them in the right order to the user.A checksum for the data exists in the UDP header. If data corruption is detected then the packet is dropped. To the application, this is the same as a lost packet.UDP is a lighter weight protocol: header is 8 bytes vs. 20+ bytes for TCP. Linux source for udp is around 1200 lines vs. >8000 lines for tcp.More importantly, dealing with UDP traffic uses less kernel resources: state about the connection, receive buffers to deal with out-of-order data, retransmission does not have to be handled.5CS 417Sockets and ports• Sockets are a popular communication abstraction– Allow us to address data to a destination address and port number– Allow us to bind our socket to a port number and source address.• bind– Assign source address and port number• connect– Assign destination address and port numberAs we’ve seen with sockets programs, sockets are a popular implementation for achieving network communication.After creating a socket, we use the bind system call to assign it to an address and port number. Typically, this address is 0.0.0.0, which represents INADDR_ANY, or any valid incoming address (particularly useful if a machine has several connections and several IP addresses). For servers, the port number is usually chosen by the user so that other programs will be able to specify it. For clients, one typically asks the operating system to pick any unused port number (this is requested by setting the port to 0 in bund).For connection-oriented protocols (TCP), the server address and port number is specified with the connect system call. For connectionless protocols (UDP), the address and port number may be specified explicitly when sending data using sendtoor sendmsg system calls.6CS 417Multiple senders may send from the same address, port!•Server– Sets socket for listen and waits in accept– accept returns a new socket– Typically, a new process or thread will handle that session– Destination address and port is the same for each socket!Client ASource addr: 192.168.1.2Source port: 1212Client BSource addr: 192.168.1.2Source port: 2323Client BSource addr: 192.168.1.5Source port: 4321Listener: Source address: 207.46.230.219Source port: 12Process 1Process 2Process 3to 207.46.230.219:12to 207.46.230.219:12to 207.46.230.219:12When a server set up a socket for listening and waits for an incoming connection with the accept call, a new socket is returned for each accepted connection.A server will typically create a new thread or fork a new process that will be responsible for handling that particular communication session.Each client still addresses data to the same IP address and port number. Now that data has to be routed to the correct socket so that the right process or thread can get the data and all the data streams do not become interleaved.7CS 417Sorting it out: routing data to the correct socket• Protocol Control Block–Table– Each entry contains:• Local address• Local port• Foreign address•Foreign port• Is the socket used for listening?• Reference to the socket


View Full Document

Rutgers University CS 417 - Small worlds and giant epidemics

Download Small worlds and giant epidemics
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 Small worlds and giant epidemics 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 Small worlds and giant epidemics 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?