DNS (M1.6)

 The Domain Name System (DNS) is the phonebook of the Internet. Humans access information online through domain names, like nytimes.com or espn.com. Web browsers interact through Internet Protocol (IP) addresses. DNS translates domain names to IP addresses so browsers can load Internet resources.

  • DNS is short for Domain Name Service or Domain Name System.
  • It is an application layer protocol.
  • DNS is a host name to IP Address translation service.
  • It converts the names we type in our web browser address bar to the IP Address of web servers hosting those sites.

WHY DNS?

  • IP Addresses are not static and may change dynamically.So, a mapping is required which maps the domain names to the IP Addresses of their web servers.
  • IP Addresses are a complex series of numbers. So, it is difficult to remember IP Addresses directly while it is easy to remember names.

The DNS is (1) a distributed database implemented in a hierarchy of DNS servers, and (2) an application-layer protocol that allows hosts to query the distributed database. 

DNS provides a few other important services in addition to translating host- names to IP addresses:
• Host aliasing. A host with a complicated hostname can have one or more alias names.

• Mail server aliasing. For obvious reasons, it is highly desirable that e-mail addresses be mnemonic.

• Load distribution. DNS is also used to perform load distribution among replicated servers, such as replicated Web servers.

Working

A simple design for DNS would have one DNS server that contains all the mappings. In this centralized design, clients simply direct all queries to the single DNS server, and the DNS server responds directly to the querying clients. Although the simplicity of this design is attractive, it is inappropriate for today’s Internet, with its vast (and growing) number of hosts. The problems with a centralized design include:
A single point of failure. If the DNS server crashes, so does the entire Internet.
Traffic volume. A single DNS server would have to handle all DNS queries (for all the HTTP requests and e-mail messages generated from hundreds of millions of hosts).

Distant centralized database. A single DNS server cannot be “close to” all the querying clients. If we put the single DNS server in New York City, then all queries from Australia must travel to the other side of the globe, perhaps over slow and congested links. This can lead to significant delays.
Maintenance. The single DNS server would have to keep records for all Internet hosts. Not only would this centralized database be huge, but it would have to be updated frequently to account for every new host. 

A Distributed, Hierarchical Database
In order to deal with the issue of scale, the DNS uses a large number of servers, organized in a hierarchical fashion and distributed around the world. No single DNS server has all of the mappings for all of the hosts in the Internet. Instead, the mappings are distributed across the DNS servers. To a first approximation, there are three classes of DNS servers—

root DNS servers-In the Internet there are 13 root DNS servers (labeled A through M), most of which are located in North America.

top-level domain (TLD) DNS servers- These servers are responsible for top-level  domains such as com, org, net, edu, and gov, and all of the country top-level domains such as uk, fr, ca, and jp.

authoritative DNS servers-Every organization with publicly accessible hosts  (such as Web servers and mail servers) on the Internet must provide publicly accessible DNS records that map the names of those hosts to IP addresses.

DNS Resolution is a process of resolving a domain name onto an IP Address.

DNS Lookup

  1. A user types ‘example.com’ into a web browser and the query travels into the Internet and is received by a DNS recursive resolver.
  2. The resolver then queries a DNS root nameserver (.).
  3. The root server then responds to the resolver with the address of a Top Level Domain (TLD) DNS server (such as .com or .net), which stores the information for its domains. When searching for example.com, our request is pointed toward the .com TLD.
  4. The resolver then makes a request to the .com TLD.
  5. The TLD server then responds with the IP address of the domain’s nameserver, example.com.
  6. Lastly, the recursive resolver sends a query to the domain’s nameserver.
  7. The IP address for example.com is then returned to the resolver from the nameserver.
  8. The DNS resolver then responds to the web browser with the IP address of the domain requested initially.
  9. Once the 8 steps of the DNS lookup have returned the IP address for example.com, the browser is able to make the request for the web page:

  10. The browser makes a HTTP request to the IP address.
  11. The server at that IP returns the webpage to be rendered in the browser (step 10).

DNS queries:

  1. Recursive query - In a recursive query, a DNS client requires that a DNS server (typically a DNS recursive resolver) will respond to the client with either the requested resource record or an error message if the resolver can't find the record.
  2. Iterative query - in this situation the DNS client will allow a DNS server to return the best answer it can. If the queried DNS server does not have a match for the query name, it will return a referral to a DNS server authoritative for a lower level of the domain namespace. The DNS client will then make a query to the referral address. This process continues with additional DNS servers down the query chain until either an error or timeout occurs.

