You are on page 1of 13

10144IT601 Network Programming and Management UNIT - I ELEMENTARY TCP SOCKETS 2MARKS: 1. What is transmission control protocol?

? TCP is a connection-oriented protocol that provides a reliable full-duplex byte for a user process. 2. What are the advantages of TCP/IP? The advantages are, ->TCP is not vendor specific. ->TCP is used for both LANs and WANs. ->TCP has been implemented on everything from personal computers to the largest super computers. 3. What is socket? The basis for network I/O in the socket API, centers on an abstraction known as the socket. We think of a socket as a generalization of the UNIX file access mechanism that provides an end for communication. As with file access, application program request the operating system to create a socket when one is needed. 4. How will you create socket? The socket function is, result=socket (pf, type, protocol) Where , Pf the protocol family to be used with the socket. Type type of communication Protocol specific protocol. 5. Write about socket libraries. The socket interface routine are in a library that must be linked with the applications. The libraries libsocket.so and libsocket.a are combined in-user-lib with the rest of the system services libraries. 6. What are raw sockets? Some protocols such as ICMP or OSPF that directly use the services of IP use neither STREAM sockets nor DEGRAM sockets. Raw sockets are designed for these types of application. 7.Which function is used to establish a local address for a socket? Once a socket has been created,a server uses the bind function to establish A local address for it.Bind has the following form: bind(socket,local addr,addrlen) where, socket-integer descriptor of the socket to be found.

1|Page

10144IT601 Network Programming and Management Local addr-structure that specifies the local addresses to which the Socket should be bound Addrlen-integer that specifies the length of the address measured In bytes 8.How will you send data through a socket? Once an application program has established a socket, it can use the socket to transmit data. There are five possible functions from which to choose: Send, sendto, sendmsg, write ,writev, and writer only work With connected sockets because they do not allow the caller to specify the Destination address. Write (socket, buffer, length) Writev (socket, iovector, vectorlen) Send (socket, message, length, flags) Sendto (socket, message, length, flags, destaddr, addrlen) Sendmsg (socket, messagestrut, flags)

9.Write about the write function. Write function takes three arguments and is used to send data through a Socket. Write (socket, buffer, length) Where, Socket-integer socket descriptor Buffer-address of the data to be sent Length-the number of bytes to send. -> Like most system calls, write returns an error code to the application Calling it, allowing the programmer to know if the operation succeeded. 10.Write about the writev function. The system call writev works like write except that it uses a gather write Form, making it possible for the application program to write a message Without copying the message in to contiguous bytes of memory. writev has The form, Writev (socket, iovector, vectorlen) Where, socket-socket to use iovector-address of an array of type iovec that contains a sequence of pointers to the blocks of bytes that form the Message. vectorlen-specifies the number of entries in iovector. 11.Write about the send function. The send function has the form, Send (socket, message, length, flags) Where, 2|Page

10144IT601 Network Programming and Management Socket-specifies the socket to use. Message-address of the data to be sent Length-specifies the number of bytes to be sent. Flags-controls the transmission. 12.Write about the sendto function. Sendto,which takes the destination address as argument,has the form, Sendto(socket,message,length,flags,desaddr,addrlen) Where, Socket-socket to use. Message-address of the data to be sent. Length-number of bytes to be sent. Flags-to control the transmission. Desaddr-destination address. Addrlen-give the length of the address. 13.How will you receive data through a socket? The socket API offers five functions that a process can use to receive data through a socket, they are read, readr, recv from and recvmsg. 14.What are datagram socket? A datagram socket provides a symmetric data exchange interface. There is no requirement for connection establishment. Each message carries the destination address. 15. What is connection establishment? It is usually asymmetric, with one process a thing as the client and the other as the server. The server binds a socket to a well-known address associated with the service and blocks on its socket for a connection. 16.What are the system calls used for data transfer? The system call used for data transfer are 1) Write(s, buf, size buf); 2) read(s, buf, size buf); 3)send(s,buf, size of buf,flag); 4) recv(s,buf, size of buf,flag); 17. What are the files to be included for using sockets? The files to be included are 1) sys / types.h 2) sys / socket.h 3) netinet / in.h 4) arpa / inet.h 18. Name the advantage of socket system call. i. readv and writev ii. sendmsg and recvmsg iv. shutdown v. select

