1. Define sockets - SOCKETS Part A A socket is a construct to provide a communication between computers. It hides the underlying networking concepts and provides us with an interface to communicate between computers. 2. Define value result arguments The way in which the length of the structure passed is depends on which direction the structure is being passed from process to kernel or vice versa. The size parameter is passed by value when the function is called and passed by result when the function returns. This type of argument is called value result argument. 3. Write down the different byte manipulation functions bzero,bcopy,bcmp,memset,memcpy,memcmp What is the purpose of address conversion functions The functions inet_aton,inet_ntoa and inet_addr convert IPv4 address between dotted decimal string and its 32-bit network byte ordered binary value. The functions inet_pton,inet_ntop handle both IPv4 and IPv6 address. The letters p and n stands for numeric and presentation. 4. What are the different options and type values available for creating a socket? The different option values are AF_INET, AF_INET6, AF_LOCAL, AF_ROUTE, AF_KEY. The different type values are SOCK_STREAM, SOCK_DGRAM, SOCK_RAW 5. What is the purpose of connect and bind function. The connect function is used by a TCP client to establish a connection with a TCP server. The bind function assigns a local protocol address to a socket. 6. What are the actions performed by listen function? The listen function is called by TCP server and it performs the following actions. It converts the unconnected socket into a passive socket, indicating that the kernel should accept incoming connection requests directed to this socket. CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 1
It specifies the maximum number of connections that the kernel should queue for this socket. 7. Define concurrent servers and iterative servers. The servers that can handle multiple clients simultaneously are called concurrent servers. The servers that can handle multiple clients serially are called concurrent servers. 8. Write down any 8 generic socket options SO_BROADCAST, SO_DEBUG, SO_ERROR, SO_DONTROUTE, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_SNDBUF 9. Define UDP sockets. UDP is a connection less unreliable, datagram protocol. In UDP the client does not establish connection with a server. Instead the client just sends a datagram to the server. 10. What is the purpose of DNS? The domain name system or DNS is used primarily to map between host names and IP addresses. DNS entries are known as resource records (RRs) 11. What is the purpose of resolvers? The client and server applications contact a DNS server by calling functions in a library known as resolver. The common resolver functions are gethostbyname and gethostbyaddr. 12. What are the different Resource records(rr)? The different RR format are A, AAAA, PTR, MX, CNAME 13. Define TCP sockets. TCP sockets provide a simple and effective way to provide connection oriented client server networking. 14. What are the additional facilities supported by raw sockets? Raw sockets are used to read and write ICMPv4, IGMPv4, and ICMPv6 packets. With the raw socket a process can read and write IPv4 data grams with an IPv4 protocol field that is not processed by kernel. With a raw socket a process can build its own IPv4 header using the IP_HDRINCL socket option 15. What are the differences between raw IPv6 sockets with ordinary raw output? All fields in the protocol send or received on a raw IPv6 socket are in network byte order. CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 2
There is no equivalent of IP_HDRINCL socket option with IPv6. Checksums on raw Ipv6 sockets are handled differently using the IPv6 socket option 16. What are the different level constants are available for socket option functions? SQL-SOCKET, IPPROTO_IP, IPPROTO_ICMPV6, IPPROTO_IPV6, IPPROTO_TCP. What are the functions available for set and retrieve the socket options? The functions for set and retrieve socket options are getsockopt and setsockopt 17. Describe different TCP/IP services. echo server return whatever the client sends discard server discards whatever the client sends daytime server returns the date and time in a human readable form 18. What is the purpose of sock program It is used to generate special case conditions that can help us visualize various scenarios without writing individual test programs. 19. List down the different operation modes for sock program. Standard input, standard output client Standard input, standard output server Source client Sink server 20. What are the different functions done by TCP echo client server program? The client reads a line of text from its standard input and writes it to the server. The server reads the line from the network input and echoes the line back to the client. The client reads the echoed line and prints it on its standard output 21. What is the purpose of trace route program? The trace route program allows us to determine the path that IP datagrams follow from our host to some other destination. 22. What is the purpose of ping program? The ping program is a utility program that is used to fetchecho replies from the server. 23. What is the purpose of netstat program? It shows the status of networking endpoints. It shows the multicast groups that a host belongs to on each interface. It shows the pre protocol statistics with the s option. CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 3
It displays the routing table with the r option and the interface information with the i option. 24. What are the three Socket Address Structure? IPV4 SOCKET address structure / internal socket address structure. Generic Socket Address Structure. IPV6 SOCKET Address Structure. 25. What are the two byte orders? Little endian byte order Low order byte at the starting address, known as little endian. Big endian byte order High order byte at the starting address. 26. Write the syntax of function to convert host byte order into network byte order.? #include<netinet/in.h> unit 16-t htons(unit 16-t host 16 bit value); unit 32-t htonl(unit 32-t host 32 bit value); 27. How do the TCP client established a connection with a TCP server? Connect function is used to establish a connection with TCP server. int connect(int sockfd, const struct sockaddr *servaddr, socklen_t addelen); 28. What is the use of bind function? The bind function assigns a local protocol address to a socket. With the Internet protocols the protocol address is the combination of either a 32-bit IPV4 address or a 128-bit IPV6 address, along with 16-bit TCP or UDP port number. 29. Explain the function listen with Syntax? The listen function is called only by a TCP server and it performs two actions: When a socket is created by the socket function its assumed to be an active socket, i.e. a client socket that will issue a connect. The listen function converts an unconnected socket into a passive socket, indicating that the kernel should accept incoming connection requests directed to this socket. CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 4
The second argument to this function specifies the maximum number of connections that the kernel should queue for this socket. int listen(int sockfd, int backlog); 30. What are the two queues maintained for a listening socket? A incomplete connection queue, which contains entry for each SYN that arrived from a client for which the server is awaiting completion of the TCP three way hand shake. A completed connection queue, which contains an entry for each client with whom the TCP three- way handshake has completed. 31. Explain accept function? Accept is called by a TCP server to returns the next computed connection from the front of the completed connection queue. If the completed connection queue is empty, the process is put to sleep. int accept(int sockfd, struct sockaddr *cliaddr, socklen_t *addrlen); 32. How do you terminate a TCP connection? The normal UNIX close function is also used to close a socket and terminate a TCP connection. int close(int sockfd); 33. Define I/O multiplexing? I/O multiplexing is the capability to tell the kernel that we want to be notified if one or more I/O condition are ready i.e. input is ready to be read. 34. Specify two examples where we can use I/O multiplexing? When a client is handling multiple descriptors i.e. standard I/O and socket I/O. If a TCP server handles both a listening socket and its connected sockets. 35. What are the I/O modules available in Unix? Blocking I/O. Non Blocking I/O. CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 5
I/O multiplexing. Signal driven I/O. Asynchronous I/O. 36. Define synchronous I/O operation? A synchronous I/O operation is a I/O operation which causes the requesting process to be blocking until that I/O operating completes. 37. Define asynchronous I/O operation? An asynchronous I/O is a I/O operation which does not cause the requesting process to be blocked. 38. 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. 39. What is the limitation of close function? Close decrements the descriptor s reference count and closes the socket only if the count reaches O. Close terminates both directions of data transfer, reading and writing. 40. Explain shutdown function with syntax To terminate network connection shutdown function is used. int shutdown (int sockfd, int howto); 41. When the socket is ready for reading? Specify two conditions When the following conditions are true, the socket is ready for reading. Number of bytes of data in the socket receive buffer is greater than or equal to the current size of the low-water mark for the socket receive buffer. The read-half of the connection is closed. 42. How do you get socket options? To get socket options the following function is used. int getsocket(int sockfd, int level, int optname, void *optcal, socklen-t *optlen); CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 6
43. How do you set socket options? To set socket options the following function is used. int set solkopt(int sockfd, int level, int optname, void *optcal, socklen-t *optlen); 44. Which socket option is used to send broad cast message? SO-BROADCAST option is used to send broadcast message. Broadcasting is supported for only data gram sockets and only on network that support the concept of a broadcast message Example: Ethernet An application must set this socket option before sending a broadcast data gram. 45. Define pending error? When an error occurs on a socket, the protocol module in BSD kernel sets a variable named so error for that socket to one of the standard Unix Exxx values. This is called the pending error for the socket. 46. Explain receive low water mark and send low water mark? Receive low-water-mark; Amount of data that must be in the socket receive buffer for select to return readable default value is 1. send low-water-mark; Amount of available space that must exist in the socket send buffer for select to return writable default value is 2048 for TCP sockets. 47. What is the purpose of Nagle algorithm in TCP sockets? (MAY 04) The purpose of the Nagle algorithm is to reduce the number of small packets on a WAN. The algorithm states that if a given connection has out standing data, then no small packets will be sent on the connection until existing data is acknowledged. 48. Describe the characteristics of UDP protocol? (MAY 04) UDP User Data gram Protocol. It is a Connection less Protocol. It is a Unreliable Protocol. CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 7
49. Define Domain Name System? Domain name system, or DNS is a system to map between host names and IP Addresses. A host name can be either a simple name, such as Solaris or a fully qualified domain name such as Solaris kohala.com. 50. What are the resolver functions? gethostbyname maps host name into it and IP address. gethostbyaddr reverse mapping. 51. Explain gethostbyname function. To lookup the host name and return all the IP addresses for the host. #include<netdb.h> struct hostent *gethostbyname(const char *hostname); 52. Explain gethostbyaddr function? This function gethostbyaddr takes a binary IP address and tries to find the host name corresponding to that address. struct hostent *gethostbyaddr(const ahar *addr, size-t cen, int family); 53. How do you get service details? To look up a service given its name. #include<netdb.h> struct serv *getservbyname(const char *servname const char *protoname); CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY 8