Outline Network Programming
Total Page:16
File Type:pdf, Size:1020Kb
Outline Network Programming Definitions Berkeley API Dr. Thaier Hayajneh Computer Engineering Department Socket definition and types Introduction to Sockets 1 2 Network API Process Process Process Layer API - Application Programming Interface API is a set of functionality/services delivered by a programming system. TCP SCTP UDP Transppyort Layer Also API is a set of declaration, definitions, and procedflldbdures followed by programmers titlitto write client- server programs. ICMP, ARP Network API & IP Network Layer The services ( often provided by the operating system) RARP that provide the interface between application and protocol software . 802.3 Data-Link Layer 3 4 Network API Network API wish list Generic Programming Interface. Internet Support multiple communication protocol suites OSI model Application protocol suite details (families). Application User Address (endpoint) representation independence. processor Presentation Application Provide special services for Client and Server Session Transport TCP UDP Support for message oriented and connection Network IPv4, IPv6 oriented communication. kernel Data link Data link Work with existing I/O services Physical Physical Communications Operating System independence details Presentation layer services 5 6 TCP/IP Client-Server Model TCP/IP does not include an API definition. Client 1 Server Client 2 There are a variety of APIs for use with TCP/IP: Client 3 Sockets by Berkeley XTI (X/Open Transport Interface) by AT&T One side of communication is client, and the other side is server Winsock - Windows Sockets API by Microsoft Server waits for a client request to arrive MacTCP / Open Transport by Apple Server processes the client request and sends the response back to the client Iterative or concurrent 7 8 Functions needed: Berkeley Sockets Sppyecify local and remote communication A socket is an abstract representation of a communication endpoint. endpoints Generic: Initiate a connection support for multiple protocol families. Wait for incoming connection address representation independence Send and receiv e data Sockets (obviously) have special needs: Terminate a connection gracefully establishing a connection specifying communication endpoint addresses Error handling Sockets work with Unix I/O services just like files, pipes & FIFOs 9 10 Sockets API Sockets Abstraction API is Application Programming Interface The socket is the basic abstraction for network •Sockets API defines interface between application and communication in the socket API transport layer Defines an endpoint of communication for a process two processes communicate by sending data into Operating system maintains information about the socket, reading data out of socket socket and its connection •Socket interface gives a file system like abstraction to the Application references the socket for sends, receives, capabilities of the network etc •Each transport protocol offers a set of services The socket API provides the abstraction to access these services •The API defines function calls to create, close, read and wri/fite to/from a soc ket 11 12 Elements of a Socket Types of Sockets Each socket can be uniqqyuely identified by Source IP address Source port number Destination IP address Destination port number An end-to-end protocol (TCP or UDP) 13 14 Stream Sockets Datagram Sockets Also known as connection-oriented socket Also known as connectionless socket Use TCP Use UDP Provide reliable, connected networking Provide unreliable, best-effort networking service service Error free; no out-of-order packets Packets may be lost; may arrive out of Applications: telnet, ssh, http order TCP uses a pair of stream sockets to Applications: streaming audio/video connect one application program to UDP uses a pair of datagram sockets to another across the Internet. connect one application program to another across the ItInternet . 15 16 Raw Sockets Some protocols as ICMP or OSPF that directly use the services of IP use neither stream sockets nor datagram sockets. Raw sockets are designed for these types of applications. 17.