iii. vi.

getsockopt getpeername

3|Page

10144IT601 Network Programming and Management 19. write about socket implementation.

20 . What are asynchronous sockets? Asynchronous communication between processes is required in real time applications. They must be sock STREAM type. UNIT II APPLICATION DEVELOPMENT

1. Give an example of simple echo client and server.

2. Write the flow of functions performed by the TCP echo server. The functions are 1. Create socket, bind servers well known port. 2. Wait for client connection to complete. 3. Concurrent server. 3. what is the purpose of TCP echo server: str-echo function? The function performs the server processing for each client, reading the lines from the client and echoing them back to the client. 4. State the purpose of TCP echo client, str-cli function. This function handle the client processing loop, read a line of text from standard input, write it to the server, read back the servers echo of the line, and output the echoed line to standard output.

4|Page

10144IT601 Network Programming and Management 5. Draw the diagram for simple echo client-server using UDP.

6. What is the use of ip shutdown? It is used to shutdown an IP interface. Ex: host 1 (config-if) # ip shutdown. 7. What is the difference between applications using TCP and that the use UDP? UDP is a connectionless, unreliable, datagram protocol whereas, TCP is a connection oriented, reliable byte stream. 8. List out the few popular applications built using UDP. The few popular applications are, a. DNS The domain name system b. NFS The Network File System. c. SNMP Simple Network Management protocol. 9. What are the I/O models are available in UNIX. There are five I/O models available in unix. They are 1. Blocking I/O. 2. Non Blocking I/O. 3. I/O Multiplexing 4. Signal drive I/O 5. Asynchronous I/O. 10. What is the purpose of select function. This function allows the process to instruct the kernel to wait for any one of multiple events to occur and to wake up the process only when one or more of these events occurs or when a specified amount of time has passed. 11. Write the syntax of select function. Syntax: int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const struct timeval *timeout); 12. write the syntax of shutdown function. Syntax: Int shutdown(int sockfd, int howto); 13. Define poll function The poll function originated with SVR3 and was originally limited to streams devices. Poll to work with any descriptor. Poll provides the functionality that is similar to select, but poll provide the additional information when dealing with stream devices. 14. write the syntax of poll function. Syntax: Int poll (struct pollfd *fdarray, unsigned long nfds, int timeout);

5|Page

10144IT601 Network Programming and Management 15. what are the four loop involved in the client processing loop. The four steps in the client processing loop are : -> read a line from standard input using fgets -> send the line to the server using sent to -> read back the servers echo using recvfrom -> print and echoed line to standard output using fputs. 16. What are the characteristics of client? The characteristics of client are, 1. it is invoked by a user and executed for one session. 2. It runs locally on the users computer. 3. It actively initiates contact with a server. 4. It can access multiple services as needed. 17. What are the characteristics of server? The characteristics of server are, 1. It is a special purpose program dedicated to provide one service. 2. It is invoked automatically when a system boots, and continues to execute through many sessions. 3. It runs on a shared computers. 4. It accept contact from arbitrary clients, but offers a single service. 18. If bind() fails, what should I do with the socket descriptor? If you are exiting, all unixes will close open file descriptors on exit. If you are not exiting though, you can just close it with a regular close() call. 19. What is the difference between select() and poll()? The basic difference is that select()'s fd_set is a bit mask and therefore has some fixed size. It would be possible for the kernel to not limit this size when the kernel is compiled, allowing the application to define FD_SETSIZE to whatever it wants but it takes more work. 4.4BSD's kernel and the Solaris library function both have this limit. But I see that BSD/OS 2.1 has now been coded to avoid this limit, so it's doable, just a small matter of programming. :-) Someone should file a Solaris bug report on this, and see if it ever gets fixed. With poll(), however, the user must allocate an array of poll fd structures, and pass the number of entries in this array, so there's no fundamental limit. As Casper notes, fewer systems have poll() than select, so the latter is more portable. Also, with original implementations (SVR3) you could not set the descriptor to -1 to tell the kernel to ignore an entry in the poll fd structure, which made it hard to remove entries from the array; SVR4 gets around this. Personally, I always use select() and rarely poll(), because I port my code to BSD environments too. Someone could write an implementation of poll() that uses select(), for these environments, but I've never seen one. Both select() and poll() are being standardized by POSIX 1003.1g.

