60 likes | 69 Views
CSC 552 - Advanced Unix Programming, Fall 2015. Wednesday, September 30 TCP and UDP socket system calls. Example code. ~parson/UnixSysProg/udptcp.fall2015.zip ~parson/UnixSysProg/udptcp/. Transmission Control Protocol / Internet Protocol (TCP/IP).
E N D
CSC 552 - Advanced Unix Programming, Fall 2015 Wednesday, September 30 TCP and UDP socket system calls
Example code • ~parson/UnixSysProg/udptcp.fall2015.zip • ~parson/UnixSysProg/udptcp/
Transmission Control Protocol / Internet Protocol (TCP/IP) • Pipe-like, connection oriented, virtual circuit protocol. (But, a pipe lives inside one machine’s OS.) • Reliable data delivery via sequence numbers, acknowledgments, timeouts, retransmissions • TCP/IP has guaranteed order of delivery. • There is overhead associated with TCP/IP reliability. • Write() data boundaries for sender may differ from read() data boundaries for receiver.
TCP/IP Connection Establishment Server Process Client Process socket() (local endpoint) socket() bind() (IP address + TCP port) listen() (wait for connect) SYNconnect() accept() (grant connection request, makes new fd) SYN, ACK read() ACK write() write () ACK read() close() FIN or RST close()
User DatagramProtocol / Internet Protocol (UDP/IP) • Discrete, atomic messages from a sender’s sendto() call arrive at a receiver’s recvfrom(). • Unreliable data delivery may discard datagrams. • UDP has no guaranteed order of delivery. • There is minimal overhead with UDP/IP. • Sendto() data boundaries for sender do not differ from recvfrom() data boundaries for receiver. • Good medium for media streams where dropped datagrams can be ignored.
UDP/IP Connectionless Interaction Server Process Client Process socket() (local endpoint) socket() bind() (IP address + TCP port) recvfrom() sendto() sendto() recvfrom() close() (closes local endpoint) close() (local)