Presentation is loading. Please wait.

Presentation is loading. Please wait.

IT1352-NETWORK PROGRAMMING AND MANAGEMENT

Similar presentations


Presentation on theme: "IT1352-NETWORK PROGRAMMING AND MANAGEMENT"— Presentation transcript:

1 IT1352-NETWORK PROGRAMMING AND MANAGEMENT

2 SYLLABUS

3 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.

4 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)

5 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.

6 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.

7 UNIT V - SIMPLE NETWORK MANAGEMENT
SNMP network management concepts – SNMP management information – Standard MIB’s – SNMP V1 protocol and practical issues Introduction to RMON, SNMP V2 And SNMP V3.

8 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.

9 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.

10 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

11 UNIT I - ELEMENTARY TCP SOCKETS
Highlights Of Unit-I: Socket address structures. Address conversion functions Socket – Connect – Bind – Listen-Accept –Read – Write – Close functions Iterative and Concurrent Server.

12 TCP SOCKET CALL TCP Client TCP Server open_listenfd Connection request
bind() open_listenfd Connect() open_clientfd Connection request Listen() Write() Accept() Blocks until connection from client read Process Request Data reply read() write EOF Close() read close

13 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

14 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); my_addr: socket address, struct sockaddr_in is used

15 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 written returned: a new socket descriptor (for the temporal socket)

16 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); }

17 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

18

19

20 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(“ ”); echoServAddr.sin_port = htons(echoServPort); /* Local port */ /* Bind to the local address */ bind(sock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr);

21

22

23

24

25

26

27 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.

28 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.

29 Review: UDP Client-Server Interaction
UDP Server socket() bind() UDP Client recvfrom() socket() blocks until datagram received from a client sendto() data request data reply sendto() recvfrom() close() from UNIX Network Programming Volume 1, figure 8.1 Lecture 3:

30 UNIT IV - ADVANCED SOCKETS
Highlights Of Unit-IV: Thread creation and termination TCP echo server using threads Raw sockets Raw socket creation Trace route program.

31 Raw Sockets

32 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.

33 sockfd = socket(AF_INET, SOCK_RAW, proto)
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.

34 Limitations Loss of Reliability No ports Non Standard Communications
No automatic ICMP No Raw TCP or UDP Must have root (or administrator) privilege

35 UNIT V - SIMPLE NETWORK MANAGEMENT
SNMP network management concepts SNMP management information – Standard MIB’s

36 Network Management Tasks
Fault Management Configuration Management Performance Management Security Management Inventory Management Accounting Management

37 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

38 Figure SNMP concept 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 Note 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. TCP/IP Protocol Suite

41 Note: 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. TCP/IP Protocol Suite

42 Note: MIB creates a collection of named objects, their types, and their relationships to each other in an entity to be managed. TCP/IP Protocol Suite

43 For More Details: http://en.wikipedia.org/wiki/Socket_programming
us/library/aa771458(BTS.10).aspx server-distributed-systems/


Download ppt "IT1352-NETWORK PROGRAMMING AND MANAGEMENT"

Similar presentations


Ads by Google