V Ise 18cs52-Cn-Module 1
V Ise 18cs52-Cn-Module 1
Module-1 Syllabus
Application Layer:
Principles of Network Applications: Network Application Architectures, Processes
Communicating, Transport Services Available to Applications, Transport Services
Provided by the Internet, Application-Layer Protocols. The Web and HTTP: Overview of
HTTP, Non-persistent and Persistent Connections, HTTP Message Format, User-Server
Interaction: Cookies, Web Caching, The Conditional GET, File Transfer: FTP Commands
& Replies, Electronic Mail on the Internet: SMTP, Comparison with HTTP, Mail
Message Format, Mail Access Protocols, DNS; The Internet's Directory Service: Services
Provided by DNS, Overview of How DNS Works, DNS Records, and Messages, Peer-to-
Peer Applications: P2P File Distribution, Distributed Hash Tables, Socket Programming:
creating Network Applications: Socket Programming with UDP, Socket Programming
with TCP.
MODULE 1
APPLICATION LAYER
1.1 Principles of Network Applications
• Network-applications are the driving forces for the explosive development of the internet.
• Examples of network-applications:
1) Web 5) Social networking (Facebook, Twitter)
2) File transfers 6) Video distribution (YouTube)
3) E-mail 7) Real-time video conferencing (Skype)
4) P2P file-sharing 8) On-line games (World of Warcraft)
• In network-applications, a program usually needs to
→ run on the different end-systems and
→ communicate with one another over the network.
• For ex: In the Web application, there are 2 different programs:
1) The browser program running in the user's host (Laptop or Smartphone).
2) The Web-server program running in the Web-server host.
• In this architecture, there is a server and many clients distributed over the network (Figure
1.1a).
• The server is always-on while a client can be randomly run.
• The server is listening on the network and a client initializes the communication.
• Upon the requests from a client, the server provides certain services to the client.
• Usually, there is no communication between two clients.
• The server has a fixed IP address.
• A client contacts the server by sending a packet to the server's IP address.
• A server can communicate with many clients.
• The applications such as FTP, telnet, Web, e-mail etc use the client-server architecture.
1.1.3.2 Throughput
• Throughput is the rate at which the sending-process can deliver bits to the receiving-
process.
• Since other hosts are using the network, the throughput can fluctuate with time.
1.1.3.3 Timing
• A transport-layer protocol can provide timing-guarantees.
• For ex: guaranteeing every bit arrives at the receiver in less than 100 msec.
• Timing constraints are useful for real-time applications such as
→ Internet telephony
→ Virtual environments
→ Teleconferencing and
→ Multiplayer games
1.1.3.4 Security
• A transport-protocol can provide one or more security services.
• For example,
1) In the sending host, a transport-protocol can encrypt all the transmitted-data.
2) In the receiving host, the transport-protocol can decrypt the received-data.
• The base HTML file references the other objects in the page with the object's URLs.
• URL has 2 components:
1) The hostname of the server that houses the object and
2) The object’s path name.
• For example:
“http://www.someSchool.edu/someDepartment/picture.gif”
In above URL,
1) Hostname = “www.someSchool.edu ”
2) Path name = “/someDepartment/picture.gif”.
• The web browsers implement the client-side of HTTP. For ex: Google Chrome, Internet
Explorer
• The web-servers implement the server-side of HTTP. For ex: Apache
1.2.1.2 HTTP
• HTTP is Web’s application-layer protocol (Figure 1.3) (HTTP HyperText Transfer
Protocol).
• HTTP defines
→ how clients request Web-pages from servers and
→ how servers transfer Web-pages to clients.
• The HTTP client first initiates a TCP connection with the server.
• After connection setup, the browser and the server-processes access TCP through their
sockets.
• Figure 1.4: Back-of-the-envelope calculation for the time needed to request and receive an
HTML file [1]
• RTT is the time taken for a packet to travel from client to server and then back to the
client.
• The total response time is sum of following (Figure 1.4):
i) One RTT to initiate TCP connection (RTT Round Trip Time).
ii) One RTT for HTTP request and first few bytes of HTTP response to
return.
iii) File transmission time.
i.e. Total response time = (i) + (ii) + (iii) = 1 RTT+ 1 RTT+ File transmission time
= 2(RTT) + File transmission time
1.2.2.2 HTTP with Persistent Connections
• Problem with Non-Persistent Connections:
1) A new connection must be established and maintained for each requested-object.
➢ Hence, buffers must be allocated and state info must be kept in both the client and
server.
➢ This results in a significant burden on the server.
2) Each object suffers a delivery delay of two RTTs:
i) One RTT to establish the TCP connection and
ii) One RTT to request and receive an object.
• Solution: Use persistent connections.
• With persistent connections, the server leaves the TCP connection open after sending
responses.
• Hence, subsequent requests & responses b/w same client & server can be sent over same
connection
• The server closes the connection only when the connection is not used for a certain
amount of time.
• Default mode of HTTP: Persistent connections with pipelining.
• Advantages:
1) This method requires only one RTT for all the referenced-objects.
2) The performance is improved by 20%.
1.2.3 HTTP Message Format
• Two types of HTTP messages: 1) Request-message and 2) Response-message.
1.2.3.1 HTTP Request Message
2) Header-lines and
3) Data (Entity body).
• The status line contains 3 fields:
1) Protocol version
2) Status-code and
3) Status message.
• Some common status-codes and associated messages include:
1) 200 OK: Standard response for successful HTTP requests.
2) 400 Bad Request: The server cannot process the request due to a client error.
3) 404 Not Found: The requested resource cannot be found.
• The meaning of the Status line is as follows:
“HTTP/1.1 200 OK”: This line indicates the server is using HTTP/1.1 & that
everything is OK.
• The response-message contains 6 header-lines. The meaning of the header-lines is as
follows:
1) Connection: This line indicates browser requesting a non-persistent connection.
2) Date: This line indicates the time & date when the response was sent by the
server.
3) Server: This line indicates that the message was generated by an Apache Web-
server.
4) Last-Modified: This line indicates the time & date when the object was last
modified.
5) Content-Length: This line indicates the number of bytes in the sent-object.
6) Content-Type: This line indicates that the object in the entity body is HTML text.
• Cookies refer to a small text file created by a Web-site that is stored in the user's computer.
• Cookies are stored either temporarily for that session only or permanently on the hard disk.
• Cookies allow Web-sites to keep track of users.
• 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.
4) A back-end database at the Web-site.
Figure 1.8: Clients requesting objects through a Web-cache (or Proxy Server) [1]
Figure 1.9: FTP moves files between local and remote file systems [1]
1.4.3.1 POP
• POP is an extremely simple mail access protocol.
• POP server will listen at port 110.
• Here is how it works:
➢ The user-agent at client's computer opens a TCP connection to the main server.
➢ POP then progresses through three phases:
1) Authentication
➢ The user-agent sends a user name and password to authenticate the user.
2) Transaction
➢ The user-agent retrieves messages.
➢ Also, the user-agent can
→ mark messages for deletion
→ remove deletion marks &
→ obtain mail statistics.
➢ The user-agent issues commands, and the server responds to each command with a
reply.
➢ There are two responses:
i) +OK: used by the server to indicate that the previous command was fine.
ii) –ERR: used by the server to indicate that something is wrong.
3) Update
➢ After user issues a quit command, the mail-server removes all messages marked
for deletion.
• Disadvantage:
The user cannot manage the mails at remote mail-server. For ex: user cannot delete
messages.
1.4.3.2 IMAP
• IMAP is another mail access protocol, which has more features than POP.
• An IMAP server will associate each message with a folder.
• When a message first arrives at server, the message is associated with recipient's INBOX
folder
• Then, the recipient can
→ move the message into a new, user-created folder
4) Maintenance
➢ The single DNS server would have to keep records for all Internet hosts.
➢ This centralized database has to be updated frequently to account for every new
host.
1.5.2.1 A Distributed, Hierarchical Database
• The example shown in Figure 1.13 makes use of both recursive queries and iterative
queries.
• The query 1 sent from cis.poly.edu to dns.poly.edu is a recursive query. This is because
→ the query asks dns.poly.edu to obtain the mapping on its behalf.
• But the subsequent three queries 2, 4 and 6 are iterative. This is because
→ all replies are directly returned to dns.poly.edu.
4) If Type=MX, Value is the canonical name of a mail-server that has an alias hostname
Name.
➢ MX records allow the hostnames of mail-servers to have simple aliases. For ex:
(foo.com, mail.bar.foo.com, MX) is an MX record.
b) Authoritative
➢ This flag-bit is set in a reply message when a DNS server is an authoritative-server.
c) Recursion Desired
➢ This flag-bit is set when a client desires that the DNS server perform recursion.
iii) Four Number-of-Fields
➢ These fields indicate the no. of occurrences of 4 types of data sections that follow
the header.
2) Question Section
• This section contains information about the query that is being made.
• This section has following fields:
i) Name
➢ This field contains the domain-name that is being queried.
ii) Type
➢ This field indicates the type of question being asked about the domain-name.
3) Answer Section
• This section contains a reply from a DNS server.
• This section contains the resource-records for the name that was originally queried.
• A reply can return multiple RRs in the answer, since a hostname can have multiple IP
addresses.
4) Authority Section
• This section contains records of other authoritative-servers.
5) Additional Section
• This section contains other helpful records.
1.6 Peer-to-Peer Applications
• Peer-to-peer architecture is different from client-server architecture.
• In P2P, each node (called peers) acts as a client and server at the same time.
• The peers are not owned by a service-provider.
• The peers not supposed to be always listening on the Internet.
• The peers are dynamic, i.e., some peers will join some peers will leave from time to
time.
1.6.1 P2P File Distribution
• One popular P2P file distribution protocol is BitTorrent
• Consider the following scenarios:
Suppose a server has a large file and ‘N’ computers want to download the file (Figure 1.15).
1) In client-server architecture, each of the N computers will
→ connect to the server &
→ download a copy of the file to local-host.
2) In P2P architecture, a peer need not necessarily download a copy from the server.
2) The peer with the lowest download-rate cannot obtain all F bits of the file in less
than F/dmin.
➢ Thus, the minimum distribution-time is at least F/ dmin.
• Putting above 2 observations together, we have
• We have 2 observations:
1) At the beginning of the distribution, only the server has the file.
➢ So, the minimum distribution-time is at least F/us.
2) The peer with the lowest download-rate cannot obtain all F bits of the file in less
than F/dmin.
➢ Thus, the minimum distribution-time is at least F/ dmin.
3) The total upload capacity of the system as a whole is u total = us + u1 + u2 . . . +
uN.
➢ The system must deliver F bits to each of the N peers.
➢ Thus, the minimum distribution-time is at least NF/( us + u1 + u2 . . . + uN).
• Putting above 3 observations together, we have
• Figure 1.16 compares the minimum distribution-time for the client-server and P2P
architectures.
1.6.1.1 BitRorrent
• The collection of all peers participating in the distribution of a particular file is called a
torrent.
• Peers download equal-size chunks of the file from one another. Chunk size = 256 KBytes.
• The peer also uploads chunks to other peers.
• Once a peer has acquired the entire file, the peer may leave the torrent or remain in the
torrent.
• Each torrent has an infrastructure node called tracker.
• Here is how it works (Figure 1.17):
1) When a peer joins a torrent, the peer
→ registers itself with the tracker and
→ periodically informs the tracker that it is in the torrent.
2) When a new peer joins the torrent, the tracker
→ randomly selects a subset of peers from the set of participating peers and
→ sends the IP addresses of these peers to the new peer.
3) Then, the new peer tries to establish concurrent TCP connections with all peers
on this list.
➢ All peers on the list are called neighboring-peers.
4) Periodically, the new peer will ask each of the neighboring-peers for the set of
chunks.
• To choose the chunks to download, the peer uses a technique called rarest-first.
• Main idea of rarest-first:
→ Determine the chunks that are the rarest among the neighbors and
→ Request then those rarest chunks first.
➢ So, we can view the identifier as an integer at the range from 0 to 2n-1.
2) For a data pair (key, value), the hash value of the key is computed.
➢ Then the data is stored in the peer whose identifier is closest to the key.
3) To insert or retrieve data, first we need to find the appropriate peer.
➢ Problem: It is not realistic to let the peer to store all of the
other peer's identifiers. Solution: Use a circular arrangement.
Figure 1.18: (a) A circular DHT. Peer 3 (b) A circular DHT with shortcuts[1]
wants to determine who is responsible
for key 11. [1]
from
socket
import *
serverPort
= 12000
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverSocket.bind((’’, serverPort)) // This line assigns the port# 12000 to the server’s socket.
print ”The server is ready to receive”
while 1:
message, clientAddress = serverSocket.recvfrom(2048)
modifiedMessage = message.upper() // This line converts data to upper case
serverSocket.sendto(modifiedMessage, clientAddress)
References:
1. James F Kurose and Keith W Ross, Computer Networking, A Top-Down Approach, Sixth
edition, Pearson,2017 .
2. Nader F Mir, Computer and Communication Networks, 2nd Edition, Pearson, 2014.
2. 2019 &
1. Dec/Jan-
2019
2. Explain FTP with its commands and replies. 8 Dec/Jan-
2019
3. Discuss how files are distributed in peer-to-peer application. 8 June/July
2018
4. Design network application using socket programming with 8 June/July
UDP 2018
5. Describe in detail the services offered by DNS and , explain 8 June/July
DNS messaging format. 2019
6. Explain non-persistent & persistent connections of HTTP 8 June/July
2019
7. Define a socket. Describe the socket programming using 8 June/July
TCP. 2019
8. Explain HTTP messages. 8 Dec/Jan-2019
9. Explain web caching with diagram 8 June/July
2019
10. Explain DNS resource record. 4 Dec/Jan-
2019
11. What are the different types of transport services provided by 8 June/July
the internet 2018
12. Compose logical note on proxy-server with suitable diagram 8 June/July
2018
Prepared by
Mrs. Usha G.R.
Assistant Professor