DNS caching

  • The purpose of caching is to temporarily stored data in a location that results in improvements in performance and reliability for data requests. 
  • DNS caching involves storing data closer to the requesting client so that the DNS query can be resolved earlier and additional queries further down the DNS lookup chain can be avoided, thereby improving load times and reducing bandwidth/CPU consumption. 
  • DNS data can be cached in a variety of locations, each of which will store DNS records for a set amount of time determined by a time-to-live (TTL).

 OpenDNS

Suppose DNS server of your ISP is slow, the time it takes to resolve the web address adds up to the overall loading time of the website.

To solve this problem, we look at a simple and reliable service called OpenDNS that speeds up your Internet connection and also handles some other very important issues.

OpenDNS is an American company providing Domain Name System (DNS) resolution services—with features such as phishing protection, optional content filtering, and DNS lookup in its DNS servers.

Setup

  • There are no software to install, it’s very easy to set up and the price is just right - $0.
  • To use OpenDNS, all you have to do is open your Network Connections or Router’s settings page and update the default DNS server to point to the OpenDNS nameservers that are 208.67.222.222 and 208.67.220.220.
  • The whole process takes a few seconds but with this single step alone, you just made your computer safer and increased the overall browsing speed. 
Here’s why:
  • Unlike the DNS servers of your less reliable ISP, OpenDNS servers store the IP addresses of millions of websites in their cache so it would take less time to resolve your requests. So if you have asked for an IP address of a website that has been previously requested by another OpenDNS user, you will get the reply instantly.
  • Another huge advantage of using OpenDNS is that it blocks phishing websites from loading on your computer. It uses data from Phishtank, a community site that is also used by Yahoo! Mail to determine if some particular website is part of any online phishing scam.
  • OpenDNS also takes care of any typos that you commit while typing the name of popular websites. For instance, if you type www.gogle.com omitting the additional “o” by mistake, OpenDNS will open the main www.google.com site automatically.
  • If you are a parent worried about kids visiting adult websites on the home computer, you can configure OpenDNS to block any adult website from loading on the computer. In fact, quite a few business places use OpenDNS to block social sites like MySpace and Facebook on employee computers.
  • Power users can assign abbreviations or OpenDNS Shortcuts to access their favourite websites more quickly.

FTP, SMTP, POP3, IMAP, and MIME (M1.6)

FTP
  • File transfer protocol (FTP) is a set of rules that computers follow for the transferring of files from one system to another over the internet. 
  • It may be used by a business to transfer files from one computer system to another, or websites may use FTP to upload or download files from a website's server. 
  • FTP uses two parallel TCP connections to transfer a file, a control connection and a data connection
  • The control connection is used for sending control information between the two hosts—information such as user identification, password, commands to change remote directory, and commands to “put” and “get” files. 
  • The data connection is used to actually send a file. 
  • Because FTP uses a separate control connection, FTP is said to send its control information out-of-band.
  • Throughout a session, the FTP server must maintain state about the user.  

Advantages of using FTP

  1. It allows you to transfer multiple files and folders.
  2. When the connection is lost then it has the ability to resume the transfer.
  3. There is no limitation on the size of the file to be transferred. The browsers allow a transfer of only up to 2 GB.
  4. Many FTP clients like FileZilla have the ability to schedule the transfers.
  5. The data transfer is faster than HTTP.
  6. The items that are to be uploaded or downloaded are added to the ‘queue’. The FTP client can add items to the ‘queue’.

Disadvantages of using FTP

  1. FTP doesn't encrypt the traffic so usernames, passwords, and other data can easily be read by capturing the data packets because while transferring as they are sent in cleartext. FTP is vulnerable to packet capture and other attacks.

SMTP (Simple Mail Transfer Protocol)

  • SMTP is the heart of Internet electronic mail. 
  • SMTP transfers messages from senders’ mail servers to the recipients’ mail servers. 
  • SMTP is much older than HTTP 
  • It is used for sending the emails efficiently and reliably over the internet.

  

 

SMTP is a pure text based protocol.

  • SMTP can only handle the messages containing 7 bit ASCII text.
  • SMTP can not transfer other types of data like images, video, audio etc.
  • SMTP can not transfer executable files and binary objects.
  • SMTP can not transfer the text data of other languages like French, Japanese, Chinese etc.
(since they are represented in 8 bit codes)

MIME extends the limited capabilities of email.

As the name suggests,

  • Multipurpose Internet Email Extension (MIME) is an extension to the internet email protocol.
  • It extends the limited capabilities of email by enabling the users to send and receive graphics, audio files, video files etc in the message.
  • MIME was specially designed for SMTP.

 SMTP is a stateless protocol.

