Post on 17-Apr-2018
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 1 hcr:innovationcse@gg
UNIT – V APPLICATION LAYER, SOCKETS Client server model – concurrency – processes – sockets – byte ordering – socket system calls – TCP and
UDP client-server programs – BOOTP -DHCP – DNS – name space, resolution – types of records – concept –
mode of operation – Rlogin.
CLIENT SERVER MODEL
Client Server Paradigm
Should both application programs be able to request services and provide services or should the
application programs just do one or the other?
o the tasks of requesting a service and providing a service are separate from each other.
o An application program is either a requester (a client), or a provider (a server).
Should a server provide services only to one specific client or should the server be able to provide services
to any client that requests the type of service it provides?
o server providing a service for any client that needs that type of service, not a particular one
o the server-client relationship is one-to-many.
Should a computer run only one program (client or server)?
o should be able to run any client program
o server programs need to be run on a computer that can be continuously running
When should an application program be running?
o a client program should run only when it is needed
o The server program should run all the time
Should there be only one universal application program that can provide any type of service a user wants?
o services needed frequently and by many users have specific client-server application programs
Server
A server is a program running on the remote machine providing service to the clients.
When it starts, it opens the door for incoming requests from clients
it never initiates a service until it is requested to do so.
an infinite program.
Client
A client is a program running on the local machine requesting service from a server.
A client program is finite, which means it is started by the user (or another application program) and
terminates when the service is complete.
o a client opens the communication channel using the IP address of the remote host and the well-known
port address of the specific server program running on that machine.
o After a channel of communication is opened, the client sends its request and receives a response.
o Although the request-response part may be repeated several times, the whole process is finite and
eventually comes to an end.
Concurrency
Both clients and servers can run in concurrent mode.
Concurrency in Clients
Clients can be run on a machine either iteratively or concurrently.
Iteratively running clients
o running them one by one;
o one client must start, run, and terminate before the machine can start another client.
Concurrently running clients
o two or more clients can run at the same time.
Concurrency in Servers
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 2 hcr:innovationcse@gg
An iterative server can process only one request at a time; it receives a request, processes it, and sends
the response to the requestor before it handles another request
A concurrent server, can process many requests at the same time and thus can share its time between
many requests.
The servers use either
o UDP, a connectionless transport layer protocol
o TCP/ SCTP, a connection-oriented transport layer protocol
Server operation, depends on two factors:
o the transport layer protocol
o the service method
Four types of servers:
o connectionless iterative,
o connectionless concurrent,
o connection-oriented iterative,
o connection-oriented concurrent
Connectionless Iterative Server
The servers that use UDP are normally iterative, means that the server processes one request at a time.
A server gets the request received in a datagram from UDP, processes the request, and gives the response
to UDP to send to the client.
The server pays no attention to the other datagrams.
These datagrams are stored in a queue, waiting for service.
They could all be from one client or from many clients.
In either case they are processed one by one in order of arrival.
The server uses one single port for this purpose, the well-known port.
All the datagrams arriving at this port wait in line to be served
Connection-Oriented Concurrent Server
The servers that use TCP (or SCTP) are normally concurrent.
This means that the server can serve many clients at the same time.
Communication is connection-oriented, which means that a request is a stream of bytes that can arrive in
several segments and the response can occupy several segments.
A connection is established between the server and each client, and the connection remains open until the
entire stream is processed and the connection is terminated.
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 3 hcr:innovationcse@gg
have one well-known port and many ephemeral ports.
The server accepts connection requests at the well-known port.
A client can make its initial approach to this port to make the connection.
After the connection is made, the server assigns a temporary port to this connection to free the well-known
port.
Data transfer can now take place between these two temporary ports, one at the client site and the other at
the server site.
The well-known port is now free for another client to make the connection.
To serve several clients at the same time, a server creates child processes, which are copies of the original
process (parent process)
The server must also have one queue for each connection.
The segments come from the client, are stored in the appropriate queue, and will be served concurrently by
the server.
PROCESSES Write general about unix processes
SOCKET INTERFACES An interface is a set of instructions designed for interaction between two entities
Several interfaces have been designed for communication
o socket interface,
o transport layer interface (TLI),
o STREAM
The socket interface, as a set of instructions, is located
between the operating system and the application
programs.
To access the services provided by the TCP/IP protocol
suite, an application needs to use the instructions
defined in the socket interface.
Relation between the operating system and the TCP/IP
suite
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 4 hcr:innovationcse@gg
Socket
A socket is a software abstract simulating a hardware socket we see in our daily life.
To use the communication channel, an application program (client or server) needs to request the operating
system to create a socket.
The application program then can plug into the socket to send and receive data.
For data communication to occur, a pair of sockets, each at one end of communication, is needed
Socket data structure
Family
o defines the protocol group: IPv4, IPv6, UNIX domain protocols, and so on.
o IF_INET for IPv4 protocol
o IF_INET6 for IPv6 protocol
Type
o defines four types of sockets:
o SOCK_STREAM (for TCP),
o SOCK_DGRAM (for UDP),
o SOCK_SEQPACKET (for SCTP),
o SOCK_RAW
Protocol
o defines the protocol that uses the interface.
o It is set to 0 for TCP/IP protocol suite
Local socket address
o defines the local socket address.
o A socket address is a combination of an IP address and a port number
Remote socket address
o defines the remote socket address
Socket types
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 5 hcr:innovationcse@gg
IPv4 socket address
struct in_addr {
in_addr_t s_addr; // A 32-bit IPv4 address
}
struct sockaddr_in { uint8_t sin_len; // length of structure (16 bytes) sa_family_t sin_family; // set to AF_INET in_port_t sin_port; // A 16-bit port number struct in_addr sin_addr; // A 32-bit IPv4 address char sin_zero[8]; // unused }
FUNCTIONS The interaction between a process and the operating system is done through a list of predefined functions
The socket Function
o int socket (int family, int type, int protocol);
The bind Function
o int bind (int sockfd, const struct sockaddress* localAddress, socklen_t addrLen);
The connect Function
o int connect (int sockfd, const struct sockaddress* remoteAddress, socklen_t addrLen);
The listen Function
o int listen (int sockfd, int backlog);
The accept Function
o int accept (int sockfd, const struct sockaddress* clientAddr, socklen_t* addrLen);
o blocking function that, when called, blocks itself until a connection is made by a client
The fork function
o pid_t fork (fork);
The send and recv Functions
o int send (int sockfd, const void* sendbuf, int nbytes, int flags);
o int recv (int sockfd, void* recvbuf, int nbytes, int flags);
The sendto and recvfrom Functions
o int sendto (int sockfd, const void* buffer, int nbytes, int flags
o struct sockaddr* destinationAddress, socklen_t addrLen);
o int recvfrom (int sockfd, void* buffer, int nbytes, int flags
o struct sockaddr* sourceAddress, socklen_t* addrLen);
The close Function
o int close (int sockfd);
Byte Ordering Functions
o uint16_t htons (uint16_t shortValue);
o uint32_t htonl (uint32_t longValue);
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 6 hcr:innovationcse@gg
o uint16_t ntohs (uint16_t shortValue);
o uint32_t ntohl (uint32_t longValue);
Memory Management Functions
o void* memset (void* destination, int chr, size_t len);
o void* memcpy (void* destination, const void* source, size_t nbytes);
o int memcmp (const void* ptr1, const void* ptr2, size_t nbytes);
Address Conversion Functions
o int inet_pton (int family, const char* stringAddr, void* numericAddr);
o char* inet_ntop (int family, const void* numericAddr, char* stringAddr, int len);
Header Files
o #include <sys/socket.h>
o #include <netinet/in.h>
o #include <netdb.h>
o #include <errno.h>
o #include <signal.h>
o #include <unistd.h>
o #include <string.h>
o #include <arpa/innet.h>
o #include <sys/wait.h>
COMMUNICATION USING UDP
Connectionless iterative communication using UDP
Server Process
o Explain the above diagram
Client Process
o Explain the above diagram
Echo Server Program using the Service of UDP
01 // UDP echo server program 02 #include "headerFiles.h" 03 04 int main (void) 05 { 06 // Declaration and definition
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 7 hcr:innovationcse@gg
07 int sd; // Socket descriptor 08 int nr; // Number of bytes received 09 char buffer [256]; // Data buffer 10 struct sockaddr_in serverAddr; // Server address 11 struct sockaddr_in clientAddr; // Client address 12 int clAddrLen; // Length of client Address 13 // Create socket 14 sd = socket (PF_INET, SOCK_DGRAM, 0); 15 // Bind socket to local address and port 16 memset (&serverAddr, 0, sizeof (serverAddr)); 17 serverAddr.sin_family = AF_INET; 18 serverAddr.sin_addr.s_addr = htonl (INADDR_ANY); // Default address 19 serverAddr.sin_port = htons (7) // We assume port 7 20 bind (sd, (struct sockaddr*) &serverAddr, sizeof (serverAddr)); 21 // Receiving and echoing datagrams 22 for ( ; ; ) // Run forever 23 { 24 nr = recvfrom (sd, buffer, 256, 0, (struct sockaddr*)&clientAddr, &clAddrLen); 25 sendto (sd, buffer, nr, 0,(struct sockaddr*)&clientAddr, sizeof(clientAddr)); 26 } 27 } // End of echo server program
Echo Client Program using the Service of UDP
01 // UDP echo client program 02 #include "headerFiles.h" 04 04 int main (void) 05 { 06 // Declaration and definition 07 int sd; // Socket descriptor 08 int ns; // Number of bytes send 09 int nr; // Number of bytes received 10 char buffer [256]; // Data buffer 11 struct sockaddr_in serverAddr; // Socket address 11 // Create socket 12 sd = socket (PF_INET, SOCK_DGRAM, 0); 13 // Create server socket address 14 memset (&servAddr, 0, sizeof(serverAddr)); 15 servAddr.sin_family = AF_INET; 16 inet_pton (AF_INET, “server address”, &serverAddr.sin_addr); 17 serverAddr.sin_port = htons (7); 18 // Send and receive datagrams 19 fgets (buffer, 256, stdin); 20 ns = sendto (sd, buffer, strlen (buffer), 0, 21 (struct sockaddr)&serverAddr, sizeof(serveraddr)); 22 recvfrom (sd, buffer, strlen (buffer), 0, NULL, NULL); 23 buffer [nr] = 0; 24 printf (“Received from server:”); 25 fputs (buffer, stdout); 26 // Close and exit 27 close (sd); 28 exit (0); 29 } // End of echo client program
To be complete, error-checking code needs to be added to both server and client programs.
COMMUNICATION USING TCP Diagram as in next page
Expand
o Server process
o Client Process
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 8 hcr:innovationcse@gg
Status of parent and child processes with respect to the sockets
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 9 hcr:innovationcse@gg
Echo Server Program using the Services of TCP
01 // Echo server program 02 #include "headerFiles.h" 03 04 int main (void) 05 { 06 // Declaration and definition 07 int listensd; // Listen socket descriptor 08 int connectsd; // Connecting socket descriptor 09 int n; // Number of bytes in each reception 10 int bytesToRecv; // Total bytes to receive 11 int processID; // ID of the child process 12 char buffer [256]; // Data buffer 13 char* movePtr; // Pointer to the buffer 14 struct sockaddr_in serverAddr; // Server address 15 struct sockaddr_in clientAddr; // Client address 16 int clAddrLen; // Length of client address 17 // Create listen socket 18 listensd = socket (PF_INET, SOCK_STREAM, 0); 19 // Bind listen socket to the local address and port 20 memset (&serverAddr, 0, sizeof (serverAddr)); 21 serverAddr.sin_family = AF_INET; 22 serverAddr.sin_addr.s_addr = htonl (INADDR_ANY); 23 serverAddr.sin_port = htons (7); // We assume port 7 24 bind (listensd, &serverAddr, sizeof (serverAddr)); 25 // Listen to connection requests 26 listen (listensd, 5); 27 // Handle the connection 28 for ( ; ; ) // Run forever 29 { 30 connectsd = accept (listensd, &clientAddr, &clAddrLen); 31 processID = fork (); 32 if (processID == 0) // Child process 33 { 34 close (listensd); 35 bytesToRecv = 256; 36 movePtr = buffer; 37 while ( (n = recv (connectfd, movePtr, bytesToRecv, 0)) > 0) 38 { 39 movePtr = movePtr + n; 40 bytesToRecv = movePtr − n; 41 } // End of while 42 send (connectsd, buffer, 256, 0); 43 exit (0); 44 } // End of if 45 close (connectsd): // Back to parent process 46 } // End of for loop 47 } // End of echo server program
Echo Client Program using the services of TCP
01 // TCP echo client program 02 #include "headerFiles.h" 03 04 int main (void) 05 { 06 // Declaration and definition 07 int sd; // Socket descriptor 08 int n; // Number of bytes received 09 int bytesToRecv; // Number of bytes to receive 10 char sendBuffer [256]; // Send buffer 11 char recvBuffer [256]; // Receive buffer 12 char* movePtr; // A pointer the received buffer 13 struct sockaddr_in serverAddr; // Server address 14
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 10 hcr:innovationcse@gg
15 // Create socket 16 sd = socket (PF_INET, SOCK_STREAM, 0); 17 // Create server socket address 18 memset (&serverAddr, 0, sizeof(serverAddr); 19 serverAddr.sin_family = AF_INET; 20 inet_pton (AF_INET, “server address”, &serverAddr.sin_addr); 21 serverAddr.sin_port = htons (7); // We assume port 7 22 // Connect 23 connect (sd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)); 24 // Send and receive data 25 fgets (sendBuffer, 256, stdin); 26 send (fd, sendBuffer, strlen (sendbuffer), 0); 27 bytesToRecv = strlen (sendbuffer); 28 movePtr = recvBuffer; 29 while ( (n = recv (sd, movePtr, bytesToRecv, 0) ) > 0) 30 { 31 movePtr = movePtr + n; 32 bytesToRecv = bytesToRecv − n; 33 } // End of while loop 34 recvBuffer[bytesToRecv] = 0; 35 printf (“Received from server:”); 36 fputs (recvBuffer, stdout); 37 // Close and exit 38 close (sd); 39 exit (0); 40 } // End of echo client program
Predefined Client-Server Applications
established programs that can be installed and be used.
FTP
o designed to give some specific service
TELNET
o some are designed to allow users to log into the server and perform the desired task
DNS
o designed to help other application programs
Peer-to-Peer (P2P) paradigm
two peer computers (laptops, desktops, or main frames) can communicate with each other to exchange
services.
interesting in some areas such file as transfer in which the client-server paradigm may put a lot of the load
on the server machine if a client wants to transfer a large file such as an audio or video file.
is also interesting if two peers need to exchange some files or information to each other without going to a
server.
let the duty of a server be shared by some users that want to participate in the process.
Example,
o instead of allowing several clients to make a connection and each download a large file, a server can let
each client download a part of a file and then share it with each other.
o In the process of downloading part of the file or sharing the downloaded file, however, a computer
needs to play the role of a client and the other the role of a server.
o In other words, a computer can be a client for a specific application at one moment and the server at
another moment.
These applications are now controlled commercially and not formally part of the Internet
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 11 hcr:innovationcse@gg
BOOTSTRAP PROTOCOL (BOOTP) a client/server protocol that configures a diskless computer or a computer that is booted for the first time.
It provides the IP address, net mask, the address of a default router, and the address of a name server.
Client and server on two different networks
Use of UDP ports
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 12 hcr:innovationcse@gg
BOOTP packet format
Option format
Options for BOOTP
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 13 hcr:innovationcse@gg
DYNAMIC HOST CONFIGURATION PROTOCOL
(DHCP) DHCP provides static and dynamic address allocation that can be manual or automatic
DHCP is a client/server protocol designed to provide the four pieces of information for a diskless computer
or a computer that is booted for the first time.
DHCP is a successor to BOOTP
DHCP Configuration
Static Address Allocation
DHCP server has a database that statically binds physical addresses to IP addresses.
When working in this way, DHCP is backward compatible with the deprecated protocol BOOTP
Dynamic Address Allocation
DHCP has a second database with a pool of available IP addresses.
This second database makes DHCP dynamic.
When a DHCP client requests a temporary IP address, the DHCP server goes to the pool of available
(unused) IP addresses and assigns an IP address for a negotiable period of time.
When a DHCP client sends a request to a DHCP server, the server first checks its static database.
If an entry with the requested physical address exists in the static database, the permanent IP address of
the client is returned.
if the entry does not exist in the static database, the server selects an IP address from the available pool,
assigns the address to the client, and adds the entry to the dynamic database.
Three types of address assignment
Manual configuration
o a manager can configure a specific address for a specific computer.
Automatic configuration
o a manager allows a DHCP server to assign a permanent address when a computer first attaches NW
Completely dynamic configuration
o a server "loans" an address to a computer for a limited time
DHCP Operation
The DHCP client and server can either be on the
same network
different networks
Same Network
The DHCP server issues a passive open command on UDP port number 67 and waits for a client.
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 14 hcr:innovationcse@gg
A booted client issues an active open command on port number 68
o The message is encapsulated in a UDP user datagram,using the destination port number 67 and the
source port number 68.
o The UDP user datagram, in turn, is encapsulated in an IP datagram.
o The client uses all 0s as the source address and all 1s as the destination address.
The server responds with either a broadcast or a unicast message using UDP source port number 67 and
destination port number 68.
o The response can be unicast because the server knows the IP address of the client.
o It also knows the physical address of the client, which means it does not need the services of ARP for
logical to physical address mapping.
o some systems do not allow the bypassing of ARP, resulting in the use of the broadcast address.
Different Networks
The DHCP request is broadcast because the client does not know the IP address of the server.
A broadcast IP datagram cannot pass through any router.
One of the hosts (or a router at the application layer) can be used as a relay agent.
Relay agent knows the unicast address of a DHCP server and listens for broadcast messages on port 67
When it receives this type of packet, it encapsulates the message in a unicast datagram and sends the
request to the DHCP server.
The packet, carrying a unicast destination address, is routed by any router and reaches the DHCP server.
The DHCP server knows the message comes from a relay agent because one of the fields in the request
message defines the IP address of the relay agent.
The relay agent, after receiving the reply, sends it to the DHCP client
Use of UDP ports
Error Control
DHCP requires that UDP uses the checksum.
The DHCP client uses timers and a retransmission policy if it does not receive the DHCP reply to a request.
DHCP forces the client to use a random number to set its timers to prevent a traffic jam
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 15 hcr:innovationcse@gg
DHCP Packet
Operation code
o This 8-bit field defines the type of DHCP packet: request (1) or reply (2).
Hardware type
o This is an 8-bit field defining the type of physical network.
o Each type of network has been assigned an integer. For example, for Ethernet the value is 1.
Hardware length
o This is an 8-bit field defining the length of the physical address in bytes.
o For example, for Ethernet the value is 6.
Hop count
o This is an 8-bit field defining the maximum number of hops the packet can travel.
Transaction ID
o This is a 4-byte field carrying an integer.
o The transaction identification is set by the client and is used to match a reply with the request.
o The server returns the same value in its reply.
Number of seconds
o 16-bit field that indicates the number of seconds elapsed since the time the client started to boot.
Flag
Client IP address
o This is a 4-byte field that contains the client IP address.
o If the client does not have this information, this field has a value of 0.
Your IP address
o This is a 4-byte field that contains the client IP address.
o It is filled by the server (in the reply message) at the request of the client.
Server IP address
o This is a 4-byte field containing the server IP address.
o It is filled by the server in a reply message.
Gateway IP address
o This is a 4-byte field containing the IP address of a router.
o It is filled by the server in a reply message
Client hardware address
o This is the physical address of the client.
o Although the server can retrieve this address from the frame sent by the client, it is more efficient if the
address is supplied explicitly by the client in the request message.
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 16 hcr:innovationcse@gg
Server name
o This is a 64-byte field that is optionally filled by the server in a reply packet.
o It contains a null-terminated string consisting of the domain name of the server
Boot filename
o This is a 128-byte field that can be optionally filled by the server in a reply packet.
o It contains a null-terminated string consisting of the full pathname of the boot file
Options
o It can carry either
additional information (such as the network mask or default router address) or
some specific vendor information.
Transition States
To provide dynamic address allocation, the DHCP client acts as a state machine that performs transitions
from one state to another depending on the messages it receives or sends.
The type of the message is defined by the option with tag 53 that is included in the DHCP packet
States
INIT State
SELECTING State
REQUESTING State
BOUND State
RENEWING State
REBINDING State
Issues related to the DHCP states
Early Release
Timers
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 17 hcr:innovationcse@gg
DHCP client transition diagram
Exchanging Messages
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 18 hcr:innovationcse@gg
DOMAIN NAME SPACE
Name Space
The names assigned to machines must be unique because the addresses are unique.
A name space that maps each address to a unique name can be organized in two ways:
o flat
o hierarchical
Domain Name Space
The DNS is hierarchical in design.
The names are defined in an inverted-tree structure with the root at the top.
The tree can have 128 levels: level 0 (root) to level 127.
Label
Each node in the tree has a label, which is a string with a maximum of 63 characters
Domain Name
is a sequence of labels separated by dots (.)
Fully Qualified Domain Name (FQDN)
o a label is terminated by a null string
o challenger.atc.fhda.edu.
Partially Qualified Domain Name (PQDN)
o a label is not terminated by a null string
o challenger
Domain
A domain is a subtree of the domain name space.
The name of the domain is the name of the node at the top of the subtree
a domain may itself be divided into domains (or subdomains)
Distribution of Name Space
Hierarchy of Name Servers
distribute the information among many computers called DNS servers
divide the whole space into many domains based on the first level
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 19 hcr:innovationcse@gg
Zone
a contiguous part of the entire tree
Root Server
a server whose zone consists of the whole tree
Primary and Secondary Servers
A primary server is a server that stores a file about the zone for which it is an authority
A secondary server is a server that transfers the complete information about a zone from another server
(primary or secondary) and stores the file on its local disk.
A primary server loads all information from the disk file; the secondary server loads all information from the
primary server.
When the secondary downloads information from the primary, it is called zone transfer
DNS In the Internet
The domain name space (tree)
is divided into three different
sections:
generic domains
country domains
inverse domain
Generic Domains
define registered hosts according to their generic behavior Ex: srmuniv.ac.in
Each node in the tree defines a domain, which is an index to the domain name space database
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 20 hcr:innovationcse@gg
Country Domains
uses two-character country abbreviations (in for India)
Second labels can be organizational, or they can be more specific, national designations (like tn.in)
Example: www.tn.gov.in
Inverse Domain
used to map an address to a name
Example: 121.45.34.132.in-addr.arpa
Resolution
Mapping a name to an address or an address to a name is called name-address resolution
Resolver
DNS is designed as a client-server application.
A host that needs to map calls a DNS client called a resolver.
The resolver accesses the closest DNS server with a mapping request.
If the server has the information, it satisfies the resolver; otherwise, it either refers the resolver to other
servers or asks other servers to provide the information.
After the resolver receives the mapping, it interprets the response to see if it is a real resolution or an error,
and finally delivers the result to the process that requested it.
Mapping Names to Addresses
the resolver gives a domain name to the server and asks for the corresponding address
Mapping Addresses to Names
A client can send an IP address to a server to be mapped to a domain name
Recursive Resolution
the resolver expects the server to supply the final answer
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 21 hcr:innovationcse@gg
Iterative Resolution
the client repeats the same query to multiple servers
The client is responsible for repeating the query to this second server
DNS Messages
two types of messages: query, response
Both types have the same format.
The query message consists of a header and question records;
the response message consists of a header, question records, answer records, authoritative records, and
additional records
Header
Identification
This is a 16-bit field used by the client to match the response with the query
Flags.
QR (query/response)., OpCode., AA (authoritative answer), TC (truncated), RD (recursion desired, RA
(recursion available).
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 22 hcr:innovationcse@gg
Question Section
o This is a section consisting of one or more question records.
o It is present on both query and response messages
Answer Section
o This is a section consisting of one or more resource records.
o It is present only on response messages.
o This section includes the answer from the server to the client (resolver)
Authoritative Section
o This is a section consisting of one or more resource records.
o It is present only on response messages.
o This section gives information (domain name) about one or more authoritative servers for the query.
Additional Information Section
o This is a section consisting of one or more resource records.
o It is present only on response messages.
o This section provides additional information that may help the resolver.
Types Of Records
two types of records are used in DNS.
The question records are used in the question section of the query and response messages.
The resource records are used in the answer, authoritative, and additional information sections of the
response message
Question Record
used by the client to get information from a server.
This contains the domain name
Resource Record
Each domain name (each node on the tree) is associated with a record called the resource record.
The server database consists of resource records.
Resource records are also what is returned by the server to the client
Compression
DNS requires that a domain name be replaced by an offset pointer if it is repeated.
For example, in a resource record the domain name is usually a repetition of the domain name in the
question record.
For efficiency, DNS defines a 2-byte offset pointer that points to a previous occurrence of the domain or
part of it.
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 23 hcr:innovationcse@gg
RLOGIN Similar to TELNET without customization options
TELNET
When a user wants to access an application program or utility located on a remote machine, he or she
performs remote login.
Here the TELNET client and server programs come into use.
The user sends the keystrokes to the terminal driver where the local operating system accepts the
characters but does not interpret them.
The characters are sent to the TELNET client, which transforms the characters to a universal character set
called Network Virtual Terminal (NVT) characters and delivers them to the local TCP/IP stack
Network Virtual Terminal (NVT)
NVT Character Set
NVT uses two sets of characters, one for data and one for control. Both are 8-bit bytes
EOF, EOR, SE, NOP, DM, BRK, IP, AO, AYT, EC, EL, GA, SB, WILL, WONT, DO, DONT, IAC
End of file, End of record, Suboption end, No operation, Data mark, Break, Interrupt process, Abort output, Are
you there?, Erase character, Erase line, Go ahead, Suboption begin, Agreement to enable option, Refusal to
enable option, Approval to option request, Denial of option request, Interpret (the next character) as control
Embedding
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 24 hcr:innovationcse@gg
The backspace character is translated into two remote characters (IAC EC), which is embedded in the data and
sent to the remote server
Options
TELNET lets the client and server negotiate options before or during the use of the service.
Options are extra features available to a user with a more sophisticated terminal
Code Option Meaning
0 Binary Interpret as 8-bit binary transmission
1 Echo Echo the data received on one side to the other
3 Suppress go-ahead Suppress go-ahead signals after data
5 Status Request the status of TELNET
6 Timing mark Define the timing marks
24 Terminal type Set the terminal type
32 Terminal speed Set the terminal speed
34 Line mode Change to line mode
Modes of Operation
operate in one of three modes: default mode, character mode line mode
Default Mode
The default mode is used if no other modes are invoked through option negotiation.
In this mode, the echoing is done by the client.
The user types a character and the client echoes the character on the screen (or printer) but does not send
it until a whole line is completed.
After sending the whole line to the server, the client waits for the GA (go ahead) command from the server
before accepting a new line from the user.
The operation is half-duplex
CS603 TCP/IP Technology Unit - V
MTech CSE (PT, 2011-14) SRM, Ramapuram 25 hcr:innovationcse@gg
Character Mode
each character typed is sent by the client to the server.
The server normally echoes the character back to be displayed on the client screen.
In this mode the echoing of the character can be delayed if the transmission time is long (such as in a
satellite connection).
It also creates overhead (traffic) for the network because three TCP segments must be sent for each
character of data:
o 1. The user enters a character that is sent to the server.
o 2. The server acknowledges the received character and echoes the character back (in one segment).
o 3. The client acknowledges the receipt of the echoed character.
Line Mode
line editing (echoing, character erasing, line erasing, and so on) is done by the client.
The client then sends the whole line to the server.
the line mode is full-duplex with the client sending one line after another, without the need for an intervening
GA (go ahead) character from the server
Comments & Feedback
Thanks to my family members who supported me while I spent hours and hours to prepare this. Your feedback is welcome at
GHCRajan@gmail.com