UNIT I - ELEMENTARY TCP SOCKETS
Introduction to socket programming –
Overview of TCP / IP protocols – Introduction to sockets – Socket address structures – Byte ordering functions – Address conversion functions – Elementary TCP sockets – Socket – Connect – Bind – Listen – Accept –Read – Write – Close functions – Iterative server – Concurrent server.
UNIT II - APPLICATION DEVELOPMENT
TCP echo server – TCP echo client – POSIX signal handling – Server with multiple clients – Boundary conditions– Server process crashes– Server host crashes – Server crashes and reboots – Server shutdown – I/O multiplexing – I/O models – Select function – Shutdown function – TCP echo server (with multiplexing) – Poll function – TCP echo client (with multiplexing)
UNIT III - SOCKET OPTIONS, ELEMENTARY UDP SOC SOCKETS
Socket options – Getsocket and setsocket functions – Generic socket options – IP socket options – ICMP socket options – TCP socket options – Elementary UDP sockets – UDP echo server – UDP echo client – Multiplexing TCP and UDP sockets –Domain Name System – Gethostbyname function – IPV6 support in DNS – Gethostbyadr function – Getservbyname and getservbyport functions.
UNIT IV - ADVANCED SOCKETS
IPV4 and IPV6 interoperability – Threaded servers – Thread creation and termination– TCP echo server
using threads – Mutexes – Condition variables – Raw sockets –Raw socket creation – Raw socket output – Raw socket input – Ping program – Trace route program.
UNIT V - SIMPLE NETWORK MANAGEMENT
SNMP network management concepts – SNMP management information – StandardMIB’s – SNMP V1 protocol and practical
issues Introduction to RMON, SNMP V2 And SNMP
V3.
ASSIGNMENT TOPICS
Address conversion functions. Iterative server Concurrent server. POSIX signal handling Server crashes and reboots Elementary UDPsockets Domain Name System Thread creation and termination Raw socket creation SNMP management information.
SEMINAR TOPICS
Byte ordering functions. Elementary TCP sockets. Boundary conditions. I/O models. Multiplexing TCP and UDP sockets. Getservbyname and getservbyport
functions. Ping program. Standard MIB’s.
OBJECTIVES To learn the basics of socket programming-using
TCP sockets. Also to learn about Iterative and Concurrent server.
To learn the about the Echo server and client and handling of posix signal.
Various steps to be taken to recover the server when crash. Also to learn the Concept of I/O multiplexing.
To learn the various ways to get and set the options that affect a socket and basics of UDP sockets.
To develop knowledge of threads for developing high performance scalable applications
UNIT I - ELEMENTARY TCP SOCKETSHighlights Of Unit-I:
Socket address structures. Address conversion functions Socket – Connect – Bind – Listen-Accept
–Read – Write – Close functions Iterative and Concurrent Server.
TCP SOCKET CALLTCP Client TCP Server
Socket()
Socket()
bind()
Listen()
Accept()
read
read
write
close
read()
Connect()
Write()
Close()
Connection
request
EOF
Process Request
open_listenfd
open_clientfd
Blocks until connection from client
Data reply
SOCKET() FUNCTION
int socket(int domain(or)family, int type, int protocol);
domain := AF_INET (IPv4 protocol) type := (SOCK_DGRAM or SOCK_STREAM ) protocol := 0 (IPPROTO_UDP or IPPROTO_TCP) returned: socket descriptor (sockfd), -1 is an error
CONNECT() AND BIND() FUNCTION
int connect(int sockfd, const struct sockaddr *servaddr, int addrlen); //used by TCP client sockfd - socket descriptor (returned from socket()) sockaddr: socket address, struct sockaddr_in is
used addrlen := sizeof(struct sockaddr)
int bind(int sockfd, struct sockaddr *my_addr, int addrlen); sockfd - socket descriptor (returned from socket()) my_addr: socket address, struct sockaddr_in is
used addrlen := sizeof(struct sockaddr)
LISTEN() AND ACCEPT() FUNCTION
int listen(int sockfd, int backlog); backlog: how many connections we want
to queue
int accept(int sockfd, void *addr, int *addrlen);addr: here the socket-address of the caller
will be writtenreturned: a new socket descriptor (for the
temporal socket)
SOCKET I/O: READ() read can be used with a socket read blocks waiting for data from the
client but does not guarantee that sizeof(buf) is read
int fd; /* socket descriptor */char buf[512]; /* used by read() */int nbytes; /* used by read() */
/* 1) create the socket *//* 2) bind the socket to a port *//* 3) listen on the socket *//* 4) accept the incoming connection */
if((nbytes = read(newfd, buf, sizeof(buf))) < 0) {
perror(“read”); exit(1);}
UNIT II - APPLICATION DEVELOPMENT
TCP echo server TCP echo client POSIX signal handling Server process crashes Server host crashes Server Crashes and reboots- Server
shutdown
int main(int argc, char *argv[]){ int sock; /* Socket */ struct sockaddr_in echoServAddr; /* Local address */ struct sockaddr_in echoClntAddr; /* Client address */ unsigned int cliAddrLen; /* Length of incoming message */ char echoBuffer[ECHOMAX]; /* Buffer for echo string */ unsigned short echoServPort =7; /* Server port */ int recvMsgSize; /* Size of received message */ /* Create socket for sending/receiving datagrams */ sock = socket(AF_INET, SOCK_DGRAM, 0); /* Construct local address structure */ memset(&echoServAddr, 0, sizeof(echoServAddr)); /* Zero out
structure */ echoServAddr.sin_family = AF_INET; /* Internet address family
*/ echoServAddr.sin_addr.s_addr = htonl(“172.24.23.4”); echoServAddr.sin_port = htons(echoServPort); /* Local port */ /* Bind to the local address */ bind(sock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr);
UNIT III
UNIT-III SOCKET OPTIONS, ELEMENTARY UDP SOCKETS
Highlights Of Unit-III:
Socket options – Getsocket and setsocket functions
Generic socket options Elementary UDP sockets Multiplexing TCP and UDP sockets Domain Name System – Gethostbyname
function Gethostbyadr function Getservbyname and getservbyport functions.
GETSOCKOPT AND SETSOCKOPT FUNCTION
#include <sys/socket.h>int getsockopt(int sockfd, , int level, int optname, void *optval, socklent_t *optlen);
int setsockopt(int sockfd, int level , int optname, const void *optval, socklent_t optlen);
•sockfd => open socket descriptor•level => code in the system to interprete the option(generic, IPv4, IPv6, TCP)•optval => pointer to a variable from which the new value of option is fetched by setsockopt, or into which the current value of the option is stored by setsockopt.•optlen => the size of the option variable.
Lecture 3: 9-4-01 29
REVIEW: UDP CLIENT-SERVERINTERACTION
socket()
bind()
recvfrom()
sendto()
UDP Server
socket()
UDP Client
sendto()
recvfrom()
close()
blocks until datagramreceived from a clientdata request
data reply
from UNIX Network Programming Volume 1, figure 8.1
UNIT IV - ADVANCED SOCKETSHighlights Of Unit-IV:
Thread creation and termination TCP echo server using threads Raw sockets Raw socket creation Trace route program.
WHAT ARE RAW SOCKETS? Allows you to bypass the TCP/UDP
layers.
Send/receive your own packets, with your own headers.
You need to do all protocol processing at user-level.
RAW SOCKET CREATION
Only root can open a raw socket.
sockfd = socket(AF_INET, SOCK_RAW, proto)
where proto is IPPROTO_RAW, IPPROTO_ICMP etc.
LIMITATIONS Loss of Reliability
No ports
Non Standard Communications
No automatic ICMP
No Raw TCP or UDP
Must have root (or administrator) privilege
UNIT V - SIMPLE NETWORK MANAGEMENT
SNMP network management concepts SNMP management information – Standard MIB’s
NETWORK MANAGEMENT TASKS
Fault ManagementConfiguration ManagementPerformance ManagementSecurity Management Inventory ManagementAccounting Management
SNMP more than just a protocol …
It defines an architecture for extracting information from the network regarding the current operational state of the network, using a vendor-independent family of mechanisms
TCP/IP Protocol Suite 39
MANAGEMENT COMPONENTS
SNMP requires the use of two other protocols: Structure of Management Information (SMI) and Management Information Base (MIB). Network management on the Internet is done through the cooperation of SNMP, SMI, and MIB.
The topics discussed in this section include:Role of SNMP Role of SMI Role of MIB
TCP/IP Protocol Suite 40
SNMP defines the format of packets exchanged between a
manager and an agent. It reads and changes the status (values) of
objects (variables) in SNMP packets.
Note
TCP/IP Protocol Suite 41
SMI defines the general rules for naming objects, defining object types
(including range and length), and showing how to encode objects and
values. SMI defines neither the number of objects an entity should
manage, nor names the objects to be managed nor defines the association between the objects and their values.
Note:
TCP/IP Protocol Suite 42
MIB creates a collection of named objects, their types, and their
relationships to each other in an entity to be managed.
Note:
For More Details:
http://en.wikipedia.org/wiki/Socket_programminghttp://www.youtube.com/watch?v=4W09Gi4AFzEhttp://docstore.mik.ua/orelly/networking/tcpip/ch01_01.htmhttp://www.cisco.com/en/US/tech/ http://msdn.microsoft.com/en- us/library/aa771458(BTS.10).aspxhttp://www.indiastudychannel.comhttp://www.careertechonline.com/distributed-systems
/iterative-serverconcurrent- server-distributed-systems/
http://www.citap.com/documents/tcp-ip/tcpip013.htm
Top Related