This is because-

  • It does not maintain the state of its clients.
  • If an email is asked to be sent twice, then SMTP server resends it without saying that the email has already been sent.

 We can not use SMTP at the receiver’s side.

This is because-

  • SMTP is a push protocol.
  • At receiver’s side, a pull protocol like POP3, IMAP is needed.
  • Receiver periodically checks if he has any mail from his mail server

NOTE-

 To receive or download the email,

  • Another protocol is needed between the receiver’s mail server and the receiver.
  • The most commonly used protocols are POP3 and IMAP.
 

POP3 (Post Office Protocol) 

  • POP3 is an extremely simple mail access protocol.which is short and quite readable. Because the protocol is so simple, its functionality is rather limited. 
  • POP3 begins when the user agent (the client) opens a TCP connection to the mail server (the server) on port 110. 
  • With the TCP connection established, POP3 progresses through three phases: authorization, transaction, and update.
     
  • During the first phase, authorization, the user agent sends a username and a password
    (in the clear) to authenticate the user. 
  • During the second phase, transaction, the user agent retrieves messages; also during this phase, the user agent can mark messages for deletion, remove deletion marks, and obtain mail statistics. 
  • The third phase, update, occurs after the client has issued the quit command, ending the POP3 session; at this time, the mail server deletes the messages that were marked for
    deletion.
     
  • In a POP3 transaction, the user agent issues commands, and the server responds
    to each command with a reply. 
  • There are two possible responses: +OK (sometimes followed by server-to-client data), used by the server to indicate that the previous command was fine; and -ERR, used by the server to indicate that something was wrong with the previous command.
     
  • The authorization phase has two principal commands: user <username> and
    pass <password>.
  • Suppose that mailServer is the name of your mail server. You will see something like:  telnet mailServer 110
    +OK POP3 server ready
    user bob
    +OK
    pass hungry
    +OK user successfully logged on

    If you misspell a command, the POP3 server will reply with an -ERR message. 
  •  A user agent using POP3 can often be configured (by the user) to “download and delete” or to “download and keep.” 
  • The sequence of commands issued by a POP3 user agent depends on which of these two modes the user agent is operating in. 
  • In the download-and-delete mode, the user agent will issue the list, retr, and dele commands. The user agent then retrieves and deletes each message from the server.
  • In the download-and- keep mode, the user agent leaves the messages on the mail server after downloading them.  
  • During a POP3 session between a user agent and the mail server, the POP3
    server maintains some state information; in particular, it keeps track of which user
    messages have been marked deleted. However, the POP3 server does not carry state
    information across POP3 sessions. This lack of state information across sessions
    greatly simplifies the implementation of a POP3 server.

 IMAP

  • IMAP is a mail access protocol. It has many more features than POP3, but it is also significantly more complex. 
  • Note that, unlike POP3, an IMAP server maintains user state information
    across IMAP sessions 
  • Another important feature of IMAP is that it has commands that permit a user
    agent to obtain components of messages. 
For example, a user agent can obtain just the message header of a message or just one part of a multipart MIME message. This feature is useful when there is a low-bandwidth connection (for example, a slow-speed modem link) between the user agent and its mail server. With a low- bandwidth connection, the user may not want to download all of the messages in its mailbox, particularly avoiding long messages that might contain, for example, an audio or video clip. 
 
MIME
  • MIME stands for Multipurpose Internet Mail Extensions. 
  • It is used to extend the capabilities of Internet e-mail protocols such as SMTP. 
  • The MIME protocol allows the users to exchange various types of digital content such as pictures, audio, video, and various types of documents and files in the e-mail.  
  • MIME is an e-mail extension protocol, i.e., it does not operate independently, but it helps to extend the capabilities of e-mail in collaboration with other protocols such as SMTP.

Need of MIME Protocol

MIME protocol is used to transfer e-mail in the computer network for the following reasons:

  1. The MIME protocol supports multiple languages in e-mail, such as Hindi, French, Japanese, Chinese, etc.
  2. Simple protocols can reject mail that exceeds a certain size, but there is no word limit in MIME.
  3. Images, audio, and video cannot be sent using simple e-mail protocols such as SMTP. These require MIME protocol.
  4. Many times, emails are designed using code such as HTML and CSS, they are mainly used by companies for marketing their product. This type of code uses MIME to send email created from HTML and CSS.

Working of MIME –
Suppose a user wants to send an email through user agent and it is in a non-ASCII format so there is a MIME protocol which converts it into 7-bit NVT ASCII format. Message is transferred through e-mail system to the other side in 7-bit format now MIME protocol again converts it back into non-ASCII code and now the user agent of receiver side reads it and then information is finally read by the receiver. MIME header is basically inserted at the beginning of any e-mail transfer.