6|Page

10144IT601 Network Programming and Management 20. What is the difference between read() and recv()? read() is equivalent to recv() with a flags parameter of 0. Other values for the flags parameter change the behaviour of recv(). Similarly, write() is equivalent to send() with flags == 0. It is unlikely that send()/recv() would be dropped; perhaps someone with a copy of the POSIX drafts for socket calls can check... Portability note: non-unix systems may not allow read()/write() on sockets, but recv()/send() are usually ok. This is true on Windows and OS/2, for example. 21. When will my application receive SIGPIPE? : with TCP you get SIGPIPE if your end of the connection has received an RST from the other end. What this also means is that if you were using select instead of write, the select would have indicated the socket as being readable, since the RT is there for you to read (read will return an error with errno set to ECONNRESET). UNIT III SOCKET OPTIONS, ELEMENTARY UDP SOCKET 1. How will you obtain socket options? Function getsockopt allows the application to request information about the socket. A caller specifies the socket, the option of interest, and a location at which to store the requested information. The operating system examines its internal data structure for the socket and passes the requested information to the caller. The call as the form, gtsockopt(socket, level, optioned, optional, length) 2.How is the function getpeername used? The function getpeername is used to determine the address of the peer to which a socket connects. It has the form, getpeername(socket,desaddr,addrlen) Argument socket specifies the socket for which the address sockaddr that will receive the socket address. Finally argument addrlen is a pointer to an integer that will receive the length of the address. Getpeername only works with connected sockets. 3.Write about getsockname function? Function getsockname returns the local address associated with a socket. It has the form, getsockname (socket, localaddr, addrlen) Argument socket specifies the socket for which the local address is desired. Argument localaddr is a pointer to a structure of type sockaddr that will contain the address, and argument addrlen is a pointer to an integer that will contain the length of the address. 4.List out the mechanism that is used to obtain and set socket options. To add new functions for each new control operation, the designers decided to build-a single mechanism. The mechanism has two operations; getsockopt and setsockopt. 7|Page

10144IT601 Network Programming and Management 5.How will you set socket options? Function setsockopt allows an application program to set a socket option using the set of values obtained with getsockopt. The caller specifies a socket for which the option should be set, the option to be changed, and a value for the option should be set, the option to be changed, and a value for the option. The call to setsockopt has the form, Setsockopt (socket, level, optioned, optional, length) Where the arguments are like those for getsockopt, except that the length argument contains the length of the option being passed to the system. 6.What type of command is used for username and password on server? The command used for, a.username-USER username b.password-PASS password. 7.Which socket libraries is used for the arguments optname, optval and option? Libsocket, is a used for static linking. It is contained in the in/usr/lib. Static linking is strongly discouraged. 8.Define the socket type. Socket type defines the communication properties visible to a user. The internet domain socket provide access to the TCP/IP transport protocol. 9.What are the generate socket options? The generic socket options are, a. SO-BROADCAST socket option. b. SO-DEBUG socket option. c. SO-DONTROUTE socket option. d. SO-ERROR socket option. e. SO-KEEPACTIVE socket option. f. SO-LINGER socket option. g. SO-OOBINLINE socket option. h. SO-RCVBUF and SO-SNDBUF socket options. i. SO-RCVLOWAT and SO-SNDLOWAT socket options. j. SO-TYPE socket option. 10.What are all the TCP socket options? TCP socket options are, a. TCP-KEEPALIVE socket option b. TCP-MAXRT socket option c. TCP-MAXSEG socket option d. TCP-NODELAY socket option e. TCP-STDURG socket option. 11.What are the advantages of socket library routines? Many of the socket library routines provide database services that allow a process to determine the names of machines and network services, protocol port numbers and other related information. For example, one set of library routines provides access to the database of network services. 12.Give the syntax of the system call used to connect the sockets. The syntax is: int connect (int sockfd, struct sockaddr * servaddr, int addrlen);

