260 likes | 349 Views
System Programming SOCKETS and TCP, UPD Protocols. ISO OSI 7 Layer Network Reference Model. Application. Application. Presentation. Presentation. Session. Session. Transport. Transport. Network. Network. Network. Data Link. Data Link. Data Link. Physical. Physical. Physical.
E N D
ISO OSI 7 Layer Network Reference Model Application Application Presentation Presentation Session Session Transport Transport Network Network Network Data Link Data Link Data Link Physical Physical Physical Physical Wire Physical Wire Host B Host A Router
TCP UDP TCP UDP TCP/IP Protocol Stack Application Application IPv4, IPv6 IP IPv4, IPv6 Link Link Link Link Physical Wire Physical Wire Host A Host B Router
TCP UDP OSI model and IP suite Comparison Application Application Application Details User Process Presentation Session Sockets XTI Transport Network IPv4, IPv6 Kernel Communications Details Data Link Device drive and Hardware Physical
Socket • Socket is an Interface to Network protocol stack • Provide point-to-point, two-way communication between two processes • Versatile and are basic component of inter-process and inter-system communication • Endpoint of communication to which a name can be bound • Exist in communication domains called socket domains • There are twenty three (23) sockets types defined in socket.h • Processes communicate only between sockets of the same type
Socket Types • Stream Socket • Provides two-way, sequenced, reliable, and unduplicated flow of data. • Underlying Protocol is TCP, socket type is SOCK_STREAM • Datagram Socket • Supports a two-way flow of messages • Datagram socket may receive messages in a different order from the sequence in which the messages were sent • Socket type is SOCK_DGRAM • Underlying protocol is User Datagram Protocol (UDP)
Socket Programming • Using sockets to communicate between different process • These processes can be remote or local • Sockets are manipulated like un-buffered I/O files and use socket descriptors • Most popular of APIs for socket programming is Berkeley Sockets • Another popular socket API is the System V Transport Layer Interface (TLI) provided by AT&T later standardized as X/Open Transport Interface
Transport Layer Role and Services The purpose of the Transport layer
Transport Layer Role and Services Major functions of the transport layer and the role it plays in data networks
Transport Layer Role and Services Supporting Reliable Communication
Transport Layer Role and Services The basic characteristics of the UDP and TCP protocols
Transport Layer Role and Services How a port number is represented and describe the role port numbers play in the TCP and UDP protocols
Application and Operation of TCP Mechanisms The role of port numbers in establishing TCP sessions and directing segments to server process
UDP Protocol The process specified by the UDP protocol to reassemble data at the destination device
TCP Connection EstablishmentThree-Way Handshake The server must be prepared to accept connection (passive open) socket, bind, listen The client calls connect (active open) A SYN segment is sent telling the server the initial sequence number of client The server must ACK the clients SYN and also send its own SYN to the client The client must ACK the servers SYN Each SYN can contain TCP options
TCP Options MSS option With this option the TCP sending the SYN announces its maximum segment size, the maximum amount of data that it is willing to accept in each TCP segment, on this connection Can be set with TCP_MAXSEG socket option
TCP Connection Termination One application calls close first (active close), this end’s TCP sends a FIN segment, which means it is finishes sending the data The other side that receives FIN performs the passive close The receive FIN is acknowledge by TCP The receipt of the FIN is also passed to the application as an end-of-file (after any data that may be queued for the application to receive) Some times later the application that received the end-of-file will close its socket This cause its TCP to send a FIN The TCP on the system that receives this final FIN (the end that did the active close) acknowledges the FIN
MSL is the maximum amount of time that any given IP datagram can live in an internet • The common value for MSL is between 30 seconds to 4 minute 25