Sockets API Overview Sockets with UDP Sockets with

  • Slides: 10
Download presentation
Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP

Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

Sockets Overview WHAT IT IS: • Used by applications to send and receive data

Sockets Overview WHAT IT IS: • Used by applications to send and receive data over TCP/IP networks WHAT IT DOES: • Supports UDP and TCP protocols • Sends and receives data between applications SET-UP CONDITIONS: • Socket() call creates communications endpoints • Bind() links a network address to the socket • Other calls depend on the protocol

Socket-Layer Protocols • Application Level Network Communication Protocols • Ride on Top of Either

Socket-Layer Protocols • Application Level Network Communication Protocols • Ride on Top of Either TCP/IP for Guaranteed Delivery or UDP/IP for Minimizing Network Traffic (not Guaranteed) • Inconspicuous Communication for Security INTERNET Socket Connection Socket

Possible Socket Implementations TCP Connection Client Server Socket Connection Client creates socket, requests connection

Possible Socket Implementations TCP Connection Client Server Socket Connection Client creates socket, requests connection on specific IP port. Server must have been passively ‘listening’ on that port. Terminal UDP Connection Terminal Socket Connection Socket created on specific port, data is sent without connection established. Remote terminal must have been passively ‘listening’ on that port.

Sockets Flow - UDP Device 1 Device 2 Create Bind DATA PIPE Send. To

Sockets Flow - UDP Device 1 Device 2 Create Bind DATA PIPE Send. To NETWORK Recv. From

Sockets Flow - TCP Create Bind Client Server (Associate Socket with own IP addr,

Sockets Flow - TCP Create Bind Client Server (Associate Socket with own IP addr, port) Connect Create Bind Listen Accept NETWORK Send Recv DATA PIPE

Example API call Declaration #include <sockapi. h> int connect(int socket_descriptor, struct sockaddr_in *ptr 2

Example API call Declaration #include <sockapi. h> int connect(int socket_descriptor, struct sockaddr_in *ptr 2 Inet_socket_addr_struct, int addrlen); Establish Connection /* Setup the server's sockaddr_in struct */ bzero(&server. Address, sizeof(server. Address)); server. Address. sin_family = AF_INET; server. Address. sin_port = htons(13); server. Address. sin_addr. s_addr = htonl(0 x. C 75 CBA 53); /* 199. 92. 186. 83 */ int rc = (connect(69, &server. Address, sizeof(server. Address)); Return value 0 if successful, otherwise -1.

Fast UDP (Fast Sockets) • Socket-like API that bypasses most of the stack •

Fast UDP (Fast Sockets) • Socket-like API that bypasses most of the stack • Advantages of Fast UDP API: performance potentially double the data rate • Advantages of Normal Sockets API: portable, richer API, TCP support • Utilizes a different set of API calls

Fast UDP vs. Standard Socket API’s • Standard – – – – accept bind

Fast UDP vs. Standard Socket API’s • Standard – – – – accept bind connect closesocket connect getpeername g. Getsockname getsockopt listen recvfrom sendto setsocketopt shutdown socket • Fast UDP – – – f. Bind f. Get. Buf f. Send. To f. Sock. Init f. Socket. Close

IP Multicasting • NET+OS TCP/IP supports Level 2 IP multicast as defined by RFC

IP Multicasting • NET+OS TCP/IP supports Level 2 IP multicast as defined by RFC 1112, which includes sending and receiving IP multicast packets and implementation of the Internet Group Membership Protocol (IGMP) V 1. • To enable a static interface to have multicast capability, the n_mcastlist field of the netstatic entry to point be set to a call back function, mcastlist. The function mcastlist is defined in the file narmenet. c (in the srcbsp directory). • If n_mcastlist field of a static interface be set to NULL, that interface won't be able to send/receive multicast packets. • The setsockopt() function is used to add/delete memberships and set multicast options for a particular socket.