Noorul Islam College of Engineering, Kumaracoil: Department of Information Technology
Noorul Islam College of Engineering, Kumaracoil: Department of Information Technology
Noorul Islam College of Engineering, Kumaracoil: Department of Information Technology
SUBJECT CODE: IT61 SUBJECT NAME: NETWORK PROGRAMMING AND MANAGEMENT CLASS: S6 IT
UNIT I ELEMENTARY TCP SOCKETS 1. What is a socket? A socket is a logical endpoint for communication between two hosts on a TCP/IP network. A socket is uniquely identified by 3 attributes. The hosts IP address The type of service needed. The port number. 2. What are the services provided by TCP? Connections between client and server Reliability Sequencing Flow Control Full duplex communication 3. What is passive open? The server prepares to accept an incoming connection by calling socket, bind and listen functions. This is called passive open. 4. What is active open? The client connects to the server by calling the connect function. It causes the client to send a SYN segment which consists of initial sequence number for the data .This is called Active open. 5. What is active and passive close? The client/server side which calls the close function means it performing an active close. It receives the FIN segment from the other end means perform the passive close. 6. What are the three different categories of ports? The well known ports (0-1023) The registered ports (1024-49151) The dynamic ports (4912-65535) 7. What are well known ports? Well known ports are used to identify well known services. port numbers from 01023 are well known ports. 8.What are registered ports? Registered ports are not controlled by IANA.Port numbers from 1024 -49151 are registered ports. These ports are used according to the convenience of the network community.
9.What are dynamic ports? Dynamic ports are short-lived ports. These ports are used only by TCP/UDP client. port numbers from 49152-65535 are dynamic ports. 10.What are Socket address structure? Socket address structure is pass d as argument to the socket function. It is used to set thee the properties of socket, such as 1.Length 2.Family 3.Port number 4.IP address 11. What is host byte order? The byte ordering followed by a given system can be in two ways Little endian byte order or big endian byte order. This is called host byte order. 12. What is network byte order? In a network the sending protocol stack and the receiving protocol stack must agree or the order in which the bytes are transmitted .This is network byte order. 13. What is the use of htons, htonl, ntohs, ntohl functions? htons Converts 16 bit value from host byte order to network byte order. htonl Converts 32 bit value from host byte order to network byte order. ntohs Converts 16 bit value from network byte order to host byte order. ntohl Converts 32 bit value from network byte order to host byte order. 14.What is the use of inet_aton function? Declaration: int inet_acton(const char * strpts,1 struct in_addr *addrptr); Use:Converts the character string pointed to by strptr into its 32-bit binary network byte ordered value.The value is stored in addrptr. 15.What is the use of inet_addr function? Definition: in_addr_t inet_addr(const char *strptr); Use:Converts the string pointed to by strptr into its 32-bit binary network byte ordered value and it returns the value as result. 16.What is the use of inet_ntoa function? Definition: char *inet_ntoa(struct in_addr inaddr); Use:Converts a 32-bit binary network byte ordered IP address into its dotted decimal string.
17.What is the use of inet_pton function? Definition: int inet_pton(int family,const char *strptr,void *addrptr); Use:Converts the string pointed by strptr into binary and stored it in addrptr. 18.What is the use of inet_ntop function? Definition: const char *inet_ntop(int family,const void *addrptr,char *strptr,size_t len); Use:Converts the numeric (addrptr) to presentation (strptr). len argument is the size of the destination. Family argument can be either AF_INET or AF_INET6. 19.What are the various Elementary TCP client socket function? 1.Socket 2.Connect 3.Write 4.Read 5.Close 20.What is the use of socket function? Socket function is used to create a socket to establish a connection.Definition of socket function: int socket(int family,int type,int protocol);socket function returns the non-negative integer value called socket descriptor(sockfd). 21.What is the use of the connect function? The connect function is used by a TCP client to establish a connection with a TCP server. Definition:int connect(int sockfd,const struct sockaddr *servaddr,socklen_t addrlen); Return:0 if ok,-1 on error. 22. What is the need for bind system call? The bind function assigns a local protocol address to the socket.The prototype of bind as follows: int bind(int sockfd,const struct sockaddr *myaddr,socklen_t addrlen); *myaddr will be binded to socket sockfd *addrlen is the length of myaddr 23. What is the need for listen system call? The listen function converts the socket(created by server)into listening socket. This socket is passive socket. The kernel will accept incoming connection between requests only through listen socket. The prototype of listen as follows: int listen(int sockfd,int backlog); *backlog specifies the maximum number of connections in the queue.
24. What are the uses of fork system call? fork function is used to create a new process. The prototype as follows: pid_t fork(void); *returns 0 in child Process ID of child in parent -1 on error 25. What is the need of exec system call? Exec replaces the current process image with the new program file which starts at the main function.
UNIT II APPLICATION DEVELOPMENT 1. What is a signal? A signal is a notification to a process that an event has occurred. They are also called software interrupts. 2. What is the use of SIGCHILD signal? The SIGCHILD signal is sent by the kernel whenever a process terminates, to the parent of the terminating process. 3. What is disposition? Every signal has some action associated with it. The associated action is called disposition. 4. What is the use of sigaction function? The sigaction function is used to set the disposition of the signal 5. What is a Zombie process? A Zombie process is one that has completed its execution but still has an entry in the process table, allowing the process that started it to read its exit status. 6. What is the difference between wait and waitpid function? Wait-If a process calls wait () and if it has one or more children that are executing, then wait blocks until the first of the existing children terminate. 7. What is the use of FIN signal? When the client terminates the connection, it sends the FIN signal to the server and then closes the connection. 8. Mention the five I/O Models? Blocking Non blocking I/O Multiplexing Signal driven I/O Asynchronous I/O 9. What are the two phases of an input operation? 1. Waiting for the data to ready 2. Copying the data from kernel to the process
10. What is meant by polling? When an application calls recvfrom function repeatly until the data is ready, it is called polling. 11. What is a select function? The select function allows the process to instruct the kernel to wait for any one of multiple events to occur and it wake up the process. 12. What is a shutdown function? int shutdown(int sockfd,int howto); sockfd-socket descriptors to be shutdown howto-can take one of the following values. 1.SHUT-RD-The read half of the connection is closed 2.SHUT-WR-The write half of the connection is closed 3.SHUT-RDWR- The write &read half of the connection is closed 13. Differntiate shutdown and close function? Shutdown We can initiate connection Termination without the reference count Close Connection termination is initiated only if reference count Reaches 0 It is only possible to terminate the connections on both sides of data transfer
It is possible to terminate the Connections in three ways Reading side Writing side Both sides
14. What is denial of service attacks? When a server is handling multiple clients there is a possibility that the server can block in a function call related to a single client .It can hang the server and deny service to all other clients. This is called a denial of service attack. 15. What is the use of pselect function? Pselect function is the same as the select function but it increase the time precious from microseconds to nanoseconds. Also it takes a new argument that enables us to avoid race conditions when signals are being caught. 16. What are the medium of communications of the signal? Signals can be sent: By one process to another process(or to itself) By the kernel to a process
17. What are the three choices of disposition? The three choices of disposition are: 1. Default Handler: We can set the disposition by setting its disposition to SIG_DFL 2. User defined signal Handler We can provide a function that is called whenever a specific signal occurs. 3. Ignoring the signal: We can ignore a signal by setting its disposition to SIG_IGN. 18. Which two signals cannot be ignored and cannot be caught? 1. SIGKILL 2. SIGSTOP 19. List the uses of I/O Multiplexing When a client is handling Multiple descriptors When a client is handling Multiple sockets at the same time If a server handles both TCP and UDP If a server handles multiple services If a server handles multiple protocols. 20. What is the advantage of I/O multiplexing model? The select call requires two system calls instead of one.
UNIT-III SOCKET OPTIONS, ELEMENTARY UDP SOCKETS 1. What is the use of getsockopt function? The getsockopt function is used to get the values of socket options,that was set already.The prototype of getsockopt as follows: Getsockopt(sockfd,level,optname,*optval,*optlen); 2. What is the use of setsockopt function? The setsockopt function was used to set the values for the socket options.The prototype of setsockopt is as follows: Setsockopt(sockfd,level,optname,*optval,optlen); Level specifies code(general socket code or protocol specific code) Optname is the option name such as Broadcast,Debug etc. Optval is the value of the optname. Optlen is the length of the option. 3. What options are inherited by a connected TCP socket from the listening socket? 1.SO_DEBUG 2.SO_DONTROUTE 3.SO_KEEPALIVE 4.SO_LINGER 5.SO_OOBINLINE 6.SO_RCVBUF 7.SO_SNDBUF 4. Mention any four Generic Socket options? 1.SO_BROADCAST 2.SO_DEBUG 3.SO_DONTROUTE 4.SO_ERROR 5. What is SO_DEBUG socket option? The SO_DEBUG option enables or disables the ability of the kernel to keep track of detailed information about all the packets sent or received by TCP.This option is supported only by TCP. 6. What is SO_KEEPALIVE socket option? When the SO_KEEPALIVE option is set for a TCP socket and if no data has been exchanged across the socket in either direction for 2 hours, TCP automatically sends a keep alive probe to the peer. The purpose of this option is to detect if the peer host crashes. 7. What are the three scenarios resulted from SO_KEEPALIVE socket option? 1. The peer responds with the expected ACK. 2. The peer responds with an RST. 3. There is no response from the peer to the keep alive signal.
8. What is the purpose of SO_RCUBUF and SO_SNDBUF socket options? Every socket has a send buffer and a receive buffer.The default size of TCP send buffer and receive buffer is 4096 bytes.The SO_RCVBUF option is used to change the default size of receive buffer.The SO_SNDBUF option is used to change the default size of send buffer. 9. What is the use of SO_RCVLOWAT and SO_SNLOWAT socket option? The SO_RCVLOWAT is used to change the default value of the receive lowwater mark. The SO_SNDLOWAT is used to change the default value of the Send low-water mark. 10. What is the use of SO_RCVTIMEO and SNDTIMEO socket options? The SO_RCVTIMEO is used to place a timeout on the receiving socket. The SO_SNDTIMEO is used to place a timeout on the receiving socket. 11. What are various IPV4 socket options? 1.IP_HDRINCL 2.IP_OPTONS 3.IP_RECVDSTADDR 4.IP_RECVIF 5.IP_TOS 6.IP_TTL 12. What is the purpose of IP_HDRINCL socket option? The IP_HDRINCL socket option is used to build our own IP header for all the datagrams that we send on the raw socket. 13. What is the use of IP_OPTIONS socket option? The IP_OPTIONS socket option is used to set IP options in the IPV4 header. For example, the source route option can be set to either strict or loose. 14. What is the use of IP_RECVDSTADDR socket option? The IP_RECVDSTADDR socket option causes the destination IP address of a received UDP datagram to be returned as uncillary data by recvmsg. 15. What is the use of IP_RECVIF socket option? The IP_RECVIF socket option causes the index of the interface on which a UDP datagram to be returned as uncillary data by recvmsg. 16. What is the purpose of ICMP6_FILTER option? The ICMP6_FILTER option is used to set and fetch an icm6_filer structure that specifies which of the 256 possible ICMPv6 message types are passed to the process on a raw socket.
17. Mention some IPv6 socket options? 1. IPv6_ADDRFORM 2. IPv6_CHECKSUM 3. IPv6_DSTOPTS 4. IPv6_HOPLIMIT 5. IPv6_NEXTHOP 6. IPv6_PICTINFO 18. Mention some of the TCP socket options? 1. TCP_KEEPALIVE 2. TCP_MAXRT 3. TCP_MAXSEG 4. TCP_NODELAY 5. TCP_STDURG 19. List the steps involved in creating a UDP Echo client? 1. Create a UDP socket. 2. Read a line from standard input (fgets) 3. Send the line to the server using sendto. 4. Read back the servers echo using recvfrom 5. Print the echoed line to standard output using fputs. 20. What is the use of sendto function? The sendto function is used by UDP to send a datagram packet to its peer.The function usage is as follows: Sendto(sockfd,*buff,nbytes,flags,*to,addrlen); *returns number of bytes written if OK,-1 on error. 21. What is the use of recvfrom function? The recvfrom function is used by UDP to receive a datagram packet from its peer.The usage of this function s as follows: Recvfrom(sockfd,*buff,nbytes,flags,*from addrlen); *returns number of bytes read if OK,-1 on error. 22. What is Domain Name System? The Domain Name System,or DNS,is used to map between hostnames and IP addresses.A host name can either be a simple name,or a FQDN_Fully qualified domain name 23. What is the use of getservby name functrion? The getservby name functrion looks up a service given its name and an optional protocol. Getservbyname(*servname,*protoname);
Returns:nonnull pointer if OK NULL on error Servname is the service name Proto name is the protocol name. 24. What is the use of getservbyport function? The getservbyport function looks up a service given its port number and an opyional protocol. Getservbyport (port,*protoname); Returns:nonnull pointer if OK NULL on error Port is the port number Protoname is the protocol name. 25. What is the purpose of the SO_REUSEADDR socket option? The SO_REUSEADDR socket option serves four different purposes 1. Allows a listening server to start and bind its well known port even if previously established connections exists. 2. Allows multiple instance of the same server to started on the same port,as long as each instance binds a different local IP address 3. Allows a single process to bind the same port to multiple sockets, as long as each bind specifies a different local IP address. 4. Allows completely duplicate bindings. 26. Draw a diagram of a single echo client-server using UDP? fgets UDP Client sendto UDP Server
UNIT-IV ADVANCED SOCKETS 1. What are the rules of Dual-stack host in dealing with listening socket? A listening IPv4 socket can accept incoming connections from IPv4 clients. If a server has a IPv6 listening socket which has wild card address, then the socket can accept incoming connections from either IPv4 or IPv6. 2. Give note on IPV6_ADDRFROM option. IPV6_ADDRFROM provide socket transformation between IPv4 and IPv6 applications. Applications already developed using IPv4 will have no knowledge of this socket option; this implies that all IPv4\IPv6 socket transformation should only be performed by IPv6 applications. 3. What are the shared information by all threads within a process? All threads within a process share the following: Process instructions Most data Open files(e.g., descriptors) Signal handlers and signal dispositions Current working directory User and group IDs 4. What are the information each thread possess? Each thread has its own Thread ID Set of registers, including program counter and stack pointer Stack (for local variables and return address) Errno Signal mask Priority 5. What are the basic functions related to threads? pthread_create() Function pthread_join() Function pthread_selg() Function pthread_detach() Function pthread_exit() Function 6. How threads are created? When a program is started by exec, a single thread is created, called the initial thread or main thread. Additional threads are created by pthread_create. #include<pthread.h> int pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*func)(void *arg); //Return:0 if OK, positivwe Exxx value on error
7. Give a note on pthread_join function #include<pthread.h> int pthread_join(pthread_t tid, void **status); //Returns : 0 if OK, positive Exxx value on error The pthread_join function shall suspend execution of the calling thread until the target tid terminates, unless the target tid has already terminated. On return from a successful pthread_join() call with a non_NULL status argument, the value passed to pthread_exit() by the terminating thread shall be made available in the location referenced by status. 8. Give a note on pthread_self() function #include<pthread.h> prthread_t pthread_self(void); //Return the thread ID of the calling thread Each thread has an ID that identifies it within a process. The thread ID is returned by pthread_create and it was used by pthread_join. A thread fetches this value for itself using pthred_self. That is this function return the thread ID of the calling thread. 9. Give a note on pthread_detach() function This function is commonly called by the thread that wants to detach itself. #include<pthread.h> int pthread_detach(pthread_t tid); //Returns: 0 if OK, positive Exxx value on error The pthread_detach function marks the threads internal data structure for deletion. 10. Give a note on pthread_exit() function The pthread_exit function terminates the calling thread returning the value given by status to any thread that has called pthread_join for the calling thread. #include<pthread.h> void pthread_exit(void *status); //Returns no value 11. How threads are terminated? There are two ways for a thread to terminate the function that starts can return. Since this function must be declared as returning a void pointer that return value is the exit status of the thread. If the main function of the process returns of if any thread calls exit, the process terminates. 12. What are the advantages for threads? Threads have some advantages of(multi) processes. Less time to create a new thread than a process, because the newly created thread uses the current process address space. Less time to terminate a thread than a process. Less time to switch between two threads within the same process, partly because the newly created thread uses the current process address space.
Less communication overheads-communication between the threads of one process is simple because the threads share everything: address space, in particular. So, data produced by one thread is immediately available to all the other threads.
13. What do you mean by Threaded Server? The threaded server is probably the simplest real server type. A server program almost always needs to handle more than one connection at a time. The reason is, since each connection gets its own thread, each thread can use simple blocking I/O on the socket. Each thread handles its connection more or less identically to the way the basic server handles each connection. 14. Define mutex. A mutex is a thread synchronization object, it can be used by threads to control access to a shared resource. A mutex can be locked to indicate a resource is in use, and other threads can then block on the mutex to wait for the resource. Mutex is short for mutual exclusion. 15. Explain lock and unlock of mutexes. Multiple threads updating a shared variable, is the simplest problem. The solution is to protect the shared variable with a mutex(which stands for mutual exclusion) and access the variable only when we hold the mutex. In terms of pthreads, a mutex is a variable of type pthread_mutex_t. 16. How mutex variable is initialized? Mutex variable must be declared with type pthread_mutex_t, and must be initialized before they can be used: Statically, when it is declared. For example: pthread_mutex_t mymutex=PTHREAD_MUTEX_INITIALIZER; Dynamically pthread_mutex_init(mutex,attr) This method permits setting mutex object attributes(for default setting use NULL). 17. Give the uses of conditional variables in threads. While mutexes implement synchronization by controlling thread access to data, condition variables allow threads to synchronize based upon the actual value of data. Without condition variables, The programmer would need to have threads continually polling(usually in critical section), to check if the condition is met. A condition variable is a way to achieve the same goal without polling. Useful when a thread needs to wait for a certain condition to be true.
18.Write about pthread_cond_wait. Pthread_cond_wait(cv,lock) is called by a thread when it wants to block and wait for a condition to be true. It is assumed that the thread has locked the mutex indicated by the second parameter. The thread releases the mutex, and blocks until it can acquire the mutex, and once acquired, it returns from the pthread_cond_wait() call. 19. What are the features provides by the raw socket? Raw sockets provide three features not provided by normal TCP and UDP sockets: Raw sockets let us read and write ICMPv4, ICMPv4, and ICMPv6 packets. With a raw socket, a process can read and write IPv4 datagrams with an IPv4 protocol field that is not processed by the kernel. Most kernels only process datagrams containing values of 1(ICMP) 3(IGMP),6(TCP), and (UDP). With a raw socket, a process can build its own IPv4 header using the IP_HDRINCL socket option.
20. What is pending error? When an error occurs on a socket, the kernel sets a variable name so_error to one of standard values. This is called the pending error. 21. What is SO_ERROR socket option? When an error occurs on a socket, the kernel will set a variable named so_error to standard value. By using so ERROR option. the process can obtain the value of that variable so error. 22. What is the purpose of the ICMP6_FILTER option? The ICMP6_FILTER OPTION is used to set and fetch an icmp6_filter structure that specifices which of the 256 possible ICMP6 message t types are passed to the process on a raw socket.
UNIT-V SNMP 1. What is the purpose of management station in network management? Management station serves as the interface for the network manager to work on the network management System. 2. What is the use of Management agent? The Management agent responds to requests for information and actions from the management station.The management agents asynchronously provide the management station with important but unsolicited information. 3. What is managed device? A managed device is a network node that contains an SNMP agent and that resides on a managed network.Managed devices collect anad store managed information and make this information available to NMSs using SNMP.managed devices,sometimes called network elements ,can be routers and access servers,switches and bridges,hubs,hosts,or printers. 4. Define MIB The MIB is a collection of access points at the agent for the management station.A management station performs the monitoring function by reterving the value of MIB objects. 5. What re the key capabilities of SNMP? get-Enables the management station to retreive the value of objects at the agent set--Enables the management station to set the value of objects at the agent trap--Enables the manaement station to notify the value of objects at the agent. 6. What are the types of messages that a management application of the management station issue? GetRequest, GetNextrequest and SetRequest are the three types of messages that a management application of the management station 7. What are the objectives Of MIB? The object or objects used to represent a particular resource must be same at each system A common Scheme for representation must be used to support interoperability. 8. What is SMI? It is the Structure of Management Information which defines the data types that can be used in the MIB and specifies how resources within the MIB are represented and named. The SMI doesnt support the creation or retrieval of complex data structure.
9. Define MIB Structure? All managed objects in the SNMP managed environment are arranged in a hierarchical or tree structure, The leaf Objects of the tree are the actual managed objects, each of which represents some resource, activity or related information that is to be managed .The tree structure itself defines a grouping of objects into logically related sets. 10. What are the four nodes specified under internet node of the SMI document? Directory Management Experimental Private 11. How are we to define objects? Define a new type called Object and every object in the MIB would be of this type. Use a macro to define a set of related types used to define managed objects. 12. What are the data types permitted in defining MIB objects in UNIVERSAL class? Integer Octet String Null Object identifier Sequence. 13. Mention the subgroups of the mib-2 group? System Interfaces Address translation IP ICMP TCP and UDP EGP(external gateway Protocol) Transmission. 14. State the information provided by system group? It provides the general information of the managed system. The informations are services supported by the system. The informations are services supported by the system and the up time of the system, of the managed system.
15. Mention the information contained in the IP group? The ip group contains information relevant to the implementation and operation of IP layer. This group contains some basic counters of traffic flow into and out of the Ip layer. Three tables namely ipAddrtable, ipRouteTable and IpNettoMediaTable.
16. State the elements of Address translation group? The address translation group has a single table. Each row in the table corresponds to one of the physical interfaces of the system. The row provides a mapping from a network address to physical address. 17. State the goals of RMON? Off-line operation Proactive monitoring Problem detection and reporting Value added Data Multiple Managers 18. What are the Key concepts of SNMPV2 SMI? Object Definitions Conceptual tables Notification Definitions Information modules 19. State the types of access to the management information? Manager-agent request-response Manager-Manager request-response Agent-Manager 20. What are the applications of SNMPV3? Command generator application Command responder Application Notification Originator Application Proxy forwarder Application 21. What are the elements of VACM? Groups, Security level, Context, MIB views and Access policy are the five elements of VACM. 22. State the Characteristics of View-based Access control Model? It determines whether access to a managed object in a local MIB by a remote principal should be allowed It makes use of a MIB that defines the access control policy for this agent, and makes it possible for remote configuration to be used.
23. What are the key elements of TCP/IP network management? Management station Management agent Management information base Network management protocol.
24. What are the advantages of trap directed polling? Trap directed polling can result in substantial savings of network capacity and agent processing time. 25. What is SNMP? SNMP stands for Simple Network Management Protocol. It was designed to be an application protocol. For a stand alone management station, a manager process achieves network management using SNMP.