Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore MCA634 Advance Computer Networks

MCA634 Advance Computer Networks

Published by Teamlease Edtech Ltd (Amita Chitroda), 2020-12-04 10:41:48

Description: MCA634 Advance Computer Networks

Search

Read the Text Version

Domain Network Services (DNS) 45 domain name to IP address. So, DNS is used to convert the domain name of the websites to their numerical IP address. 3.3 Domain Names The domain name space is divided into three different sections: generic domains, country domains and inverse domains. Generic Domain It defines the registered hosts according to their generic behavior. Each node in a tree defines the domain name, which is an index to the DNS database. It uses three-character labels, and these labels describe the organization type. For example:  Aero: Airlines and aerospace companies  Biz: Businesses or firms  Com: Commercial organizations  Edu: Educational institutions  Gov: Government institutions Country Domain The format of country domain is same as a generic domain, but it uses two-character country abbreviations (e.g., us for the United States) in place of three-character organizational abbreviations. Inverse Domain The inverse domain is used for mapping an address to a name. When the server has received a request from the client, the server contains the files of only authorized clients. To determine whether the client is on the authorized list or not, it sends a query to the DNS server and ask for mapping an address to the name. CU IDOL SELF LEARNING MATERIAL (SLM)

46 Advanced Computer Networks com fehacdthdcual gov cRhRoaoolot.atilntelcetv.vefehllda.edumil net org com edu gov int mil net org fhda atc chal Fig. 3.1: Domain Names Types of Domains The Root Domain At the top of the inverted domain tree is the highest level of the DNS structure, called the root domain and represented by a simple dot (.). The Top-level Domain Names The TLDs can be broken down further into the generic top-level domains (e.g., .org, .com,.net, .mil, .gov, .edu, .int, .biz, etc.), country-code top-level domains (e.g., .us, .uk, .ng and .ca corresponding to the country codes for the United States, the United Kingdom, Nigeria and Canada, respectively). The Second-level Domain Names The names at this level of the DNS make up the actual organizational boundary of the namespace. Companies, Internet service providers (ISPs), educational communities, non-profit groups and individuals typically acquire unique names within this level. Here are a few examples: redhat.com, caldera.com, kernel.org, etc. The second-level domain in our URL (serverA.example.org.) is “example.” The Third-level Domain Names Third-level names to reflect hostnames or other functional uses. Example of functional assignment of a third-level domain name will be the “www ” in www.yahoo.com. The “www ” CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 47 here can be the actual hostname of a machine under the yahoo.com domain, or it can be an alias to a real hostname. The third-level domain name in (serverA.example.org.) is “serverA”. Here, it simply reflects the actual hostname of our system. Table 3.1: Top-level Domains Category Description Country Description United States .com Commercial .us Canada United Kingdom .edu Educational .ca Germany Australia .org Non-profit organization .uk Taiwan Russia .net Networking .de .biz Business .au .name Personal use .tw .pro Professional .ru Top-level Domains (TLDs) are split into two types: 1. Generic Top-level Domains (gTLD), e.g., .com, .edu, .net, .org, .mil, etc. 2. Country Code Top-level Domains (ccTLD), e.g., .us, .ca, .tv, .uk, etc. root (.) Delegation .com .org .us .uk .example .b .c .co .ac .org ccTLD gTLD Fig. 3.2: Domain Structure Functions of the Domain Name System:  DNS is used to resolve host names to IP addresses and find services.  DNS is an essential service for a network that uses Active Directory.  DNS is also required if you want resources such as Web servers available on the Internet.  The most common operating system DNS is implemented on is UNIX/Linux, and this can be integrated with the Windows version of DNS. CU IDOL SELF LEARNING MATERIAL (SLM)

48 Advanced Computer Networks 3.4 The Internet Domain Name Server Hierarchy  Root Name Server: It is contacted by name servers that cannot resolve the name. It contacts authoritative name server if name mapping is not known. It then gets the mapping and returns the IP address to the host.  Top-level server: It is responsible for com, org, edu, etc. and all top level country domains like uk, fr, ca, in, etc. They have info about authoritative domain servers, and know names and IP addresses of each authoritative name server for the second level domains.  Authoritative name server: This is organization’s DNS server, providing authoritative hostName to IP mapping for organization servers. It can be maintained by organization or service provider. In order to reach cse.dtu.in, we have to ask the root DNS server, then it will point out to the top-level domain server and then to authoritative domain name server which actually contains the IP address. So, the authoritative domain server will return the associative IP address. 3.5 Working of DNS  DNS is a client-server network communication protocol. DNS clients send requests to the server while DNS servers send responses to the client.  Client requests contain a name which is converted into an IP address known as a forward DNS lookup while requests containing an IP address are converted into a name known as reverse DNS lookup.  DNS implements a distributed database to store the name of all the hosts available on the internet.  If a client like a web browser sends a request containing a hostname, then a piece of software such as DNS resolver sends a request to the DNS server to obtain the IP address of a hostname. If DNS server does not contain the IP address associated with a hostname, then it forwards the request to another DNS server. If IP address has arrived at the resolver, which in turn completes the request over the internet protocol. – Need to register a primary and secondary domain name servers for your domain and arrange to have zone files created on DNS servers. – Host Name Resolutions. – Host names are used because they are easier to remember than IP addresses. CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 49 – When a program uses a host name, the host name must be converted to an IP address before the resource can be contacted. – The contents of a hosts file are a list of IP addresses and host names.  The steps followed by Windows Server 2003 to resolve host names are: – Host name is checked. – Hosts file is loaded into cache. – DNS cache is searched. – DNS server is queried. DNS resolver in ISP’s Servers client I want If IP not in ISP’s www.abc.com local DNS cache, send DNS request What is IP for to root server. abc.com DNS Root Go to authority Server for for abc.com COM Domains What is IP for Send DNS www.abc.com request to authoritative Authority for IP is server. abc.COM 192.23.64.01 Send IP 192.23.64.01 address to client. Get me If Web page not in a 192.23.64.01 local web cache maintained by the ISP, DNS resolver in get page from client internet. Fig. 3.3: Working of DNS CU IDOL SELF LEARNING MATERIAL (SLM)

50 Advanced Computer Networks Structure of DNS  IP addresses are usually paired with more human-friendly names: Domain Name System (DNS). Hostname Organization Top-level domain Fig. 3.4: Structure of DNS Other top-level domains include .com, .gov, .org, etc. There are also country-specific domains like .uk, .ca, .jp, etc. Need to register a primary and secondary domain name servers for your domain and arrange to have zone files created on DNS servers. Example of Domain Name  server.rkt.com 3.6 Authoritative Hosts An authoritative name server provides actual answer to your DNS queries such as – mail server IP address or website IP address (a resource record). It provides original and definitive answers to DNS queries.... It is used to share DNS server load and to improve DNS zone availability in case master server fails. An authoritative Name server is a (DNS Server) that holds the actual DNS records (A, CNAME, PTR, etc.) for a particular domain/address. A recursive resolver would be a DNS server that queries an authoritative name server to resolve a domain/address. So, for example, if I have a a DNS server in my network that holds an A record for foobar.com, my DNS server would be authoritative for the foobar.com domain. If clients needed to access foobar.com, they could query my DNS server and they would get an authoritative response. However, if a client needed to access contoso.com and they queried my DNS server, it would not have records to resolve that domain. In order for my DNS server to resolve contoso.com, it would need to use recursive lookups (via Forwarders or Root Hints). My DNS server would be set to send queries for domains for which it is not authoritative to another DNS server. That DNS server would do the same, until the query reached a DNS server that was authoritative for CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 51 contoso.com. That DNS server would return the proper records, which would be passed all the way back down to the client. Record Configuration Authoritative Name Servers Resolving Name Server User/Browser Fig. 3.5: Authoritative Hosts 3.7 Delegating Authority DNS is actually a series of delegations: the root.zone to the .com zone to the .example.com zone. How do those zones link together? This is done by that process mentioned earlier, delegation, in which one zone points the authority to the next in the chain. The process for dyn.com looks like this using my own computer through Google DNS. The process for dyn.com looks like this using my own computer through Google DNS. Google initially knows the names of the root name servers because they are hard-coded into the hints file. The root zone looks at the request for dyn.com. and notices that it is in the com namespace. There is a label for com in the root zone, with 13 nameservers as NS records. The nameserver records found in the zone performing the delegation (root in this case) are known as the parent nameservers of the delegation. The inclusion of these nameservers at this spot indicates the answer to this query is not on the current nameserver or zone, and the resolver should try the ones provided. CU IDOL SELF LEARNING MATERIAL (SLM)

