* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download sockets
Survey
Document related concepts
Wireless security wikipedia , lookup
Piggybacking (Internet access) wikipedia , lookup
Deep packet inspection wikipedia , lookup
Computer network wikipedia , lookup
Dynamic Host Configuration Protocol wikipedia , lookup
Distributed firewall wikipedia , lookup
Network tap wikipedia , lookup
Airborne Networking wikipedia , lookup
Wake-on-LAN wikipedia , lookup
Remote Desktop Services wikipedia , lookup
Cracking of wireless networks wikipedia , lookup
Internet protocol suite wikipedia , lookup
Zero-configuration networking wikipedia , lookup
Recursive InterNetwork Architecture (RINA) wikipedia , lookup
Transcript
NP Lab Experiment No. : Date: Sample Viva Questions & Answers What is Network? A network is an interconnection of devices. What is networking? Networking is the communication between the interconnected devices. What is NIC? NIC is called Network Interface Card. It forms an interface between the networked device (Computer) and the Ethernet (LAN). It is often referred as MAC. It has a physical address having 48 bits. What is the function of Hub, Switch and Router? Hub is a layer-1 device generally used to connect all devices on a network so that they communicate with each other. It always does broadcasting. Switch is a layer-2 device which is also used to connect all devices on a network so that they communicate with each other. However Switches for the first time do broadcast and afterwards it will do unicast data communication. Bridges work similar to Switches with the main difference in number of ports and switching speed which is higher in Switch. Bridges are now obsolete. Router is a layer-3 device which is used to connect two or more different networks. It allows communication between two or more different networks present in different geographical locations. The important function is routing of packets based on IP address hence it is called router. Explain the difference Peer to Peer (Workgroup) and Client Server Network Model? Peer to Peer Model Client Server Model Peer to Peer or Workgroup Model: Logical grouping of computers connected together. Every System maintains its own local database of user accounts. Logon locally No server is present in the network Each machine act as client as well as server Used for small group of users. Less expensive to implement. Does not require specialized N/W administration software and Less Secure Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: Client Server Model: It is domain model having centralized server maintaining all user accounts of connected computers in the network. Used for enterprise Networks. Provides better security. Requires Expensive and powerful hardware for server. User data is inaccessible if server is down. Has a single point of failure. What is Service interface: How upper layer entities interact with lower layer entities. The abbreviation API stands for Application Programming Interface What is a socket? It is a network programming interface. It is used for interprocess communication over a network. It is used by a process to communicate with a remote system via a transport protocol. It needs an IP address and a Port number Sockets were first introduced in Berkeley Unix. Nowadays it is commonly supported by all modern operating systems for interprocess communication over a network. Sockets can be used in a single computer system for inter-process communication (the Unix domain) and also for communication across computer systems (the Internet domain). Note: To the kernel, a socket is an endpoint of communication. To an application, a socket is a file descriptor that lets the application read/write from/to the network. All Unix I/O devices, including networks, are modeled as files. What is the purpose (Usages) of Sockets? Network applications use sockets at some level, often using higher level protocols on top of sockets File transfer apps (FTP), Web browsers (HTTP), Email (SMTP/ POP3), etc… Simplify and expedite application development process Sockets provide an interface for programming networks at the transport layer. Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Application Transport Date: Application SOCKETS Transport Network Network Link Link port A server (program) runs on a specific computer and has a socket that is bound to a specific port. The server waits and listens to the socket for a client to make a connection request. server Connection request Client port Zahed Shareef port port If everything goes well, the server accepts the connection. Upon acceptance, the server gets a new socket bounds to a different port. It needs a new socket (consequently a different port number) so that it can server continue to listen to the original socket for connection requests while serving the connected client. Connection ( ) Client 160310737044 NP Lab Experiment No. : Date: Generic socket address: struct sockaddr { unsigned short sa_family; protocol family */ char sa_data[14]; address data. */ }; /* /* Internet-specific socket address: struct sockaddr_in { unsigned short sin_family; family (always AF_INET) */ unsigned short sin_port; network byte order */ struct in_addr sin_addr; network byte order */ unsigned char sin_zero[8]; sizeof(struct sockaddr) */ }; /* address /* port num in /* IP addr in /* pad to How does a client find the server? The IP address in the server socket address identifies the host (more precisely, an adaptor on the host). The (well-known) port in the server socket address identifies the service, and thus implicitly identifies the server process that performs that service. Write examples of well known ports Port 7 : Echo Server Port 13 : Daytime server Port 21 : FTP Server Port 23 : Telnet server Port 25 : Simple Mail Transfer Protocol (SMTP) Server Port 37 : Time Server Port 53 : DNS Server Port 80 : (HTTP )Web server What is a Daemon? A daemon is a process that executes in the background. Servers are long-running processes (daemons). Created at boot-time (typically) by the init process (process 1) Run continuously until the machine is turned off. What is a Server? Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: A machine that runs a server process is also often referred to as a “server.” What is network programming? In computing, network programming, essentially identical to socket programming or client-server programming, involves writing computer programs that communicate with other programs across a computer network. The program or process initiating the communication is called a client process, and the program waiting for the communication to be initiated is the server process. The client and server processes together form a distributed system. The communication between the client and server process may either be connection-oriented (such as an established TCP virtual circuit or session), or connectionless (based on UDP datagrams). What is Inter-Process Communication (IPC)? Inter-Process Communication (IPC) is a set of techniques for the exchange of data among two or more threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC techniques are divided into methods for message passing, synchronization, shared memory, and remote procedure calls (RPC). The method of IPC used may vary based on the bandwidth and latency of communication between the threads, and the type of data being communicated. What is a Process? A process is an instance of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs concurrently. What do you mean by Threads? Threads are a way for a program to split itself into two or more simultaneously (or pseudo-simultaneously) running tasks. Threads and processes differ from one operating system to another but, in general, a thread is contained inside a process and different threads in the same process share some resources while different processes do not. 4. What is client-server model? 5. What is a client? 6. What is a server? What are the various types of sockets? The different types of sockets are: 1) Stream Sockets used by TCP protocol (Family: SOCK_STREAM) 2) Datagram Sockets used by UDP protocol (Family: SOCK_DGRAM) 3) Sequential Packet Sockets used by SCTP protocol (Family: SOCK_SEQPACKET) 4) Raw Sockets which talk directly to IP protocol (Family: SOCK_RAW) What are the different types of server? In fact servers are classified on the basis of the way they handle multiple requests. They are two types of servers: 1) Iterative Servers and 2) Concurrent Servers 1. Concurrent Servers: These servers handle multiple clients at the same time. Among the various approaches that are available to handle these multiple clients, simplest approach is to call the UNIX fork system call , creating a child Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: process for each client. When a connection is established, accept returns, the server calls fork, and then the child process services the client and the parent process waits for another connection. The parent closes the connected socket since the child handles this new client. What is an iterative server? Iterative Servers: When a clients request can be handled by the server in a known, finite amount of time, the server process handles the request itself. These servers handle one client at a time by iterating between them. What is a concurrent server and what are the different ways to design concurrent servers? Concurrent Servers: These servers handle multiple clients at the same time. Among the various approaches that are available to handle these multiple clients, simplest approach is to call the UNIX fork system call, creating a child process for each client. When a connection is established, accept returns, the server calls fork, and then the child process services the client and the parent process waits for another connection. The parent closes the connected socket since the child handles this new client. What is byte ordering? Big-endian and little-endian are terms that describe the order in which a sequence of bytes are stored in computer memory. Big-endian is an order in which the "big end" (most significant value in the sequence) is stored first (at the lowest storage address). Little-endian is an order in which the "little end" (least significant value in the sequence) is stored first. For example, in a big-endian computer, the two bytes required for the hexadecimal number 4F52 would be stored as 4F52 in storage (if 4F is stored at storage address 1000, for example, 52 will be at address 1001). In a little-endian system, it would be stored as 524F (52 at address 1000, 4F at 1001). Byte Ordering Functions: little-endian byte order: low-order byte at the starting address big-endian: high-order byte at the starting address To handle byte ordering for non-standard size integers there are conversion functions htonl - host to network, long int htons - host to network, short int ntohl - network to host, long int ntohs - network to host, short int Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: List some examples of big-endian systems? IBM's 370 mainframes, most RISC-based computers, and Motorola microprocessors use the big-endian approach. TCP/IP also uses the big-endian approach (and thus bigendian is sometimes called network order). List some examples of little-endian systems? On the other hand, Intel processors (CPUs) and DEC Alphas and at least some programs that run on them are little-endian. What is a signal? A signal is a notification to a process that an event has occurred. Signals are sometimes called “software interrupts”. Signals usually occur asynchronously. Signals can be sent by one process to another process or by the kernel to a process. How can you block the signal? The sigblock system call can be used to block one or more signals. A process can also block the delivery of a signal by mean of masks. When a signal is blocked, it remains pending. How can you unblock the signal? The SIG_UNBLOCK system call is used to unblock the signals in the given signal set. List some examples of signals? Examples of important signals SIGABRT SIGALRM SIGBUS SIGCHLD SIGFPE SIGINT SIGKILL SIGQUIT SIGSEGV Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: SIGSTOP SIGTERM SIGUSR1 SIGUSR2 What are the different I/O models? The five I/O models available are: 1. Blocking I/O 2. Non Blocking I/O 3. I/O multiplexing (select and poll) 4. Signal Driven I/O (SIGIO) 5. Asynchronous I/O (the POSIX aio_functions) Define RPC? Remote Procedure Call (RPC) is a high-level model for client-server communication. It provides the programmers with a familiar mechanism for building distributed systems. Examples: File service, Authentication service. RPC enables clients to communicate with servers by calling procedures in a similar way to the conventional use of procedure calls in high-level languages. RPC is modelled on the local procedure call, but the called procedure is executed in a different process and usually a different computer. In a Remote Procedure Call (RPC), a process on the local system invokes a procedure on a remote system. The details of network-programming are hidden to the process invoking the RPC. (Don’t care about sockets) Client and server both have to use rpc.h (for C) which handles most of the networking details. Explain in brief the mechanism of RPC? It can be summarized in the following steps: 1. The client provides the arguments and calls the client stub in the normal way. 2. The client stub builds (marshals) a message (call request) and traps to OS & network kernel. 3. The kernel sends the message to the remote kernel. 4. The remote kernel receives the message and gives it to the server dispatcher. 5. The dispatcher selects the appropriate server stub. 6. The server stub unpacks (unmarshals) the parameters and call the corresponding server procedure. What are the functions of server and client stubs? Client Stub: The client stub purpose is to package up the arguments to the remote procedure, possible put them into some standard and then build one or more network messages. The client calls a local procedure, called the client stub, which appears to the client that it is the actual server procedure that it wants to call. Server Stub: The server stub executes a local procedure call to invoke the actual server functions, passing it the arguments that it received in the network messages from the client stub. Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: What are the advantages of RPC? The Advantages/Disadvantages of RPC are: Advantages: 1. RPC provides a simple interface to distributed heterogeneous systems in a common (procedural) programming language (C) 2. RPC supports modular and hierarchical design of distributed systems (i.e. client and server are separate entities) Disadvantages: 1. RPC is not a standard. 2. Low-level construct. What is IDL? An interface description language (or alternately, interface definition language), or IDL for short, is a specification language used to describe a software component's interface. IDLs describe an interface in a language-neutral way, enabling communication between software components that do not share a language – for example, between components written in C++ and components written in Java. IDLs are commonly used in remote procedure call software. In these cases the machines at either end of the "link" may be using different operating systems and computer languages. IDLs offer a bridge between the two different systems. What is marshaling & unmarshalling? Marshalling is the process of transforming the memory representation of an object to a data format suitable for storage or transmission. It is typically used when data must be moved between different parts of a computer program or from one program to another. It transforms data structures into a format suitable for transmission. The packaging of the client’s arguments into a network is called Marshalling. The reverse process of marshalling is called unmarshalling. What is XDR? XDR is a standard for the description and encoding of data. It is useful for transferring data between different computer architectures, and has been used to communicate data between such diverse machines as the SUN WORKSTATION*, VAX*, IBM-PC*, and Cray*. XDR fits into the ISO presentation layer. 29. What are the different layers in RPC interface? The RPC interface can be seen as being divided into three layers: highest, intermediate, and lowest. See the following: Using the Highest Layer of RPC Using the Intermediate Layer of RPC Using the Lowest Layer of RPC The highest layer of RPC is totally transparent to the operating system, workstation, and network on which it runs. This level is actually a method for using RPC routines, rather than a part of RPC proper. The intermediate layer is RPC proper. At the intermediate layer, the programmer need not consider details about sockets or other low-level implementation mechanisms. The programmer makes remote procedure calls to routines on other workstations. Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: The lowest layer of RPC allows the programmer greatest control. Programs written at this level can be more efficient. List the different layers of OSI model? 1) Application 2) Presentation 3) Session 4) Transport 5) Network 6) Data Link 7) Physical Explain the layers of OSI Model? Application Layer 7: It is employed in software packages which implement client-server software. When an application on one computer starts communicating with another computer, then the Application layer is used. The header contains parameters that are agreed between applications. This header is often only sent at the beginning of an application operation. Examples of services within the application layer include: FTP DNS SNMP SMTP gateways Web browser Network File System (NFS) Telnet and Remote Login (rlogin) X.400 FTAM Database software Print Server Software Presentation Layer 6: This provides function call exchange between host operating systems and software layers. It defines the format of data being sent and any encryption that may be used, and makes it presentable to the Application layer. Examples of services used are listed below: MIDI HTML GIF TIFF JPEG ASCII EBCDIC Session Layer 5: The Session layer defines how data conversations are started, controlled and finished. The Session layer manages the transaction sequencing and in some cases authorization. The messages may be bidirectional and there may be many of them, the session layer manages these conversations and creates notifications if some messages fail. Indications show whether a packet is in the middle of a conversation flow or at the end. Only after a completed conversation will the data be passed up to layer 6. Examples of Session layer protocols are listed below: RPC Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: SQL NetBIOS names Appletalk ASP DECnet SCP Transport Layer 4: This layer is resonsible for the ordering and reassembly of packets that may have been broken up to travel across certain media. Some protocols in this layer also perform error recovery. After error recovery and reordering the data part is passed up to layer 5. Examples are: TCP UDP SPX Network Layer 3: This layer is responsible for the delivery of packets end to end and implements a logical addressing scheme to help accomplish this. This can be connectionless or connectionoriented and is independent of the topology or path that the data packets travel. Routing packets through a network is also defined at this layer plus a method to fragment large packets into smaller ones depending on MTUs for different media (Packet Switching). Once the data from layer 2 has been received, layer 3 examines the destination address and if it is the address of its own end station, it passes the data after the layer 3 header to layer 4. Examples of Layer 3 protocols include: Appletalk DDP IP IPX DECnet Data Link Layer 2: This layer deals with getting data across a specific medium and individual links by providing one or more data link connections between two network entities. End points are specifically identified, if required by the Network layer Sequencing. The frames are maintained in the correct sequence and there are facilities for Flow control and Quality of Service parameters such as Throughput, Service Availability and Transit Delay. Examples include: IEEE 802.2 IEEE 802.3 802.5 - Token Ring HDLC Frame Relay FDDI ATM PPP The Data link layer performs the error check using the Frame Check Sequence (FCS) in the trailer and discards the frame if an error is detected. It then looks at the addresses to see if it needs to process the rest of the frame itself or whether to pass it on to another host. The data between the header and the trailer is passed to layer 3. The MAC layer concerns itself with the access control method and determines how use of the physical transmission is controlled and provides the token ring protocols that define how a token ring operates. The LLC shields the higher level layers from concerns with the specific LAN implementation. Physical Layer 1 Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: This layer deals with the physical aspects of the media being used to transmit the data. The electrical, mechanical, procedural and functional means This defines things like pinouts, electrical characteristics, modulation and encoding of data bits on carrier signals. It ensures bit synchronisation and places the binary pattern that it receives into a receive buffer. Once it decodes the bit stream, the physical layer notifies the data link layer that a frame has been received and passes it up. Examples of specifications include: V.24 V.35 EIA/TIA-232 EIA/TIA-449 FDDI 802.3 802.5 Ethernet RJ45 NRZ NRZI You will notice that some protocols span a number of layers (e.g. NFS, 802.3 etc.). A benefit of the seven layer model is that software can be written in a modular way to deal specifically with one or two layers only, this is often called Modular Engineering. List the different layers of TCP/IP model? 1) Application 2) Transport 3) Internet 4) Network Which layer of OSI model implements RPC? Session Layer What is the difference between connection-oriented and connectionless communications? In connection oriented method session is created before transmitting data. It provides a reliable data stream as it ensures the sequential transmission of data. In connection oriented method the process starts from the sender computer by sending a request to start the transfer that is to be acknowledged by the destination device before data can be sent and hence a virtual link is established between sender and receiver. This process is called handshaking. After that data is transferred sequentially by processing acknowledgements. Sliding window and Stop and wait are used to provide flow control and Cyclic Redundancy Checks are used to provide error detection. These methods can either be implemented in the data link layer or in the transport layer. TCP provides a connection-oriented service. In connectionless transmission there is no need to establish connection. The sender just starts transmitting data that's why it cannot provide the same reliability as offered by connection-oriented method. These techniques are used in the broadcast networks. In these networks there is need of maintaining the state information for the sender and receiver devices that's why it can only offer a small number of services. However the Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: speed of connectionless networks is better than those of connection-oriented ones because they do not provide flow control and error detection. UDP provides connectionless services. What is the difference between close () and shutdown () system calls? Close () system call makes the socket descriptor invalid while shutdown is used to partially or fully shutdown the I/O on the socket. The user can call close after a shutdown to make the socket descriptor unusable. What are IP Addresses? An IP address is a 32-bit identifier assigned to a host that uses the Internet Protocol. The IP address is represented by four octets (8-bit fields). In decimal form, an IP address consists of four fields separated by dots, where each field contains a value in the range 0 - 255. This is called dotted decimal notation. Each host ID must be unique within a given network, and each network number must be unique within a given internet. Host IDs are assigned by the network administrator. The network number is assigned by the inter-network administrator. For a public network on the Internet, you must obtain a network number assigned by the Network Information Center (NIC). An IP address consists of two parts. The first part of the address, called the network number, identifies a network on the internet; the remainder, called the host ID, identifies an individual host on that network. Explain different classes of IP address? There are five classes of available IP ranges: Class A, Class B, Class C, Class D and Class E, while only A, B and C are commonly used. Each class allows for a range of valid IP addresses. Below is a listing of these addresses. Class Address Range Supports Class A 1.0.0.1 to 126.255.255.254 Supports 16 million hosts on each of 127 networks. Class B 128.1.0.1 191.255.255.254 to Supports 65,000 hosts on each of 16,000 networks. Class C 192.0.1.1 223.255.254.254 to Supports 254 hosts on each of 2 million networks. Class D 224.0.0.0 239.255.255.255 to Class E 240.0.0.0 254.255.255.254 to Reserved for multicast groups. Reserved. Note: 1) Ranges 127.x.x.x are reserved for loopback tests, for example, 127.0.0.1. 2) Ranges 255.255.255.255 are used to broadcast to all hosts on the local network. What a port number? What is the purpose of it? A port number is a way to identify a specific process to which an Internet or other network message is to be forwarded when it arrives at a server. Zahed Shareef ( ) 160310737044 NP Lab Experiment No. : Date: For the Transmission Control Protocol and the User Datagram Protocol, a port number is a 16-bit integer that is put in the header appended to a message unit. Define the following terms - TCP, UDP, ICMP, IP, ARP, and RARP? Transmission Control Protocol (TCP): A connection-oriented protocol that provides a reliable, full duplex, byte stream for a user process. Most Internet applications use TCP. Since TCP uses IP, the entire suite is often called the TCP/IP protocol family. User Datagram Protocol (UDP): It is connectionless oriented protocol. It does not provide reliable communication where UDP packets (datagrams) are not guaranteed to reach their intended destination. Internet Control Message Protocol (ICMP): It is a protocol that handles error and control information between systems in the network. Internet Protocol (IP): It is the protocol that provides the packet delivery service for TCP, UDP, and ICMP. Address Resolution Protocol (ARP): The protocol that maps an internet address into a hardware address. (IP address to MAC address) Reverse Address Resolution Protocol (RARP): The protocol that maps a hardware address into a IP address. (MAC address to IP address) What is communication domain? A communication domain is a type of network with particular conventions such as how sockets are named and used. Sockets normally exchange data only with sockets in the same domain. Concurrent Servers - simplest way to write a concurrent server under Unix is to fork a child process to handle each client - connection is established, accept returns, the server calls fork o child process services the client (on connfd, the connected socket) o parent process waits for another connection (on listenfd, the listening socket). o parent closes the connected socket since the child handles the new client - every file/socket has a file table entry: telling the number of descriptors that are currently open that refer to this file or socket o incremented to two when fork( ) called; 1 2 o parent closing connfd decrements from 2 1 o cleanup & de-allocation of socket happens when count = 0 (when child closes connfd) Zahed Shareef ( ) 160310737044 NP Lab - Experiment No. : Date: After this state, child is handling the connection with the client and the parent can call accept again on the listening socket, to handle the next client connection Zahed Shareef ( ) 160310737044