8|Page

10144IT601 Network Programming and Management 13.Give the syntax of the system call used for receiving connections. The syntax of system call used for receiving connections are , int listen (int sockfd, int backlog); Where, Sockfd ->socket descriptor Backlog ->specifies how many connection requests can be queued by the system. UNIT - IV ADVANCED SOCKETS 1. Define thread. Thread is process. Threads are sometimes called lightweight process. All the threads within a process share the same global memory. This makes the sharing of information easy between the threads, but along with this simplicity comes the problem of synchronization. 2. What is the purpose of IPC? Inter process communication required to pass information between the parent and child after the fork. 3. What are the functions available in threads. There are five function in threads. They are 1. pthread_create function 2. pthread_join function 4. pthread_detach function 5. pthread_exit function

3. pthread_self function

4. What is the use of pthread_create function? When the program is started by exec, a single thread is created, called the initial thread or main thread. Additional thread 5. Write the syntax of getsockopt and setsocketopt. Syntax of getsockopt: int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); syntax of setsockopt: int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t *optlen); 6. what are advantages of fcntl function. The fcntl function provide the following features related to the network programming: 1. Non- blocking I/O: we can set the O_NONBLOCK file status flag using the F_SETFL command to set a socket non blocking. 2. Signal-driven I/O: we can set the O_ASYNC file status flag using the F_SETFL command which causes the SIGIO signal to be generated when the status of a socket changes. 7. Write the syntax of fcntl function. Syntax : Int fcntl ( int fd, int cmd,. /* int arg */ );

9|Page

10144IT601 Network Programming and Management

8. What is use of SO_KEEPALIVE socket option. The SO_KEEPALIVE socket option is set by many TCP servers and automatically terminates a half-open connection. The nice feature of this option is that is handled by TCP layer, without requiring an application level inactivity timer. 9. Name a ICMPv6 socket option. ICMP6 FILTER : This option let us to fetch and set an icmp6-filter structure that specifies which of the 256 possible ICMPV6 message types are passed to the process on a raw socket. 10. What are all the steps involved in socket creation. The steps involved in creating the raw socket are as follows. 1. The socket function creates a raw socket when the second argument is SOCK_RAW. 2. The IP_HDRINCL socket option can be set. 3. bind can be called on the raw socket, but this is rare. 4. connect can be called on the raw socket. but this is rare. 11. what are the characteristics of Ipv6. 1. All the fields in the protocol headers sent or received on a raw Ipv6 socket are in network byte order. 2. All the fields in Ipv6 header and all extension headers are available to the application through the socket options. 3. checksum on raw Ipv6 sockets are handled differently, as described shortly. 12. Define proto structure: A proto structure contain the function pointers, pointers to socket address structures, and other constants. 13. What are the benefits of intel daemon. The benefits are Primary benefit: Intel is that service that are not taking up machine resources. Secondary benefits: Intel is that it does most of the work to establish a connection. 14. What are the descriptions used for the arguments optname, optval, option? The description used for a. optname symbolic constant defined in <sys/socket.h> b. optval point to the value of option c. option point to the length of the value of the option. 15. What is the raw socket? Raw sockets are normally datagram oriented although their exact characteristics are dependent on the interface provided by the protocol.

