UNIT IV- SOCKETS Part A

Similar documents
Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!

Review. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection

Outline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

Oral. Total. Dated Sign (2) (5) (3) (2)

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

Introduction to Socket Programming

Elementary TCP Sockets

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK UNIT 1

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

Group-A Assignment No. 6

Chapter 6. The Transport Layer. Transport Layer 3-1

Network Communication

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

CSE 124 Discussion Section Sockets Programming 10/10/17

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS

Tutorial on Socket Programming

Socket Programming for TCP and UDP

TCP: Three-way handshake

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

CSE 333 Section 8 - Client-Side Networking

Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction!

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Multicast on a LAN 3/4. Multicast on a LAN 2/4. Multicast on a WAN. Multicast on a LAN 4/4

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur QUESTION BANK

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

IPv4 and ipv6 INTEROPERABILITY

STUDY OF SOCKET PROGRAMMING

Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현

Sockets 15H2. Inshik Song

Ports under 1024 are often considered special, and usually require special OS privileges to use.

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

CSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1

Networked Applications: Sockets. End System: Computer on the Net

NETWORK PROGRAMMING AND MANAGEMENT 1 KINGS DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK

MC1751 UNIX and Network programming. Short questions and answers

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks

A. Basic Function Calls for Network Communications

Computer Networks Prof. Ashok K. Agrawala

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

MARIA COLLEGE OF ENGINEERING AND TECHNOLOGY, ATTOOR DEPARTMENT OF INFORMATION TECHNOLOGY NETWORK PROGRAMMING MANAGEMENT 2 MARKS QUESTIONS & ANSWERS

Agenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control

CS 3516: Computer Networks

Networked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

EEC-484/584 Computer Networks

Socket Programming TCP UDP

Network programming(ii) Lenuta Alboaie

Network programming(i) Lenuta Alboaie

A Client-Server Exchange

System Programming. Sockets

LESSON PLAN. Sub. Code & Name : IT2351 & Network Programming and Management Unit : I Branch: IT Year : III Semester: VI.

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Communication. Sockets (Haviland Ch. 10)

NETWORK PROGRAMMING. Ipv4 and Ipv6 interoperability

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

Introduction! Overview! Signal-driven I/O for Sockets! Two different UDP servers!

Network Socket Programming - 3 BUPT/QMUL

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs

CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

CSE 333 SECTION 8. Sockets, Network Programming

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

Network Socket Programming - 3 BUPT/QMUL

Programming with TCP/IP. Ram Dantu

CptS 360 (System Programming) Unit 17: Network IPC (Sockets)

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

UNIX Sockets. COS 461 Precept 1

Chapter 8: I/O functions & socket options

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

Introduction to Socket Programming

Network Programming. Multicast on a LAN 1/4. Sending & Receiving Multicast Messages. Multicasting II. Dr. Thaier Hayajneh

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C.

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Networks. Practical Investigation of TCP/IP Ports and Sockets. Gavin Cameron

Socket Programming(2/2)

CS 640: Computer Networking

CLIENT-SIDE PROGRAMMING

Computer Network Lab, SS Fachgebiet Technische Informatik, Joachim Zumbrägel. Overview. Sockets. Sockets in C.

CSE 333 SECTION 7. C++ Virtual Functions and Client-Side Network Programming

The Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4

Department of Computer Science

Computer Network Programming. The Transport Layer. Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

CS321: Computer Networks Introduction to Application Layer

Socket Programming 2007/03/28

Unix Network Programming

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

Server-side Programming

Redesde Computadores(RCOMP)

The User Datagram Protocol

Overview. Administrative. * HW# 5 Due next week. * HW# 5 : Any Questions. Topics. * Client Server Communication. * 12.

CS 428/528 Computer Networks Lecture 01. Yan Wang

CS321: Computer Networks Socket Programming

Transcription:

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