52 Advanced Computer Networks Fig. 3.6: Delegating Authority This produces a zone cut to a new zone within the new delegated zone. At the location of those 13 new name servers, there is a zone file for the domain of com, with a Start of Authority (SOA) record so indicating. Along with the SOA, there are an additional 13 name servers in the apex of the com zone signaling that you are in the right place. These are known as the child name servers of the delegation. The recursive follows this process, again and again, until it gets to the authoritative for the DNS name in question and “voila!” gets the answer. For this example, the domain name is delegated to a name server that is a different domain entirely, but sometimes domain operators will choose to have the domain delegated to a name server within the zone itself. This is known as being in bailiwick and would look like example.com being delegated to a name server ns1.example.com. How did we get the IP of the original name server to ask the question in the first place? We have created a version of the bootstrap paradox. How do we get around it? Name servers are able to pass on information in a DNS request such as the authority section to provide information on which name server is currently responding, as well as an additional section to provide more information on the answer. In the case of name servers, the additional section CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 53 contains the IP addresses of the name servers, to be used for the initial lookup – breaking the paradox. These are glue records, and they must be in the parent zone file. See the entry below for an example of authority along with additional sections in a DNS response. Some recursives will prefer the parent NS records for name server selection, others will prefer to query the child name servers for child NS record, and still others will use the authority section within a DNS response handed out by those child name servers. There could be differences in TTLs between the parent and child NS records, and even the number and content of the records themselves if you misconfigured them, or have a lame delegation in which one of the name servers in delegation does not respond to queries. CU IDOL SELF LEARNING MATERIAL (SLM)