10 | P a g e

10144IT601 Network Programming and Management 16. Draw the format of ICMPv4 and ICMPv6 echo request and reply message.

UNIT - V SNMP 1. What are the key enhancements of SNMPv2? The key enhancements of SNMPv2 fall into the following categories Structure of Management Information Manager-to-manager capability Protocol operations 2. What are the key concepts introduced in SNMPv2 SMI ? The SNMPv2 SMI introduces four key concepts Object definitions Conceptual tables Notification definition Information modules 3. What are the application types defined in SNMPv2? The following application types are defined in SNMPv2 IpAddress Counter32 Counter64 Unsigned32

Gauge32

4. Define Gauge32: Gauge32 is a nonnegative integer that may increase or decrease, with a maximum value of 232-1. If the maximum value is reached, the gauge remains latched at that value until reset. 5. What are the possibilities for MAX-ACCESS clause? The five possibilities ordered from least to greatest capability, are defined as follows Not-accessible Accessible-for-notify Read-only Read-write Read-create

11 | P a g e

10144IT601 Network Programming and Management 6. Give the syntax of SNMPv2 tables ? A conceptual table has a SYNTAX clause of the form SEQUENCE OF <entry> where, <entry> refers to its subordinate conceptual row. A conceptual row has a SYNTAX clause of the form SEQUENCE {<type1>,<typeN>} where there is one <type> for each columnar object and each <type> is of the form <descriptor><syntax> 7. What are the methods used for row creation in SNMPv2 tables? The two methods used for row creation are CreateAndWait CreateAndGo 8. What are the types of access to management information in SNMPv2? SNMPv2 provides three types of access to management information: Manager- agent request-response Manager-manager request-response Agent- manager unconfirmed. 9. Give the SNMPv2 message structure?

10. What are the principal threats that SNMPv3 is secure against? Modification of information Masquerade Message stream modification Disclosure 11. What are the message handling ? Message handling documents : Transport mapping Message processing & dispatcher Security

12 | P a g e

10144IT601 Network Programming and Management 12. What are the PDU handling? PDU handling documents : Protocol operations Applications

Access control

13. What are the information model document ? Information model documents Structure of management information Textual conventions Conformance statements 14. What are the various SNMPv3 applications ? Command generator applications Command responder applications Notification generator applications Notification receiver applications Proxy forwarder applications 15. What are the MIBs that support SNMPv3 applications ? Management target MIB Notification MIB Proxy MIB 16. What is SNMP? The Simple Network Management Protocol (SNMP) is the most popular protocol in use to manage networked devices. SNMP was designed in the late 80's to facilitate the exchange of management information between networked devices, operating at the application layer of the ISO/OSI model. The SNMP protocol enables network and system administrators to remotely monitor and configure devices on the network. 17. How can we protect our network or system? A number of steps can be taken to improve the security of systems relying on SNMP: Apply a patch from your vendor. Disable all nonessential SNMP software. Filter SNMP access to managed devices to ensure the traffic originates from known management systems. Filter SNMP services at your network perimeter (ingress/egress filtering). Change SNMP community strings from their defaults. Segregate network management traffic onto a separate network. 18. What are managers and agents? SNMP is built around the concept of "managers" and "agents." Manager software makes requests to agent software running on a host or device to gather data on the operational status, configuration, or performance statistics of that system (polling). Some agents allow configuration parameters to be changed by managers, while others provide read-only statistics and configuration information. 19. What protocols/ports does SNMP use? SNMP uses 161/udp for general purpose (request/response) communications, and 162/udp for traps. Additionally, the SNMP multiplexing protocol (smux, defined in RFC1227) uses 199/tcp. Another SNMP extension, the AgentX protocol uses 705/tcp. 13 | P a g e

You might also like