Advanced Computer Networks - Unit 3
Advanced Computer Networks - Unit 3
The Web and HTTP, File Transfer: FTP, Electronic Mail in the Internet, Domain
Name System (DNS), P2P File Sharing, Socket Programming with TCP and
UDP, building a Simple Web Server Crea�ng simulated networks and passing
packets through them using different rou�ng techniques. Installing and using
network monitoring tools.
………………………………………………………………………………………………………………………
1) Overview of HTTP :
• Let’s walk through the steps of transferring a Web page from server to
client for the case of non-persistent connec�ons. Let’s suppose the page
consists of a base HTMLfile and 10 JPEG images, and that all 11 of these
objects reside on the same server. Further suppose the URLfor the base
HTMLfile is
http://www.someSchool.edu/someDepartment/home.index
• Here is what happens:
1. The HTTPclient process ini�ates a TCPconnec�on to the server
www.someSchool.edu on port number 80, which is the default port
number for HTTP. Associated with the TCPconnec�on, there will be a
socket at the client and a socket at the server.
2. The HTTPclient sends an HTTPrequest message to the server via its
socket. The request message includes the path name
/someDepartment/home.index.
3. The HTTPserver process receives the request message via its socket,
retrieves the object /someDepartment/home.index from its storage
(RAM or disk), encapsulates the object in an HTTPresponse message, and
sends the response message to the client via its socket.
4. The HTTPserver process tells TCPto close the TCPconnec�on.
5. The HTTPclient receives the response message. The TCPconnec�on
terminates. The message indicates that the encapsulated object is an
HTMLfile. The client extracts the file from the response message,
examines the HTMLfile, and finds references to the 10 JPEG objects. 6.
The first four steps are then repeated for each of the referenced JPEG
objects.
As the browser receives the Web page, it displays the page to the user.
Two different browsers may interpret (that is, display to the user) a Web
page in somewhat different ways. HTTPhas nothing to do with how a
Web page is interpreted by a client.
We need a calcula�on to es�mate the amount of �me that elapses from
when a client requests the base HTML file un�l the en�re file is received
by the client. To this end, we define the round-trip �me (RTT), which is
the �me it takes for a small packet to travel from client to server and
then back to the client. As shown in Figure 2.7, this causes the browser
to ini�ate a TCP connec�on between the browser and the Web server;
this involves a ―three-way handshake‖—the client sends a small TCP
segment to the server, the server acknowledges and responds with a
small TCP segment, and, finally, the client acknowledges back to the
server. The first two parts of the threeway handshake take one RTT.
With persistent connec�ons, the server leaves the TCP connec�on open
a�er sending a response. Subsequent requests and responses between
the same client and server can be sent over the same connec�on. In
par�cular, an en�re Web page (in the example above, the base HTMLfile
and the 10 images) can be sent over a single persistent TCP connec�on.
Moreover, mul�ple Web pages residing on the same server can be sent
from the server to the same client over a single persistent TCP
connec�on. These requests for objects can be made back-to-back,
without wai�ng for replies to pending requests (pipelining). Typically, the
HTTPserver closes a connec�on when it isn’t used for a certain �me (a
configurable �meout interval).
When the server receives the back-to-back requests, it sends the objects
back-to-back. The default mode of HTTP uses persistent connec�ons
with pipelining.
The HTTP include the defini�ons of the HTTP message formats. There are
two types of HTTP messages, request messages and response messages,
both of which are discussed below.
• 400 Bad Request: This is a generic error code indica�ng that the
request could not be understood by the server.
• 404 Not Found: The requested document does not exist on this server.
• 505 HTTP Version Not Supported: The requested HTTP protocol version
is not supported by the server.
It is o�en desirable for a Web site to iden�fy users, either because the
server wishes to restrict user access or because it wants to serve content
as a func�on of the user iden�ty. For these purposes, HTTP uses cookies.
.
As shown in Figure, cookie technology has four components: (1) a cookie
header line in the HTTP response message; (2) a cookie header line in
the HTTP request message; (3) a cookie file kept on the user’s end
system and managed by the user’s browser; and (4) a back-end database
at the Web site.
5) Web Caching :
In a typical FTP session, the user is si�ng in front of one host (the local
host) and wants to transfer files to or from a remote host. In order for
the user to access the remote account, the user must provide a user
iden�fica�on and a password. A�er providing this authoriza�on
informa�on, the user can transfer files from the local file system to the
remote file system and vice versa. As shown in Figure , the user interacts
with FTPthrough an FTPuser agent. The user first provides the hostname
of the remote host, causing the FTP client process in the local host to
establish a TCP connec�on with the FTP server process in the remote
host. The user then provides the user iden�fica�on and password, which
are sent over the TCP connec�on as part of FTP commands.
Once the server has authorized the user, the user copies one or more
files stored in the local file system into the remote file system (or vice
versa).
HTTP and FTP are both file transfer protocols and have many common
characteris�cs; for example, they both run on top of TCP. However, the
two applica�on-layer protocols have some important differences. The
most striking difference is that FTP uses two parallel TCPconnec�ons to
transfer a file, a control connec�on and a data connec�on. The control
connec�on is used for sending control informa�on between the two
hosts—informa�on such as user iden�fica�on, password, commands to
change remote directory, and commands to ―put‖ and ―get‖ files.
When a user starts an FTP session with a remote host, the client side of
FTP (user) first ini�ates a control TCP connec�on with the server side
(remote host) on server port number 21. The client side of FTP sends the
user iden�fica�on and password over this control connec�on. The client
side of FTP also sends, over the control connec�on, commands to
change the remote directory. When the server side receives a command
for a file transfer over the control connec�on (either to, or from, the
remote host), the server side ini�ates a TCP data connec�on to the client
side. FTPsends exactly one file over the data connec�on and then closes
the data connec�on. If, during the same session, the user wants to
transfer another file, FTP opens another data connec�on.
We end this sec�on with a brief discussion of some of the more common
FTP commands and replies. The commands, from client to server, and
replies, from server to client, are sent across the control connec�on in 7-
bit ASCII format. Thus, like HTTP commands, FTP commands are readable
by people. In order to delineate successive commands, a carriage return
and line feed end each command. Each command consists of four
uppercase ASCII characters, some with op�onal arguments. Some of the
more common commands are given below:
• USER username: Used to send the user iden�fica�on to the server.
• PASS password: Used to send the user password to the server.
• LIST: Used to ask the server to send back a list of all the files in the
current remote directory. The list of files is sent over a (new and non-
persistent) data connec�on rather than the control TCPconnec�on.
• RETR filename: Used to retrieve (that is, get) a file from the current
directory of the remote host. This command causes the remote host to
ini�ate a data connec�on and to send the requested file over the data
connec�on.
• STOR filename: Used to store (that is, put) a file into the current
directory of the remote host.
Each command is followed by a reply, sent from server to client. The
replies are three-digit numbers, with an op�onal message following the
number. This is similar in structure to the status code and phrase in the
status line of the HTTP response message. Some typical replies, along
with their possible messages, are as follows:
• 331 Username OK, password required
• 125 Data connec�on already open; transfer star�ng
• 425 Can’t open data connec�on
• 452 Error wri�ng file
Electronic mail has been around since the beginning of the Internet. It
was the most popular applica�on when the Internet was in its infancy
and hasbecome more and more elaborate and powerful over the years.
It remains one of the Internet’s most important and u�lized applica�ons.
As with ordinary postal mail, e-mail is an asynchronous communica�on
medium—people send and read messages when it is convenient for
them, without having to coordinate with other people’s schedules. In
contrast with postal mail, electronic mail is fast, easy to distribute, and
inexpensive. Modern e-mail has many powerful features, including
messages with atachments, hyperlinks, HTML-formated text, and
embedded photos.
Figure presents a high-level view of the Internet mail system, it has three
major components: user agents, mail servers & Simple Mail Transfer
Protocol (SMTP).
We now describe each of these components in the context of a sender,
Alice, sending an e-mail message to a recipient, Bob. User agents allow
users to read, reply to, forward, save, and compose messages. Microso�
Outlook and Apple Mail are examples of user agents for e-mail. When
Alice is finished composing her message, her user agent sends the
message to her mail server, where the message is placed in the mail
server’s outgoing message queue. When Bob wants to read a message,
his user agent retrieves the message from his mailbox in his mail server.
Mail servers form the core of the e-mail infrastructure. Each recipient,
such as Bob, has a mailbox located in one of the mail servers. Bob’s
mailbox manages and maintains the messages that have been sent to
him. Atypical message starts its journey in the sender’s user agent,
travels to the sender’s mail server, and travels to the recipient’s mail
server, where it is deposited in the recipient’s mailbox.
When Bob wants to access the messages in his mailbox, the mail server
containing his mailbox authen�cates Bob (with usernames and
passwords). Alice’s mail server must also deal with failures in Bob’s mail
server. If Alice’s server cannot deliver mail to Bob’s server, Alice’s server
holds the message in a message queue and atempts to transfer the
message later. Reatempts are o�en done every 30 minutes or so; if
there is no success a�er several days, the server removes the message
and no�fies the sender (Alice) with an e-mail message.
SMTP is the principal applica�on-layer protocol for Internet electronic
mail. It uses the reliable data transfer service of TCPto transfer mail from
the sender’s mail server to the recipient’s mail server. As with most
applica�on-layer protocols, SMTPhas two sides: a client side, which
executes on the sender’s mail server, and a server side, which executes
on the recipient’s mail server. Both the client and server sides of SMTP
run on every mail server. When a mail server sends mail to other mail
servers, it acts as an SMTPclient. When a mail server receives mail from
other mail servers, it acts as an SMTPserver.
SMTP :
1. Alice invokes her user agent for e-mail, provides Bob’s e-mail address
(for example, [email protected]), composes a message, and
instructs the user agent to send the message.
2. Alice’s user agent sends the message to her mail server, where it is
placed in a message queue.
3. The client side of SMTP, running on Alice’s mail server, sees the
message in the message queue. It opens a TCPconnec�on to an
SMTPserver, running on Bob’s mail server.
4. A�er some ini�al SMTPhandshaking, the SMTPclient sends Alice’s
message into the TCPconnec�on.
5. At Bob’s mail server, the server side of SMTPreceives the message.
Bob’s mail server then places the message in Bob’s mailbox.
6. Bob invokes his user agent to read the message at his convenience.
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <[email protected]>
S: 250 [email protected] ... Sender ok
C: RCPT TO: <[email protected]>
S: 250 [email protected] ... Recipient ok
C: DATA
S: 354 Enter mail, end with ―.‖ on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: . S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connec�on
In the example above, the client sends a message (―Do you like
ketchup? How about pickles?‖) from mail server crepes.fr to mail server
hamburger.edu. As part of the dialogue, the client issued five commands:
HELO (an abbrevia�on for HELLO), MAIL FROM, RCPT TO, DATA, and
QUIT. These commands are self-explanatory.
Comparison with HTTP :
When Alice writes an ordinary snail-mail leter to Bob, she may include
all kinds of peripheral header informa�on at the top of the leter, such as
Bob’s address, her own return address, and the date. Similarly, when an
e-mail message is sent from one person to another, a header containing
peripheral informa�on precedes the body of the message itself.
As with HTTP, each header line contains readable text, consis�ng of a
keyword followed by a colon followed by a value. Some of the keywords
are required and others are op�onal. Every header must have a From:
header line and a To: header line; a header may include a Subject:
header line as well as other op�onal header lines.
Atypical message header looks like this:
From: [email protected]
To: [email protected]
Subject: Searching for the meaning of life.
A�er the message header, a blank line follows; then the message body
(in ASCII) follows. You should use Telnet to send a message to a mail
server that contains some header lines, including the Subject: header
line. To do this, issue telnet serverName 25
Once SMTP delivers the message from Alice’s mail server to Bob’s mail
server, the message is placed in Bob’s mailbox. Throughout this
discussion we have tacitly assumed that Bob reads his mail by logging
onto the server host and then execu�ng a mail reader that runs on that
host. Up un�l the early 1990s this was the standard way of doing things.
But today, mail access uses a client-server architecture—the typical user
reads e-mail with a client that executes on the user’s end system, for
example, on an office PC, a laptop, or a smartphone. By execu�ng a mail
client on a local PC, users enjoy a rich set of features, including the ability
to view mul�media messages and atachments.
Given that Bob (the recipient) executes his user agent on his local PC, it is
natural to consider placing a mail server on his local PC as well. With this
approach,Alice’s mail server would dialogue directly with Bob’s PC. There
is a problem with this approach, however. Recall that a mail server
manages mailboxes and runs the client and server sides of SMTP. If Bob’s
mail server were to reside on his local PC, then Bob’s PC would have to
remain always on, and connected to the Internet, in order to receive new
mail, which can arrive at any �me. This is imprac�cal for many Internet
users. Instead, a typical user runs a user agent on the local PC but
accesses its mailbox stored on an always-on shared mail server. This mail
server is shared with other users and is typically maintained by the user’s
ISP (for example, university or company).
Now let’s consider the path an e-mail message takes when it is sent from
Alice to Bob. We just learned that at some point along the path the e-
mail message needs to be deposited in Bob’s mail server. This could be
done simply by having Alice’s user agent send the message directly to
Bob’s mail server. And this could be done with SMTP—indeed, SMTP has
been designed for pushing e-mail from one host to another. However,
typically the sender’s user agent does not dialogue directly with the
recipient’s mail server. Instead, as shown in Figure 2.18, Alice’s user
agent uses SMTPto push the e-mail message into her mail server, then
Alice’s mail server uses SMTP (as an SMTP client) to relay the e-mail
message to Bob’s mail server.
Figure provides a summary of the protocols that are used for Internet
mail: SMTP is used to transfer mail from the sender’s mail server to the
recipient’s mail server; SMTP is also used to transfer mail from the
sender’s user agent to the sender’s mail server. Amail access protocol,
such as POP3, is used to transfer mail from the recipient’s mail server to
the recipient’s user agent.
POP3 :
Now let’s take a look at the transac�on phase. A user agent using POP3
can o�en 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
opera�ng in. In the download-and-delete mode, the user agent will issue
the list, retr, and dele commands. As an example, suppose the user has
two messages in his or her mailbox. In the dialogue below, C: (standing
for client) is the user agent and S: (standing for server) is the mail server.
The transac�on will look something like:
C: list
S: 1 498
S: 2 912
S: .
C: retr 1
S: (blah blah ...
S: .................
S: ..........blah)
S: .
C: dele 1
C: retr 2
S: (blah blah ...
S: .................
S: ..........blah)
S: .
C: dele 2
C: quit
S: +OK POP3 server signing off
The user agent first asks the mail server to list the size of each of the
stored messages. The user agent then retrieves and deletes each
message from the server.
IMAP :
With POP3 access, once Bob has downloaded his messages to the local
machine, he can create mail folders and move the downloaded messages
into the folders. Bob can then delete messages, move messages across
folders, and search for messages (by sender name or subject). But this
paradigm—namely, folders and messages in the local machine—poses a
problem for the nomadic user, who would prefer to maintain a folder
hierarchy on a remote server that can be accessed from any computer.
This is not possible with POP3—the POP3 protocol does not provide any
means for a user to create remote folders and assign messages to
folders.
To solve this and other problems, the IMAP protocol, defined in [RFC
3501], was invented. Like POP3, IMAP is a mail access protocol. It has
many more features than POP3, but it is also significantly more complex.
(And thus the client and server side implementa�ons are significantly
more complex.)
Web-Based E-Mail More and more users today are sending and accessing
their e-mail through their Web browsers. Hotmail introduced Web-based
access in the mid 1990s. Now Web-basede-mail is also provided by
Google, Yahoo!, as well as just about every major university and
corpora�on.
DNS—The Internet’s Directory Service :
Just as humans can be iden�fied in many ways, so too can Internet hosts.
One iden�fier for a host is its hostname. Hostnames—such as cnn.com,
www.yahoo. com, gaia.cs.umass.edu, and cis.poly.edu—are mnemonic
and are therefore appreciated by humans. However, hostnames provide
litle, if any, informa�on about the loca�on within the Internet of the
host. (Ahostname such as www.eurecom.fr, which ends with the country
code .fr, tells us that the host is probably in France, but doesn’t say much
more.) Furthermore, because hostnames can consist of variablelength
alphanumeric characters, they would be difficult to process by routers.
For these reasons, hosts are also iden�fied by so-called IP addresses.
The DNS is
(1) a distributed database implemented in a hierarchy of DNS servers,
and
(2) an applica�on-layer protocol that allows hosts to query the
distributed database.
1. The same user machine runs the client side of the DNS applica�on.
2. The browser extracts the hostname, www.someschool.edu, from
the URL and passes the hostname to the client side of the DNS
applica�on.
3. The DNS client sends a query containing the hostname to a DNS
server.
4. The DNS client eventually receives a reply, which includes the
IPaddress for the hostname.
5. Once the browser receives the IPaddress from DNS, it can ini�ate a
TCPconnec�on to the HTTPserver process located at port 80 at
that IPaddress.
6. DNS provides a few other important services in addi�on to
transla�ng hostnames to IPaddresses:
The DNS servers that together implement the DNS distributed database
store resource records (RRs), including RRs that provide hostname-to-IP
address mappings. Aresource record is a four-tuple that contains the
following fields:
(Name, Value, Type, TTL)
TTL is the �me to live of the resource record; it determines when a
resource should be removed from a cache. In the example records given
below, we ignore the TTL field. The meaning of Name and Value depend
on Type:
• If Type=A, then Name is a hostname and Value is the IP address for the
hostname. Thus, a Type Arecord provides the standard hostname-to-
IPaddress mapping. As an example, (relay1.bar.foo.com, 145.37.93.126,
A) is a Type Arecord.
• If Type=NS, then Name is a domain (such as foo.com) and Value is the
hostname of an authorita�ve DNS server that knows how to obtain the
IP addresses for hosts in the domain. This record is used to route DNS
queries further along inthe query chain. As an example, (foo.com,
dns.foo.com, NS) is a Type NS record
. • If Type=CNAME, then Value is a canonical hostname for the alias
hostname Name. This record can provide querying hosts the canonical
name for a hostname. As an example, (foo.com, relay1.bar.foo.com,
CNAME) is a CNAME record.
• If Type=MX, then Value is the canonical name of a mail server that has
an alias hostname Name. As an example, (foo.com, mail.bar.foo.com,
MX) is an MX record. MX records allow the hostnames of mail servers to
have simple aliases. Note that by using the MX record, a company can
have the same aliased name for its mail server and for one of its other
servers (such as its Web server). To obtain the canonical name for the
mail server, a DNS client would query for an MX record; to obtain the
canonical name for the other server, the DNS client would query for the
CNAME record.
DNS Messages
The seman�cs of the various fields in a DNS message are as follows:
P2P Architecture :
1. Centralized Directory
2. Query Flooding
3. Exploi�ng Heterogeneity
1) Centralized Directory
2) Query Flooding
Working
• Now when one peer requests for some file, this request is sent to
all its neighboring nodes i.e. to all nodes connected to this node. If
those nodes don’t have the required file, they pass on the query to
their neighbors and so on. This is called query flooding.
• When the peer with the requested file is found (referred to as
query hit), the query flooding stops and it sends back the file
name and file size to the client, thus following the reverse path.
• If there are mul�ple query hits, the client selects from one of
these peers.
3) Exploi�ng Heterogeneity
Working
Here are some steps you can take to install and use network monitoring tools:
1. Choose a tool: There are many network monitoring tools available,
including open-source tools, tools with graphical interfaces, and tools
that can monitor network traffic:
o Nagios: An open-source tool that helps DevOps teams monitor
networks and infrastructure, and maintain records of events and
failures
o Paessler PRTG Network Monitor: A tool with a simple interface
that provides informa�on about network traffic and is easy for
inexperienced users to use
o SolarWinds: A well-known tool that automa�cally maps networks
and nodes, and has a graphical interface that shows network
topology and status
o Zabbix: An open-source tool that can be scaled from small
businesses to large enterprises, and is available as a so�ware or
virtual appliance download
o DataDog: A tool that installs an agent to enable network discovery
and monitoring, and supports features like network mapping,
resource u�liza�on monitoring, aler�ng, and log management
o ManageEngine OpManager: A tool that focuses on infrastructure
management, but also offers network monitoring and applica�on
performance management features
o WhatsUp Gold: A user-friendly tool that combines infrastructure
management, applica�on performance management, and network
monitoring, and offers customizable pricing packages
o Auvik: A tool that helps small businesses map and monitor
network health and performance, and uses a centralized
dashboard to provide real-�me visibility
o Icinga: An open-source tool that allows network administrators to
monitor infrastructure of all sizes, and checks hosts and services to
no�fy users of their status
2. Install the tool
3. Discover and add devices
4. Configure the monitoring se�ngs
5. Test and verify the monitoring
6. Maintain and update the tool
1. Launch the tool: Start the network monitoring tool and log in to
the dashboard.
2. Discover devices: Allow the tool to automa�cally discover
devices on your network or manually add them.
3. Set up monitoring: Configure the tool to monitor specific
devices, services, or applica�ons.
4. Set thresholds and alerts: Define thresholds for performance
metrics and set up alerts for poten�al issues.
5. Monitor network performance: View real-�me data on network
performance, including bandwidth usage, latency, and packet loss.
6. Troubleshoot issues: Use the tool to iden�fy and troubleshoot
network problems, such as connec�vity issues or device failures.
7. Generate reports: Create customized reports to analyze network
performance, usage trends, and security threats.
8. Customize the dashboard: Tailor the dashboard to display
relevant data and metrics for your network.
9. Integrate with other tools: Integrate the network monitoring
tool with other tools, such as helpdesk so�ware or security
informa�on and event management (SIEM) systems.
10. Regularly update and maintain: Regularly update the tool and
maintain your network monitoring configura�on to ensure op�mal
performance.
Conclusion:
Network monitoring tools are so�ware programs that let you see exactly what
your network is doing at any given �me. They provide detailed informa�on
about your connec�on speed, packet size, and latency.
Network monitoring tools are essen�al when you want to make sure your
website is working correctly. If something goes wrong with your website, you
need to find out as soon as possible so you can fix it. A good network
monitoring tool lets you monitor mul�ple websites at once and provides real-
�me data about each site, and it also allows you to view all of the sites on your
network from one place.