MIME Protocol

MIME Header:
It is added to the original e-mail header section to define transformation. There are five headers which we add to the original header:

  1. MIME Version – Defines version of MIME protocol. It must have the parameter Value 1.0, which indicates that message is formatted using MIME.
  2. Content Type – Type of data used in the body of message. They are of different types like text data (plain, HTML), audio content or video content.
  3. Content Type Encoding – It defines the method used for encoding the message. Like 7-bit encoding, 8-bit encoding, etc.
  4. Content Id – It is used for uniquely identifying the message.
  5. Content description – It defines whether the body is actually image, video or audio.

 

 

The Web & HTTP (M1.5)

 The Web was the first Internet application 

The HyperText Transfer Protocol (HTTP) 

  • The Web’s application-layer protocol,is at the heart of the Web. 
  • HTTP is implemented in two programs: a client program and a server program. 
  • The client program and server program, executing on different end systems, talk to each other by exchanging HTTP messages. 
  • HTTP defines the structure of these messages and how the client and server exchange the messages.
  • HTTP defines how Web clients request Web pages from Web servers and how servers transfer Web pages to clients.    
HTTP Protocol | InnovationM Blog
  • When a user requests a Web page (for example, clicks on a hyperlink), the browser sends HTTP request messages to the server. 
  • The server receives the requests and responds with HTTP response messages that contain the objects.  
  • HTTP uses TCP as its underlying transport protocol (rather than running on top of UDP). 
  • The HTTP client first initiates a TCP connection with the server. Once the connection is established, the browser and the server processes access TCP through their socket interfaces.   
It is important to note that the server sends requested files to clients without storing any state information about the client. If a particular client asks for the same object twice in a period of a few seconds, the server does not respond by saying that it just served the object to the client; instead, the server resends the object, as it has completely forgotten what it did earlier. Because an HTTP server maintains no information about the clients, HTTP is said to be a stateless protocol. 
 
Round-trip time(RTT), which is the time it takes for a small packet to travel from client to server and then back to the client. The RTT includes packet-propagation delays, packet-queuing delays in intermediate routers and switches, and packet-processing delays.  

HTTP can use both nonpersistent connections and persistent connections. 

A nonpersistent connection is the one that is closed after the server sends the requested object to the client. In other words, the connection is used exactly for one request and one response.

Non-persistent connections have some shortcomings. First, a brand-new connection must be established and maintained for each requested object. For each of these connections, TCP buffers must be allocated and TCP variables must be kept in both the client and server. This can place a significant burden on the Web server,which may be serving requests from hundreds of different clients simultaneously. Second, as we just described, each object suffers a delivery delay of two RTTs , one RTT to establish the TCP connection and one RTT to request and receive an object.
 
With persistent connections, the server leaves the TCP connection open after
sending a response. Subsequent requests and responses between the same client and
server can be sent over the same connection.
 
 
Cookies, allow sites to keep track of users. Most major commercial Web sites use cookies today. 

Application layer Protocols (M1.4)

 Needs/Principles of Application layer Protocols

#2.1.1 Network Application Architectures

The application architecture is designed by the application developer and dictates how the application is structured over the various end systems. In choosing the application architecture, an application developer will likely draw on one of the two predominant architectural paradigms used in modern network applications: the client-server architecture or the peer-to-peer (P2P) architecture 


In a client-server architecture

  • there is a host, called the server,which services requests from many other hosts, called clients
  • A classic example is the Web application for which an Web server services the requests from browsers running on client hosts. When a Web server receives a request for an object from a client host, it responds by sending the requested object to the client host. 
  • Note that with the client-server architecture, clients do not directly communicate with each other.
  • Another characteristic of the client-server architecture is that the server has a fixed, well-known address, called an IP address.  
  • Some of the better-known applications with a client-server architecture include the Web, FTP, Telnet, and e-mail.  
  • Often in a client-server application, a single-server host is incapable of keeping up with all the requests from clients. 

For example, a popular social-networking site can quickly become overwhelmed if it has only one server handling all of its requests. For this reason, a data center, housing a large number of hosts, is often used to create a powerful virtual server. 

The most popular Internet services—such as search engines (e.g., Google and Bing), Internet commerce (e.g., Amazon and e-Bay), Web-based email (e.g., Gmail and Yahoo Mail), social networking (e.g., Facebook and Twitter)— employ one or more data centers.  

Google has 30 to 50 data centers distributed around the world, which collectively handle search, YouTube, Gmail, and other services.

Client-server and P2P network models | Download Scientific Diagram

Peer to peer architecture is a 

  • type of computer networking architecture in which there is no division or distinction of abilities amidst the various workstations or nodes of a network. 
  • Every section has the exact same responsibilities and can perform the same set of actions. 
  • In P2P each computer can act as both the server and the client as the need demands. 
  • Although P2P has a wide array of applications, its most important one is the ability to distribute content efficiently. 
  • Things that facilitate on-demand delivery of content such as software publication and distribution, streaming and peer casting for multicasting streams, and content delivery networks, all come under this. 
  • Many of today’s most popular and traffic-intensive applications are based on P2P
    architectures. 

These applications include file sharing (e.g., BitTorrent), peer-assisted. download acceleration (e.g., Xunlei), Internet Telephony (e.g., Skype), and IPTV (e.g.,
Kankan and PPstream). 

 We mention that some applications have hybrid architectures, combining both client-server
and P2P elements. For example, for many instant messaging applications, servers are used to track the IP addresses of users, but user-to-user messages are sent directly between user hosts (without passing through intermediate servers).


One of the most compelling features of P2P architectures is their self-scalability.

Challenges 

ISP Friendly. Most residential ISPs (including DSL and cable ISPs) have been dimensioned for “asymmetrical” bandwidth usage, that is, for much mor downstream than upstream traffic. But P2P video streaming and file distribution applications shift upstream traffic from servers to residential ISPs, thereby putting significant stress on the ISPs. Future P2P applications need to be designed so that they are friendly to ISPs.

Security. Because of their highly distributed and open nature, P2P applications can be a challenge to secure.

Incentives. The success of future P2P applications also depends on convincing
users to volunteer bandwidth, storage, and computation resources to the applications, which is the challenge of incentive design.


Difference Between Peer to Peer and Client Server Network - Pediaa.Com

Processes Communicating

Process can be thought of as a program that is running within an  end system. When processes are running on the same end system, they can communicate with each other with interprocess communication, using rules that are governed by the end system’s operating system.  

Processes on two different end systems communicate with each other by exchanging messages across the computer network. A sending process creates and sends messages into the network; a receiving process receives these messages and possibly responds by sending messages back. 

#Client and Server Processes

  • A network application consists of pairs of processes that send messages to each other over a network.  
  • In a P2P file-sharing system, a file is transferred from a process in one peer to a process in another peer, For each pair of communicating processes, we typically label one of the two processes as the client and the other process as the server. 
  • With P2P file sharing, the peer that is downloading the file is labeled as the client, and the peer
    that is uploading the file is labeled as the server.
     
  • You may have observed that in some applications, such as in P2P file sharing, a process can be both a client and a server. Indeed, a process in a P2P file-sharing system can both upload and download files.  

In the context of a communication session between a pair of processes, the process that initiates the communication (that is, initially contacts the other
process at the beginning of the session) is labeled as the client. The process that waits to be contacted to begin the session is the server.
 
 

#The Interface Between the Process and the Computer Network 

A process sends messages into, and receives messages from, the network through a software interface called a socket. A socket is the interface between the application layer and the transport layer within a host. It is also referred to as the Application Programming Interface (API) between the application and the network, since the socket is the programming interface with which network applications are built.  

#Addressing Processes 

In order for a process running on one host to send packets to a process running on another host, the receiving process needs to have an address. To identify the receiving process, two pieces of information need to be specified:
(1) the address of the host
(2) an identifier that specifies the receiving process in the destination host.
In the Internet, the host is identified by its IP address.
IP address is a 32-bit quantity that we can think of as uniquely identifying the host.
In addition to knowing the address of the host to which a message is destined, the
sending process must also identify the receiving process (more specifically, the
receiving socket) running in the host.  A destination port number serves this purpose. Popular applications have been assigned specific port numbers. For example, a Web server is identified by port number 80. A mail server process (using the SMTP protocol) is identified by port number 25.
 

Transport Services Available to Applications

#Reliable Data Transfer- A protocol that provides a guaranteed data delivery service, it is said to provide reliable data transfer. 

#Throughput

#Timing

#Security 

Transport Services Provided by the Internet    

#TCP Services

 Connection-oriented service

Reliable data transfer service

#UDP Services

Application-Layer Protocols

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, that is, the meaning of the information in the fields
Rules for determining when and how a process sends messages and responds to messages.
 

Monk and Inversions

using System; public class Solution { public static void Main () { int T = Convert . ToInt32 ( Console . ReadLine...