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

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

Embed Size (px)

Citation preview

Page 1: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

Sockets API

Overview

Sockets with UDP

Sockets with TCP

Fast Sockets (Fast UDP)

IP Multicasting

Page 2: 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 over

TCP/IP networksWHAT IT DOES:• Supports UDP and TCP protocols• Sends and receives data between applicationsSET-UP CONDITIONS:• Socket() call creates communications endpoints• Bind() links a network address to the socket• Other calls depend on the protocol

Page 3: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

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

Socket Connection

SocketINTERNET

Page 4: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

Possible Socket Implementations

Client

Socket Connection

ServerTCP Connection

Client creates socket, requests connection on specific IP port.

Server must have been passively ‘listening’ on that port.

Terminal

Socket Connection

TerminalUDP Connection

Socket created on specific port, data is sent without connection established.

Remote terminal must have been passively ‘listening’ on that port.

Page 5: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

Sockets Flow - UDP

DATA PIPE

Device 1 Device 2

Create Create

BindBind

SendTo SendTo

RecvFrom RecvFrom

NETWORKNETWORK

Page 6: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

DATA PIPE

Client Server

Send Send

Recv Recv

Connect

Bind Bind

Listen

Accept

Create Create

Sockets Flow - TCP

NETWORKNETWORK

(Associate Socket with own IP addr, port)

Page 7: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

Example API call

Declarationint connect(int socket_descriptor,

struct sockaddr_in *ptr2Inet_socket_addr_struct, int addrlen);Establish Connection

/* Setup the server's sockaddr_in struct */bzero(&serverAddress, sizeof(serverAddress));serverAddress.sin_family = AF_INET;serverAddress.sin_port = htons(13); serverAddress.sin_addr.s_addr = htonl(0xC75CBA53); /*

199.92.186.83 */int rc = (connect(69, &serverAddress, sizeof(serverAddress));

Return value0 if successful, otherwise -1.

#include <sockapi.h>

Page 8: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

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

Page 9: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

Fast UDP vs. Standard Socket API’s

• Standard– accept– bind– connect– closesocket– connect– getpeername– gGetsockname– getsockopt– listen– recv– recvfrom– send– sendto– setsocketopt– shutdown– socket

• Fast UDP– fBind– fGetBuf– fSendTo– fSockInit– fSocket– fSocketClose

Page 10: Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting

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) V1.

• 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 src\bsp 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.