54 Advanced Computer Networks Is it, therefore, highly advisable that your parent and child name servers match on both sides of the delegation, with all name servers correctly responding. Of course, sometimes, they can be different, in order to allow you to change name servers. But, as a general rule, they should be the same. Delegation is the tool by which the DNS has become so scalable. By delegating control of zones to individual parties, yet having a central starting point in the root, DNS has been able to grow to billions of individual organizations. Through this network of DNS operations, it has been argued that the DNS is in fact the largest distributed network in the world. In our next installment, we will dive into the terms used for DNS administration and zone file management. 3.8 DNS Resource Records  A (Host address)  AAAA (IPv6 host address)  ALIAS (Auto resolved alias)  CNAME (Canonical name for an alias)  MX (Mail exchange)  NS (Name server)  PTR (Pointer)  SOA (Start of authority)  SRV (Location of service) ● TXT (Descriptive text) 3.9 SOA Records SOA (Start of Authority) The start of authority (SOA) is the first line in the zone file. The SOA identifies the name server as the authoritative source for information about this domain. Each zone file has only one SOA, and it contains the following data: @ IN SOA main.tactechnology.com. mail.tactechnology.com. { OR @ IN SOA server.rkt.com. root.server.rkt.com { CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 55 42 ; serial 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum TTL IN NS localhost localhost IN A 127.0.0.1 }; The first character in the SOA line is a special symbol that means “to look at this domain.” In this example, IN means Internet. SOA means Start of authority. Authoritative server for this domain is server.rkt.com. Root Domain Server is root.server.rkt.com. The opening parenthesis enables the first line to be extended so that anything between the opening and closing parenthesis is considered one line. The information within the parenthesis is passed to other name servers, secondary masters that use this information to update their records. Serial: The line containing 42; Serial is the serial number of the file. Secondary servers compare this number with their stored information. If the numbers are the same and the information has not changed, it is not necessary to download this file. If the serial numbers are different, the file is downloaded to update the information in the secondary server. The serial number can be any number desired as long as it can be incremented to indicate a revision to the file. The semicolon indicates what follows to the end of the line is a comment. Refresh: The amount of time the server should wait before refreshing its data. Retry: The amount of time the server should wait before attempting to contact the primary server if the previous attempt failed. Expire: Means that if the secondary master is unable to contact a primary master during the specified period, the data expires and should be purged. CU IDOL SELF LEARNING MATERIAL (SLM)

56 Advanced Computer Networks TTL: Specifies the time to live. This parameter is intended for caching name servers and tells them how long to hold the data in their cache. All of the information contained by the SOA may be placed on one line, but it is usually written as shown previously. The order of the items is significant in the SOA header. Following the SOA header information are lines containing additional server information. Two of these lines, containing the abbreviations NS and A, are shown in the Listing. These abbreviations are explained here: NS: Name servers in this domain. A: The IP address for the name server. PTR: Pointer for address name mapping. CNAME: Canonical name, the real name of the host. MX: The mail exchange record. The MX record specifies the mail servers for the domain. If more than one MX server is present, priority is determined by the address with the lowest number receiving the highest priority. TXT: Text information. You can enter descriptive information here. WKS: Well-known service. You can enter descriptive information here. HINFO: Host information usually shows the type of hardware and software. Zone file consists of all types of DNS Records, i.e., NS, A, PTR, HINFO, MX, CNAME, TXT and WKS. Forward Zone file, i.e., named.localhost in Redhat Linux which consists of NS & A Records and MX Records if configured with sendmail server. Reverse Zone file, i.e., named.loopbak in Redhat Linux which consists of NS & PTR A Records and MX Records if configured with sendmail server. 3.10 DNS Protocol The Domain Name System is a ‘hierarchically distributed database’, which is a fancy way of saying that its layers are arranged in a definite order and that its data is distributed across a wide range of machines (just like the roots of a tree branch out from the main root). CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 57 Most companies today have their own little DNS server to ensure the computers can find each other without problems. If you’re using Windows 2000 and Active Directory, then you surely are using DNS for the name resolutions of your computers. Microsoft has created its own version of a “DNS” server, called a WINS server, which stands for Windows Internet Name Service, but this is old technology and uses protocols that are nowhere near as efficient as DNS. So, it was natural for Microsoft to move away from WINS and towards DNS. After all, the whole Internet works on DNS. The DNS protocol works when your computer sends out a DNS query to a name server to resolve a domain. For example, you type “www.firewall.cx” in your web browser. This triggers a DNS request, which your computer sends to a DNS server in order to get the website’s IP Address! There is a detailed example on the pages to follow. So, I won’t get into too much detail for the moment. The Internet Domain Name Server Hierarchy This interesting section will help you understand how domain names on the Internet are structured and where DNS servers fit in to the picture. When you think about the millions of domain names registered today, you probably think that you have to be superhuman to manage such a structure of DNS servers! Well that’s not that case. The DNS structure has been designed in such a way that no DNS server needs to know about all possible domains, but only those immediately above and below it. The picture below shows part of the Internet DNS hierarchical structure: The DNS tree structure “root domain” .au .uk .com .cx Managed by Internic .net .org Managed by Microsoft Managed by us microsoft.com Firewall.cx support.microsoft.com Cisco.com www.firewall.cx support.cisco.com routers.cisco.com www.cisco.com Managed by Cisco Fig. 3.7: The DNS Tree Structure CU IDOL SELF LEARNING MATERIAL (SLM)

58 Advanced Computer Networks Internic controls the “root” domain, which includes all the top-level domains. These are marked in a green oval for clarity. Within the green oval, you have the ROOT DNS servers, which know all about the authoritative DNS servers for the domains immediately below them, e.g., firewall.cx, cisco.com, microsoft.com, etc. These ROOT DNS servers can tell you which DNS server takes care of firewall.cx, cisco.com, microsoft.com and the rest. Each domain, including the ones we are talking about (cisco, firewall, microsoft, etc.), have what we call a “Primary DNS” and “Secondary DNS”. The Primary DNS is the one that holds all the information about its domain. The Secondary DNS acts as a backup in case the Primary DNS fails. The process in which a Primary DNS server sends its copy to the Secondary DNS server is called Zone Transfer, and is covered in the DNS Database section. Today, there are hundreds of websites at which you are able to register your own domain and, once you’ve done that, you have the power to manage it yourself. In the example above, Cisco bought the “Cisco.com” domain and then created your resource records. Some examples of resource records for the Cisco domain in our example are: support, www and routers. These will be analyzed in depth on the next pages. 3.11 DHCP and Scope Resolution DHCP (Dynamic Host Configuration Protocol) is a network management protocol used to dynamically assign an Internet Protocol (IP) address to any device, or node, on a network so that they can communicate using IP. DHCP automates and centrally manages these configurations rather than requiring network administrators to manually assign IP addresses to all network devices. DHCP can be implemented on small local networks as well as large enterprise networks. DHCP will assign new IP addresses in each location when devices are moved from place to place, which means network administrators do not have to manually configure each device with a valid IP address or reconfigure the device with a new IP address if it moves to a new location on the network. Versions of DHCP are available for use in IP version 4 (IPv4) and IP version 6 (IPv6). DHCP runs at the application layer of the Transmission Control Protocol/IP (TCP/IP) stack to dynamically assign IP addresses to DHCP clients and to allocate TCP/IP configuration information to DHCP clients. This includes subnet mask information, default gateway IP addresses and domain name system (DNS) addresses. DHCP is a client-server protocol in which servers manage a pool of unique IP addresses as well as information about client configuration parameters, and assign addresses out of those CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 59 address pools. DHCP-enabled clients send a request to the DHCP server whenever they connect to a network. Clients configured with DHCP broadcast a request to the DHCP server and request network configuration information for the local network to which they are attached. A client typically broadcasts a query for this information immediately after booting up. The DHCP server responds to the client request by providing IP configuration information previously specified by a network administrator. This includes a specific IP address as well as a time period — also called a lease — for which the allocation is valid. When refreshing an assignment, a DHCP client requests the same parameters, but the DHCP server may assign a new IP address based on policies set by administrators. DHCP clients can also be configured on an Ethernet interface. Components DHCP is made up of numerous components, such as the DHCP server, client and relay. The DHCP server — typically either a server or router – is a networked device that runs on the DHCP service. The DHCP server holds IP addresses as well as related information pertaining to configuration. The DHCP client is a device — such as a computer or phone — that can connect to a network and communicate with a DHCP server. The DHCP relay will manage requests between DHCP clients and servers. Typically, relays are used when an organization has to handle large or complex networks. Other components include the IP address pool, subnet, lease and DHCP communications protocol. DHCP Handshake DISCOVER The client sends out a DHCP discover message to identify DHCP servers. DHCP OFFER DHCP CLIENT The DHCP server responds with an available SERVER IP address and options. REQUEST The client requests the IP address from the server. ACKNOWLEDGE The server acknowledges the IP request and completes the initiation cycle. Fig. 3.8: DHCP Handshake CU IDOL SELF LEARNING MATERIAL (SLM)

60 Advanced Computer Networks These messages are given as below: 1. DHCP discover message: This is a first message generated in the communication process between server and client. This message is generated by Client host in order to discover if there is/are any DHCP server/servers present in a network or not. This message is broadcasted to all devices present in a network to find the DHCP server. This message is 342 or 576 bytes long. Any DHCP Server DHCP DISCOVER Dest MAC Address: FFFFFEFFEFFF Source MAC Addr: 08002B3EAF2A Source IP Address: 172.16.32.12 Dest IP Address: 255.255.255.255 0 Client Identifier: 08002B2EAF2A DHCP Client Fig. 3.9: DHCP Discover Message As shown in the above figure, source MAC address (client PC) is 08002B2EAF2A, destination MAC address (server) is FFFFFFFFFFFF, source IP address is 0.0.0.0 (because PC has no IP address till now) and destination IP address is 255.255.255.255 (IP address used for broadcasting). As the discover message is broadcast to find out the DHCP server or servers in the network, therefore broadcast IP address and MAC address is used. 2. DHCP offer message: The server will respond to host in this message specifying the unleased IP address and other TCP configuration information. This message is broadcasted by server. Size of message is 342 bytes. If there are more than one DHCP servers present in the network, then client host will accept the first DHCP OFFER message it receives. Also, a server ID is specified in the packet in order to identify the server. Now, for the offer message, source IP address is 172.16.32.12 (server’s IP address in the example), destination IP address is 255.255.255.255 (broadcast IP address), source MAC address is 00AA00123456 and destination MAC address is FFFFFFFFFFFF. Here, the offer message is broadcast by the DHCP server. Therefore, the destination IP address is broadcast IP address, the destination MAC address is FFFFFFFFFFFF, the source IP address is server IP address and MAC address is server MAC address. CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 61 DHCP Server 172.16.32.12 DHCPOFFER DHCP Client Dest MAC Address: FFFFFEFFEFFF Source MAC Addr: 00AA00123456 Source IP Address: 172.16.32.12 Dest IP Address: 255.255.255.255 Offered IP Address: 172.16.32.51 Server Identifier: 172.16.32.12 Lease Length: 72 Hours Client Identifier: 08002B2EAF2A Fig. 3.10: DHCP Offer Message Also, the server has provided the offered IP address 192.16.32.51 and lease time of 72 hours (after this time, the entry of host will be erased from the server automatically). Also, the client identifier is PC MAC address (08002B2EAF2A) for all the messages. 3. DHCP request message: When a client receives a offer message, it responds by broadcasting a DHCP request message. The client will produce a gratuitous ARP in order to find if there is any other host present in the network with same IP address. If there is no reply by other host, then there is no host with same TCP configuration in the network and the message is broadcasted to server showing the acceptance of IP address. A Client ID is also added in this message. DHCP Servers DHCPREQUEST 172.16.32.12 Dest MAC Address: FFFFFEFFEFFF Source MAC Addr: 08002B2EAF2A Source IP Address: 0.0.0.0 Dest IP Address: 255.255.255.255 Request IP Address: 172.16.32.51 Server Identifier: 172.16.32.12 Client Identifier: 08002B2EAF2A Request parameters................... DHCP Client Fig. 3.11: DHCP Request Message Now, the request message is broadcast by the client PC. Therefore, source IP address is 0.0.0.0 (as the client has no IP right now) and destination IP address is 255.255.255.255 (broadcast IP address), and source MAC address is 08002B2EAF2A (PC MAC address) and destination MAC address is FFFFFFFFFFFF. CU IDOL SELF LEARNING MATERIAL (SLM)

62 Advanced Computer Networks Note: This message is broadcast after the ARP request broadcast by the PC to find out whether any other host is not using that offered IP. If there is no reply, then the client host broadcast the DHCP request message for the server showing the acceptance of IP address and other TCP/IP configuration. 4. DHCP acknowledgement message: In response to the request message received, the server will make an entry with specified client ID and bind the IP address offered with lease time. Now, the client will have the IP address provided by server. DHCP Server 172.16.32.12 DHCP ACK DHCP Client Dest MAC Address: FFFFFEFFEFFF Source MAC Addr: 00AA00123456 Source IP Address: 172.16.32.12 Dest IP Address: 255.255.255.255 IP Address: 172.16.32.51 Server Identifier: 172.16.32.12 Lease Length: 72 Hours Client Identifier: 08002B2EAF2A Other Request Parameters....... Fig. 3.12: DHCP Acknowledgement Message 1. Now, the server will make an entry of the client host with the offered IP address and lease time. This IP address will not be provided by server to any other host. The destination MAC address is FFFFFFFFFFFF and the destination IP address is 255.255.255.255 and the source IP address is 172.16.32.12 and the source MAC address is 00AA00123456 (server MAC address). 2. DHCP negative acknowledgement message: Whenever a DHCP server receives a request for IP address that is invalid according to the scopes that is configured with, it send DHCP Nak message to client. For example, when the server has no IP address unused or the pool is empty, then this message is sent by the server to client. 3. DHCP decline: If DHCP client determines the offered configuration parameters are different or invalid, it sends DHCP decline message to the server. When there is a reply to the gratuitous ARP by any host to the client, the client sends DHCP decline message to the server showing the offered IP address is already in use. CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 63 4. DHCP release: A DHCP client sends DHCP release packet to server to release IP address and cancel any remaining lease time. 5. DHCP inform: If a client address has obtained IP address manually, then the client uses a DHCP inform to obtain other local configuration parameters, such as domain name. In reply to the dhcp inform message, DHCP server generates DHCP ack message with local configuration suitable for the client without allocating a new IP address. This DHCP ack message is unicast to the client. 3.12 Summary The Domain Name System delegates the responsibility of assigning domain names and mapping those names to Internet resources by designating authoritative name servers for each domain. Network administrators may delegate authority over sub-domains of their allocated name space to other name servers. This mechanism provides distributed and fault-tolerant service and was designed to avoid a single large central database. The DHCP (Dynamic Host Configuration Protocol) and DNS (Domain Name System) are both created to make it easy for us to use networks or the Internet. However, they are totally two different technologies in actual applications. The DHCP is a protocol that helps us to assign an IP address and related IP information to the computer in the network. Whereas the DNS is used to convert a website name like FS.COM to its IP address and vice versa. This is to ensure that our computer can find the right site because a computer can only find a site through its IP address, rather than its domain name. You may still be confused about how to differentiate them. So, we have created a detailed overview of exactly how DHCP and DNS work, and the differences between them. DHCP is a client-server protocol. A client is a device that is configured to use DHCP to request network parameters from a DHCP server. DHCP server maintains a pool of available IP addresses and assigns one of them to the host. A DHCP server can also provide some other parameters, such as: subnet mask, default gateway, domain name and DNS server. 3.13 Keywords/Abbreviations  DHCP: The Dynamic Host Configuration Protocol (DHCP) is a network protocol used to configure devices that are connected to a network so that they can communicate on that network using the Internet Protocol (IP). CU IDOL SELF LEARNING MATERIAL (SLM)

64 Advanced Computer Networks  DNS: Domain Name System (DNS) is the system in the Internet that maps names of objects (usually host names) into IP numbers or other resource record values.  Zone file: A file consists of all types of DNS Records, i.e., NS, A, PTR, HINFO, MX, CNAME, TXT and WKS.  Forward Zone File: A file consists of NS & A Records and MX Records if configured with sendmail server.  Reverse Zone File: A file consists of NS & PTR A Records and MX Records if configured with sendmail server. Abbreviations  SOA: Start of Authority  IN: Internet  CNAME: Canonical Name  WKS: Well-known Service  HINFO: Host Information  TTL: Time To Live  DHCP: Dynamic Host Configuration Protocol (DHCP)  DNS: Domain Name System (DNS) 3.14 Learning Activity 1. What is Primary and Secondary name server? ----------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 2. What is DNS resolver? ----------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 3. What is DNS Server? ----------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- CU IDOL SELF LEARNING MATERIAL (SLM)

Domain Network Services (DNS) 65 4. What is the use of PTR in DNS? ----------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 3.15 Unit End Questions (MCQs and Descriptive) A. Descriptive Type Questions 1. Write a short note on DNS. 2. What do you mean by the resolution in DNS? What are its types? Explain. 3. Explain the domains in DNS. 4. Explain Hierarchy of Name Servers. 5. Explain how DNS works. 6. Explain Authoritative Hosts in DNS. 7. Explain Delegating Authority with Zones. 8. Explain DNS Resource Records used. 9. Explain SOA records in detail. 10. Explain DNS protocol usage. 11. Explain DHCP in detail with its scope. B. Multiple Choice/Objective Type Questions 1. A DNS client is called __________. (a) DNS updater (b) DNS resolver (c) DNS handler (d) None of the above 2. DHCP is used for __________. (a) IPv6 (b) IPv4 (c) Both IPv6 and IPv4 (d) None of the above 3. After obtaining the IP address, to prevent the IP conflict, the client may use __________. (a) Internet relay chat (b) Broader gateway protocol (c) Address resolution protocol (d) None of the above CU IDOL SELF LEARNING MATERIAL (SLM)

66 Advanced Computer Networks 4. Which one of the following allows client to update their DNS entry as their IP address change? (a) Dynamic DNS (b) Authoritative name server (c) Mail transfer agent (d) None of the above 5. DHCP client and servers on the same subnet communicate via _________. (a) UDP broadcast (b) UDP unicast (c) TCP broadcast (d) TCP unicast Answers 1. (b), 2. (c), 3. (c), 4. (a), 5. (a) 3.16 References 1. http://intronetworks.cs.luc.edu/current/ComputerNetworks.pdf 2. http://www.nortonaudio.com/Ficheiros/1118474082.Netwo.pdf 3. Computer Network (Third Edition) by Andrew S. Tanenbaum. CU IDOL SELF LEARNING MATERIAL (SLM)

UNIT 4 NETWORK APPLICATIONS Structure: 4.0 Learning Objectives 4.1 Introduction 4.2 Electronic Mail 4.3 Hyper Text Transfer Protocol (HTTP) 4.3.1 Client-Server Approach 4.3.2 HTTP Introduction 4.3.3 Features of HTTP Protocol 4.3.4 Basic Architecture of HTTP 4.3.5 HTTP Request Methods 4.3.6 HTTP Request and Response 4.3.7 Working of HTTP Protocol 4.4 Summary 4.5 Keywords/Abbreviations 4.6 Learning Activity 4.7 Unit End Questions (MCQs and Descriptive) 4.8 References CU IDOL SELF LEARNING MATERIAL (SLM)

68 Advanced Computer Networks 4.0 Learning Objectives After studying this unit, you will be able to:  Explain Hypertext transfer protocol  Describe e-mail application 4.1 Introduction  An application layer protocol defines how an application’s processes, running on different end systems, pass messages to each other. In particular, an application layer protocol defines: — The types of messages exchanged, for example, request messages and response messages. — The syntax of the various message types, such as the fields in the message and how the fields are delineated. — The semantics of the fields, i.e., the meaning of the information in the fields. — Rules for determining when and how a process sends messages and responds to messages.  An application layer protocol is only one piece of a network application. A network is a collection or set of computing devices connected to one another to establish communication and also share available resources. A network will comprise software and hardware devices.  Computer network applications are network software applications that utilize the Internet or other network hardware infrastructure to perform useful functions, e.g., file transfers within a network. They help us to transfer data from one point to another within the network.  HTTP is a protocol used to access the data on the World Wide Web (www). This protocol is known as Hyper Text Transfer Protocol because of its efficiency that allows us to use in a hypertext environment where there are rapid jumps from one document to another document. HTTP is similar to the FTP as it also transfers the files from one host to another host. But, HTTP is simpler than FTP as HTTP uses only one connection, i.e., no control connection to transfer the files. CU IDOL SELF LEARNING MATERIAL (SLM)

Network Applications 69 4.2 Electronic Mail 1. Architecture and Services E-mail systems consist of two subsystems. They are: 1. User Agents, which allow people to read and send e-mail. 2. Message Transfer Agents, which move messages from source to destination. E-mail systems support five basic functions: (a) Composition (b) Transfer (c) Reporting (d) Displaying (e) Disposition (a) Composition: It refers to the process of creating messages and answers. Any text editor is used for body of the message while the system itself can provide assistance with addressing and numerous header fields attached to each message. (b) Reporting: It has to do with telling the originator what happened to the message, i.e., whether it was delivered, rejected (or) lost. (c) Transfer: It refers to moving messages from originator to the recipient. (d) Displaying: Incoming messages are to be displayed so that people can read their e-mail. (e) Disposition: It concerns what the recipient does with the message after receiving it. Possibilities include throwing it away before reading (or) after reading, saving it and so on. Most systems allow users to create mailboxes to store incoming e-mail. Commands are needed to create and destroy mailboxes, inspect the contents of mailboxes, insert and delete messages from mailboxes, and so on. CU IDOL SELF LEARNING MATERIAL (SLM)

70 Advanced Computer Networks Mr. Daniel Dumkopf Name: Mr. Daniel Dumkopf Envelope 18 Willow Lane Street: 18 Willow Lane City: White Plains White Plains, NY 10604 State: NY Zip Code: 10604 United Gizmo Priority: Urgent 180 Main St Encryption: None Boston, MA 02120 Sept. 1, 2002 From: United Gizmo Subject: Invoice 1081 Address: 180 Main St Location: Boston, MA 02120 Dear Mr. Dumkopf, Date: Sept. 1, 2002 Our computer records show that Subject: Invoice 1081 you still have not paid the above invoice of $0.00. Please send us Dear Mr. Dumkopf, Message a check for $0.00 promptly. Our computer records show that you still have not paid the above Yours truly invoice of $0.00. Please send us United Gizmo a check for $0.00 promptly. Yours truly United Gizmo (a) (b) Fig. 4.1: Envelopes and Messages. (a) Paper Mail. (b) Electronic Mail. 1. The User Agent A user agent is normally a program (sometimes called a mail reader) that accepts a variety of commands for composing, receiving and replying to messages as well as for manipulating mailboxes. Sending E-mail To send an e-mail message, a user must provide the message, the destination address, and possibly some other parameters. The message can be produced with a free-standing text editor, a Word processing program, or possibly with a specialized text editor built into the user agent. The destination address must be in a format that the user agent can deal with. Many user agents expect addresses of the form user@dns-address. CU IDOL SELF LEARNING MATERIAL (SLM)

Network Applications 71 Reading E-mail When a user agent is started up, it looks at the user’s mailbox for incoming e-mail before displaying anything on the screen. Then it may announce the number of messages in the mailbox or display a one-line summary of each one and wait for a command. 2. Message Formats RFC 822 Messages consist of a primitive envelope (described in RFC 821), some number of header fields, a blank line, and then the message body. Each header field (logically) consists of a single line of ASCII text containing the field name, a colon, and, for most fields, a value. Table 4.1: RFC 822 Header Fields Related to Message Transport Header Meaning To: E-mail address(es) of primary recipients(s) Cc: E-mail address(es) of secondary recipient(s) Bcc: E-mail address(es) for blind carbon copies From: Person or people who created the message Sender: E-mail address of the actual sender Received: Line added by each transfer agent along the route Return:Path: Can be used to identify a path back to the sender MIME — The Multipurpose Internet Mail Extensions RFC 822 specified the headers but left the content entirely up to the users. Nowadays, on the worldwide Internet, this approach is no longer adequate. The problems include sending and receiving: 1. Messages in languages with accents (e.g., French and German). 2. Messages in non-Latin alphabets (e.g., Hebrew and Russian). 3. Messages in languages without alphabets (e.g., Chinese and Japanese). 4. Messages not containing text at all (e.g., audio or images). A solution was proposed in RFC 1341 called MIME (Multipurpose Internet Mail Extensions). CU IDOL SELF LEARNING MATERIAL (SLM)

72 Advanced Computer Networks The basic idea of MIME is to continue to use the RFC 822 format, but to add structure to the message body and define encoding rules for non-ASCII messages. By not deviating from RFC 822, MIME messages can be sent using the existing mail programs and protocols. All that has to be changed are the sending and receiving programs, which users can do for themselves. Table 4.2: RFC 822 Headers Added by MIME Header Meaning MIME Version Identifies the MIME version Content-Description Human-readable string telling what is the message Content-ID Unique identifier Content-Transfer-Encoding How the body is wrapped for transmission Content-Type Type and format of the content Message Transfer The message transfer system is concerned with relaying messages from the originator to the recipient. The simplest way to do this is to establish a transport connection from the source machine to the destination machine and then just transfer the message. SMTP—The Simple Mail Transfer Protocol SMTP is a simple ASCII protocol. After establishing the TCP connection to port 25, the sending machine, operating as the client, waits for the receiving machine, operating as the server, to talk first. The server starts by sending a line of text giving its identity and telling whether it is prepared to receive mail. If it is not, the client releases the connection and tries again later. Even though the SMTP protocol is completely well-defined, a few problems can still arise. One problem relates to message length. Some older implementations cannot handle messages exceeding 64 KB. Another problem relates to timeouts. If the client and server have different timeouts, one of them may give up while the other is still busy, unexpectedly terminating the connection. Finally, in rare situations, infinite mailstorms can be triggered. For example, if host 1 holds mailing list A and host 2 holds mailing list B, and each list contains an entry for the other one, then a message sent to either list could generate a never- ending amount of e-mail traffic unless somebody checks for it. CU IDOL SELF LEARNING MATERIAL (SLM)

Network Applications 73 Final Delivery With the advent of people who access the Internet by calling their ISP over a modem, it breaks down. One solution is to have a message transfer agent on an ISP machine accept e-mail for its customers and store it in their mailboxes on an ISP machine. Since this agent can be online all the time, e-mail can be sent to it 24 hours a day. POP3 SMTP Internet Message User transfer agent agent (a) Sending Permanent Mailbox Receiving host connection host SMTP Internet Message POP3 POP3 User transfer server agent agent (b) Sending Mailbox ISP’s Dial-up User’s host machine connection PC Fig. 4.2: (a) Sending and reading mail when the receiver has a permanent Internet connection and the user agent runs on the same machine as the message transfer agent. (b) Reading e-mail when the receiver has a dial-up connection to an ISP. POP3 begins when the user starts the mail reader. The mail reader calls up the ISP (unless there is already a connection) and establishes a TCP connection with the message transfer agent at port 110. Once the connection has been established, the POP3 protocol goes through three states in sequence: 1. Authorization 2. Transactions 3. Update The authorization state deals with having the user log in. The transaction state deals with the user collecting the e-mails and marking them for deletion from the mailbox. CU IDOL SELF LEARNING MATERIAL (SLM)

74 Advanced Computer Networks The update state actually causes the e-mails to be deleted. IMAP (Internet Message Access Protocol) POP3 normally downloads all stored messages at each contact, the result is that the user’s e- mail quickly gets spread over multiple machines, more or less at random; some of them not even the user’s. This disadvantage gave rise to an alternative final delivery protocol, IMAP (Internet Message Access Protocol). IMAP assumes that all the e-mail will remain on the server indefinitely in multiple mailboxes. IMAP provides extensive mechanisms for reading messages or even parts of messages, a feature useful when using a slow modem to read the text part of a multipart message with large audio and video attachments. 4.3 Hyper Text Transfer Protocol (HTTP) 4.3.1 Client-Server Approach All the resources and users on the Internet are using the Hyper Text Transfer Protocol (HTTP). The World Wide Web is the universe of network-accessible information, an embodiment of human knowledge. In simple terms, The World Wide Web is a way of exchanging information between computers on the Internet, tying them together into a vast collection of interactive multimedia resources. User enters the URL (say, http://www.mydomain.com) of the web page in the address bar of web browser. Then browser requests the Domain Name Server for the IP address corresponding to www.tutorialspoint.com. After receiving IP address, browser sends the request for web page to the web server using HTTP protocol which specifies the way the browser and web server communicates. Following is client-server approach. Following steps explains how the web works: CU IDOL SELF LEARNING MATERIAL (SLM)

Network Applications 75 Request for web page Request for web page Internet Web browser Web Page Web Page Web Server (Client) HTML file HTML file Fig. 4.3: Client-Server Approach Then web server receives request using HTTP protocol and checks its search for the requested web page. If found, it returns it back to the web browser and closes the HTTP connection. Now, the web browser receives the web page, It interprets it and displays the contents of web page in web browser’s window. Uniform Resource Locator (URL) ● The URL is a standard for specifying any kind of information on the Internet. ● The URL consists of four parts: protocol, host computer, port and path. ● The protocol is the client or server program which is used to retrieve the document or file. The protocol can be ftp or http. ● The host is the name of computer on which the information is located. ● The URL can optionally contain the port number and it is separated from the host name by a colon. ● Path is the pathname of the file where the file is stored. 4.3.2 HTTP Introduction HTTP (full form Hyper Text Transfer Protocol) is used mainly to access data on the World Wide Web. HTTP is a Server and Client Communication Protocol, which is primarily set of rules for formatting and transferring web page data (text, images, video and multimedia files) over the world wide web. This is the Protocol used to create communication between Web Servers and Web Users. HTTP is an application layer protocol that works on the top of the TCP/IP suite of protocols. HTTP protocol functions like a combination of FTP and SMTP. It is similar to FTP because it transfers files and uses the services of TCP. However, it is much simpler than FTP because it CU IDOL SELF LEARNING MATERIAL (SLM)

76 Advanced Computer Networks uses only one TCP connection. There is no separate control connection; only data is transferred between the client and the server. HTTP protocol is like SMTP protocol because the data transferred between the client and the server looks like SMTP messages. In addition, MIME-like headers control the format of the messages. However, HTTP differs from SMTP in the way the messages are sent from the client to the server and from the server to the client. Unlike SMTP, the HTTP messages are not destined to be read by humans; they are read and interpreted by the HTTP server and HTTP client (browser). SMTP messages are stored and forwarded, but HTTP messages are delivered immediately. The idea of HTTP protocol is very simple. A client sends a request, which looks like mail, to the server. The server sends the response, which looks like a mail reply, to the client. The request and response messages carry data in the form of a letter with MIME-like format. 4.3.3 Features of HTTP Protocol The features of the HTTP protocol are as follows: ● HTTP is Connectionless: The HTTP client, i.e., the web browser makes an HTTP request and waits for the server to respond. Now, it is the task of the server to process the request made by the client. So, after processing, the server gives the response to the client. After receiving the response, the client disconnects the connection. ● HTTP is media-independent: Here, media-independent means that any data can be sent. Also, we have to mention the content type as per the requirement of the client and the server. ● HTTP is stateless: HTTP is a stateless protocol. Only during the current request, the client and the server know about each other, and when the connection disconnects, both client and the server forget about each other. Due to this nature, both the client and the server do not retain the information between the different requests processed. 4.3.4 Basic Architecture of HTTP Since it is a client-server based architecture, it makes use of a request/response protocol. In this, web browsers and search engines act as the client of the system, and the web server acts as the server of the system. CU IDOL SELF LEARNING MATERIAL (SLM)

Network Applications 77 Web Server Web Client Server Side Script Database HTTP Protocol Fig. 4.4: Basic Architecture of HTTP 4.3.5 HTTP Request Methods HTTP Protocol can use two case-sensitive request-response methods between client-server such as GET and POST that are used to handle form submissions. ● GET Method: A GET requests data from a specified resource using a given URI to retrieve data. ● POST Method: A POST request submits data to be processed to a specified resource to the server. Note: URLs that start with “http://” use port 80 by default and URL with “https://” are secure connection use port 443. 4.3.6 HTTP Request and Response A HTTP request message consists of a request line, headers and sometimes a body. An HTTP request is a way that web browsers ask for information to load website pages. HTTP request contains HTTP version type, a URL, HTTP request headers and HTTP body. ● HTTP Request Headers: HTTP request headers include text information saved in key- value pairs and these are contained in every HTTP request. ● URL: A client that wants to access a document needs an address. To facilitate the access of documents distributed throughout the world, HTTP protocol uses the concept of locations. The World Wide Web uses a locator called a URL to identify and inter-tribal data. CU IDOL SELF LEARNING MATERIAL (SLM)

78 Advanced Computer Networks URL is called as Uniform Resource Locator. A URL is an internet address of any website in common format (http://mydomain.com). A URL has three parts https://themeisle.com/blog/fix-broken-links-in-wordpress/ https :  Protocol themeisle.com  Domain blog/fix-broken-links-in-wordpress/  path A HTTP response means when the web client gets the answer back from the web server. It contains the information that was asked for in the HTTP request. HTTP response contains an HTTP status code, HTTP response headers and HTTP body. ● HTTP Status Codes: Many times, when a client sends a request to the server and if the HTTP request is not correct, then the error comes. These errors are shown in numeric codes. These are also called as HTTP status codes. These status codes are given by the server to identify the problem. If a client does not know the difference between codes, how a client can solve the problem. So, the client has to know about every code. Some common codes are shown below. 401 – “Unauthorized” 400 – “Bad request” 404 – “File not found” 4.3.7 Working of HTTP Protocol The first step is initiating a TCP connection with the server by the client. Once the connection is established, the browser and the server access TCP through their socket interfaces. The http request first line of the message is called the request line. The lines below the request line are known as header lines. The request line has three fields – method, URL and version. Method field can take several values like GET, POST, HEAD, PUT, DELETE, etc. The GET method is used when the browser requests an object, with the requested object identified in the URL field. ● GET: It retrieves those document which is identified in the URL. ● POST: It gives information to the server. ● HEAD: It retrieves the meta information about the document identified in the URL. ● PUT: It stores those documents which are underspecified URL. CU IDOL SELF LEARNING MATERIAL (SLM)

Network Applications 79 ● DELETE: It deletes the specified URL. ● TRACE: It will loop back the request message. HTTP response message has three sections – status line, header lines and an entity body. Further, the status line has three fields – version, status code and phrase. After that, there are header lines. In the end, there is the entity body, which contains the requested message itself. 4.4 Summary ● Network Application layer is the topmost layer of OSI Model. Manipulation of data (information) in various ways is done in this layer which enables user or software to get access to the network. Some services provided by this layer includes e-mail, transferring files, distributing the results to user, directory services, network resources, etc. ● The Application Layer contains a variety of protocols that are commonly needed by users. One widely used application protocol is HTTP (Hyper Text Transfer Protocol), which is the basis for the World Wide Web. When a browser wants a web page, it sends the name of the page it wants to the server using HTTP. The server then sends the page back. Other application protocols that are used includes: File Transfer Protocol (FTP), Trivial File Transfer Protocol (TFTP), Simple Mail Transfer Protocol (SMTP), TELNET, Domain Name System (DNS), etc. 4.5 Keywords/Abbreviations  MIME: A supplementary protocol which allows non-ASCII data to be sent through SMTP.  SMTP: A set of communication guidelines that allow software to transmit an electronic mail over the internet.  DNS: A service that translates the domain name into IP addresses.  HTTP: A protocol used to access the data on the World Wide Web (www).  Mail Services: An application layer provides e-mail forwarding and storage.  Directory Services: An application contains a distributed database that provides access for global information about various objects and services.  Network Virtual Terminal: An application layer that allows a user to log on to a remote host.  URL: A standard way of specifying any kind of information on the internet. CU IDOL SELF LEARNING MATERIAL (SLM)

80 Advanced Computer Networks Abbreviations  HTTP: Hyper Text Transfer Protocol  URL: Uniform Resource Locator  MIME: The Multipurpose Internet Mail Extensions  SMTP: The Simple Mail Transfer Protocol  IMAP: Internet Message Access Protocol 4.6 Learning Activity 1. What do you mean by HTTP? ----------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 2. What is the difference between the Internet, Intranet and Extranet? ----------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 3. What do you mean by anonymous FTP? ---------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 4.7 Unit End Questions (MCQs and Descriptive) A. Descriptive Type Questions 1. Explain Electronic mail with SMTP and MIME protocols. 2. Explain mechanism of E-mail Message Sending. 3. Explain HTTP Protocol and its working in detail. 4. Explain features of HTTP Protocol. 5. Explain the architecture of HTTP. 6. Explain HTTP Request and Response Methods. CU IDOL SELF LEARNING MATERIAL (SLM)

Network Applications 81 B. Multiple Choice/Objective Type Questions 1. In the network, HTTP resources are located by __________. (a) Uniform resource identifier (b) Unique resource locator (c) Unique resource identifier (d) Union resource locator 2. HTTP is __________ protocol. (a) Data link layer (b) Transport layer (c) Network layer (d) Application layer 3. The HTTP response message leaves out the requested object when __________ method is used. (a) GET (b) POST (c) HEAD (d) PUT 4. In the process of fetching a web page from a server, the HTTP request/response takes __________ RTTs. (a) 2 (b) 1 (c) 4 (d) 3 5. When displaying a web page, the application layer uses the __________ Protocol. (a) HTTP (b) FTP (c) SMTP (d) TCP Answers 1. (a), 2. (d), 3. (c), 4. (b), 5. (a) 4.8 References 1. http://intronetworks.cs.luc.edu/current/ComputerNetworks.pdf 2. https://www.ece.rutgers.edu/~marsic/books/CN/book-CN_marsic.pdf 3. Data Communications and Networking Book by Behrouz A. Forouzan. CU IDOL SELF LEARNING MATERIAL (SLM)

UNIT 5 HTTP COMMUNICATIONS Structure: 5.0 Learning Objectives 5.1 Introduction 5.2 HTTP Request 5.3 Request Headers/Responses 5.4 Status Code 5.5 Error Status Code E-mail – Sending and Receiving E-mails 5.6 E-mail Addressing 5.7 Message Structure 5.8 MIME: Multipurpose Internet Mail Extensions 5.9 SMTP: Simple Mail Transfer Protocol with Examples 5.10 Summary 5.11 Keywords/Abbreviations 5.12 Learning Activity 5.13 Unit End Questions (MCQs and Descriptive) 5.14 References CU IDOL SELF LEARNING MATERIAL (SLM)

HTTP Communications 83 5.0 Learning Objectives After studying this unit, you will be able to:  Explain HTTP request and e-mail addressing  Describe Multipurpose Internet Mail Extensions  Exemplify Simple Mail Transfer Protocol 5.1 Introduction HTTP is abbreviated as Hyper Text Transfer Protocol, an application layer protocol used primarily with the www (World Wide Web) in the client-server model where a web browser is a client communicating with the web server which is hosting the website. Since 1990, this has become the foundation for data communication. HTTP is a standard and stateless protocol that is used for different purposes as well using extensions for request methods, error codes as well as headers. HTTP is a communic ation protocol which is employed for delivering data (usually HTML files, multimedia files, etc.) on the World Wide Web through its default TCP port 80. However, there are other ports also which can be implemented for this function. HTTP has two different versions, HTTP/1.0, which is the old one and the newest HTTP/1.1. In its older version, a separate connection was required. In the case of a new version, the same connection can be recycled several times. HTTP Request HTTP Response Client Server Fig. 5.1: HTTP Protocol The HTTP is meant for request/response depending on a client-server architecture where the user requests information through a web browser to the web server, which then responds to the requested data. Web Client: The client of this client-server architecture asks for a request to a specific server through the HTTP (TCP/IP connection) as a request method in the form of a URL. It also contains a MIME-like message that contains request modifier and client information. CU IDOL SELF LEARNING MATERIAL (SLM)

84 Advanced Computer Networks Web Server: This accepts the request and process with a response by a status line, together with the version of the message’s protocol as well as the success or error code, followed by a MIME-like message having server information, some metadata, and possible the entity-body content holding the requested information. 5.2 HTTP Request Hyper Text Transfer Protocol (HTTP) HTTP is perhaps the most popular application protocol used in the Internet (or the web).  HTTP is an asymmetric request-response client-server protocol as illustrated. An HTTP client sends a request message to an HTTP server. The server, in turn, returns a response message. In other words, HTTP is a pull protocol; the client pulls information from the server (instead of server pushes information down to the client). HTTP Request Message HTTP Clients HTTP HTTP Server (Web Server) (Web Browser) Response Message HTTP over TCP/IP Fig. 5.2: HTTP Protocol with Request and Response with Web Server  HTTP is a stateless protocol. In other words, the current request does not know what has been done in the previous requests.  HTTP permits negotiating of data type and representation, so as to allow systems to be built independently of the data being transferred.  Quoting from the RFC2616: “The Hyper Text Transfer Protocol (HTTP) is an application level protocol for distributed, collaborative, hypermedia information systems. It is a generic, stateless, protocol which can be used for many tasks beyond its use for hypertext, such as name servers and distributed object management systems, through extension of its request methods, error codes and headers.” CU IDOL SELF LEARNING MATERIAL (SLM)

HTTP Communications 85 HTTP Requests In HTTP, every request must have an URL address. Additionally, the request needs a method. The four main HTTP methods are:  GET  PUT  POST  DELETE These methods directly correspond to actions:  read  update  create  delete All HTTP messages have one or more headers, followed by an optional message body. The body contains the data that will be sent with the request or the data received with the response. The first part of every HTTP request holds three items: Example:  GET /adds/search-result?item=vw+beetle HTTP/1.1 When a URL contains a “?” sign, it means it contains a query, i.e., it sends parameters of the requested resource. 1. The first part is a method which tells which HTTP method is used. Most commonly used is the GET method. GET method retrieves a resource from the web server and since GET does not have a message body, nothing after the header is needed. 2. The second part is a requested URL. 3. The third part is a HTTP version being used. Version 1.1. is the most common version for most browsers. However, Version 2.0 is taking over. CU IDOL SELF LEARNING MATERIAL (SLM)

86 Advanced Computer Networks 5.3 Request Headers/Responses HTTP Request Headers – Referer header:  Tells the URL from where the request has originated. – User-Agent header:  Additional information about the browser being used to generate the request. – Host header:  Uniquely identifies a host name; it is necessary when multiple web pages are hosted on the same server. – Cookie header:  Submits additional parameters to the client. HTTP Responses Like in HTTP requests, HTTP responses also consist of three items: Example: HTTP/1.1 200 OK 1. The first part is the HTTP version being used. 2. The second part is the numeric code of the result for the request. 3. The third part is a textual description of the second part. There are some other interesting things in an HTTP response: – Server header : Information about which web server software is being used. – Set-Cookie header:  Issues the cookie to the browser. – Message body : It is common for an HTTP response to hold a message body. – Content-Length header:  Tells the size of the message body in bytes. HTTP Methods The most common methods are GET and POST. But there are a few others, too. – GET:  You use this method to request data from a specified resource where data has not modified it in any way. GET requests do not change the state of resource. – POST: You use this method to send data to a server to create a resource. – PUT: You use this method to update the existing resource on a server by using the content in the body of the request. Think of this as a way to “edit” something. CU IDOL SELF LEARNING MATERIAL (SLM)

HTTP Communications 87 – HEAD:  You use this method the same way you use GET, but with the distinction that the return of a HEAD method should not contain body in the response. But the return will contain same headers as if GET was used. You use the HEAD method to check whether the resource is present prior of making a GET request. – TRACE: You use this method for diagnostic purposes. The response will contain in its body the exact content of the request message. – OPTIONS: You use this method to describe the communication options (HTTP methods) that are available for the target resource. – PATCH:  You use this method to apply partial modifications to a resource. – DELETE: You use this method to delete the specified resource.  Components of Request Headers/Responses There are three main components that make up the request/response structure. These include: – First line – Headers – Body/Content The HTTP headers are added after the first line and are defined as name:value pairs separated by a colon. HTTP headers are used to send additional parameters along with the request or response. There are different types of headers that are grouped based on their usage into four broad categories: 1. General header:  Headers that can be used in both requests and response messages, and that are independent of the data being exchanged. 2. Request header:  These headers define parameters for the data requested or parameters that give important information about the client making the request. 3. Response header:  These headers contain information about the incoming response. 4. Entity header:  The entity headers describe the content that makes up the body of the message. CU IDOL SELF LEARNING MATERIAL (SLM)

88 Advanced Computer Networks 5.4 Status Code Browsing the web, you may have encountered “404 error: not found” pages or “500 error: server is not responding” pages. These are HTTP status codes. Every HTTP response message must contain an HTTP status code in its first line, telling us the result of the request. There are five groups of status codes which are grouped by the first digit: 1. 1xx — Informational. 2. 2xx — The request was successful. 3. 3xx — The client is redirected to a different resource. 4. 4xx — The request contains an error of some kind. 5. 5xx — The server encountered an error fulfilling the request. 5.5 Error Status Code E-mail – Sending and Receiving E-mails HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes: 1. Informational responses (100–199), 2. Successful responses (200–299), 3. Redirects (300–399), 4. Client errors (400–499), and 5. Server errors (500–599). Information Responses 100 Continue This interim response indicates that everything so far is OK and that the client should continue the request, or ignore the response if the request is already finished. 101 Switching Protocol This code is sent in response to an Upgrade request header from the client, and indicates the protocol the server is switching to. CU IDOL SELF LEARNING MATERIAL (SLM)

HTTP Communications 89 102 Processing (WebDAV) This code indicates that the server has received and is processing the request, but no response is available yet. 103 Early Hints This status code is primarily intended to be used with the Link header, letting the user agent start preloading resources while the server prepares a response. Successful Responses 200 OK The request has succeeded. The meaning of the success depends on the HTTP method: 1. GET: The resource has been fetched and is transmitted in the message body. 2. HEAD: The entity headers are in the message body. 3. PUT or POST: The resource describing the result of the action is transmitted in the message body. 4. TRACE: The message body contains the request message as received by the server. 201 Created The request has succeeded and a new resource has been created as a result. This is typically the response sent after POST requests, or some PUT requests. 202 Accepted The request has been received but not yet acted upon. It is non-committal, since there is no way in HTTP to later send an asynchronous response indicating the outcome of the request. It is intended for cases where another process or server handles the request, or for batch processing. 203 Non-authoritative Information This response code means the returned meta-information is not exactly the same as is available from the origin server, but is collected from a local or a third-party copy. This is mostly used for mirrors or backups of another resource. Except for that specific case, the “200 OK” response is preferred to this status. 204 No Content There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones. CU IDOL SELF LEARNING MATERIAL (SLM)

90 Advanced Computer Networks 205 Reset Content Tells the user-agent to reset the document which sent this request. 206 Partial Content This response code is used when the Range header is sent from the client to request only part of a resource. 207 Multi-status (WebDAV) Conveys information about multiple resources, for situations where multiple status codes might be appropriate. 208 Already Reported (WebDAV) Used inside a <dav:propstat> response element to avoid repeatedly enumerating the internal members of multiple bindings to the same collection. 226 IM Used (HTTP Delta Encoding) The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance 0 manipulations applied to the current instance. Redirection Messages 300 Multiple Choice The request has more than one possible response. The user-agent or user should choose one of them. (There is no standardized way of choosing one of the responses, but HTML links to the possibilities are recommended. So, the user can pick.) 301 Moved Permanently The URL of the requested resource has been changed permanently. The new URL is given in the response. 302 Found This response code means that the URI of requested resource has been changed temporarily. Further changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests. 303 See Other The server sent this response to direct the client to get the requested resource at another URI with a GET request. CU IDOL SELF LEARNING MATERIAL (SLM)

HTTP Communications 91 304 Not Modified This is used for caching purposes. It tells the client that the response has not been modified. So, the client can continue to use the same cached version of the response. 305 Use Proxy Defined in a previous version of the HTTP specification to indicate that a requested response must be accessed by a proxy. It has been depreciated due to security concerns regarding in-band configuration of a proxy. 306 Unused This response code is no longer used; it is just reserved. It was used in a previous version of the HTTP/1.1 specification. 307 Temporary Redirect The server sends this response to direct the client to get the requested resource at another URI with same method that was used in the prior request. This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent must not change the HTTP method used: If a POST was used in the first request, a POST must be used in the second request. 308 Permanent Redirect This means that the resource is now permanently located at another URI, specified by the Location: HTTP Response header. This has the same semantics as the 301 Moved Permanently HTTP response code, with the exception that the user agent must not change the HTTP method used: If a POST was used in the first request, a POST must be used in the second request. Client Error Responses 400 Bad Request The server could not understand the request due to invalid syntax. 401 Unauthorized Although the HTTP standard specifies “unauthorized”, semantically this response means “unauthenticated”, i.e., the client must authenticate itself to get the requested response. 402 Payment Required This response code is reserved for future use. The initial aim for creating this code was using it for digital payment systems. However, this status code is used very rarely and no standard convention exists. CU IDOL SELF LEARNING MATERIAL (SLM)

92 Advanced Computer Networks 403 Forbidden The client does not have access rights to the content, i.e., it is unauthorized. So, the server is refusing to give the requested resource. Unlike 401, the client’s identity is known to the server. 404 Not Found The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 to hide the existence of a resource from an unauthorized client. This response code is probably the most famous one due to its frequent occurrence on the web. 405 Method Not Allowed The request method is known by the server but has been disabled and cannot be used. For example, an API may forbid DELETE-ing a resource. The two mandatory methods, GET and HEAD, must never be disabled and should not return this error code. 406 Not Acceptable This response is sent when the web server, after performing server-driven content negotiation, does not find any content that conforms to the criteria given by the user agent. 407 Proxy Authentication Required This is similar to 401 but authentication is needed to be done by a proxy. 408 Request Timeout This response is sent on an idle connection by some servers, even without any previous request by the client. It means that the server would like to shut down this unused connection. This response is used much more since some browsers, like Chrome, Firefox 27+, or IE9, use HTTP pre-connection mechanisms to speed up surfing. Also note that some servers merely shut down the connection without sending this message. 409 Conflict This response is sent when a request conflicts with the current state of the server. 410 Gone This response is sent when the requested content has been permanently deleted from server, with no forwarding address. Clients are expected to remove their caches and links to the resource. The HTTP specification intends this status code to be used for “limited-time, promotional CU IDOL SELF LEARNING MATERIAL (SLM)

HTTP Communications 93 services”. APIs should not feel compelled to indicate resources that have been deleted with this status code. 411 Length Required Server rejected the request because the Content-Length header field is not defined and the server requires it. 412 Precondition Failed The client has indicated preconditions in its headers which the server does not meet. 413 Payload Too Large Request entity is larger than limits defined by server; the server might close the connection or return an Retry-After header field. 414 URI Too Long The URI requested by the client is longer than the server is willing to interpret. 415 Unsupported Media Type The media format of the requested data is not supported by the server. So, the server is rejecting the request. 416 Range Not Satisfiable The range specified by the Range header field in the request cannot be fulfilled. It is possible that the range is outside the size of the target URI’s data. 417 Expectation Failed This response code means the expectation indicated by the Expect request header field cannot be met by the server. 418 I’m a teapot The server refuses the attempt to brew coffee with a teapot. 421 Misdirected Request The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI. 422 Unprocessable Entity (WebDAV) The request was well-formed but was unable to be followed due to semantic errors. CU IDOL SELF LEARNING MATERIAL (SLM)

94 Advanced Computer Networks 423 Locked (WebDAV) The resource that is being accessed is locked. 424 Failed Dependency (WebDAV) The request failed due to failure of a previous request. 425 Too Early Indicates that the server is unwilling to risk processing a request that might be replayed. 426 Upgrade Required The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol. The server sends an Upgrade header in a 426 response to indicate the required protocol(s). 428 Precondition Required The origin server requires the request to be conditional. This response is intended to prevent the ‘lost update’ problem, where a client GETs a resource’s state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict. 429 Too Many Requests The user has sent too many requests in a given amount of time (“rate limiting”). 431 Request Header Fields Too Large The server is unwilling to process the request because its header fields are too large. The request may be resubmitted after reducing the size of the request header fields. 451 Unavailable for Legal Reasons The user-agent requested a resource that cannot legally be provided, such as a web page censored by a government. Server Error Responses 500 Internal Server Error The server has encountered a situation it does not know how to handle. 501 Not Implemented The request method is not supported by the server and cannot be handled. The only methods that servers are required to support (and therefore that must not return this code) are GET and HEAD. CU IDOL SELF LEARNING MATERIAL (SLM)


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook