CN Module 2
CN Module 2
Application Layer
Outline
1. Principles of network applications
3. FTP
5. DNS
6. P2P applications
web
text messaging
remote login
Netflix)
voice over IP (e.g., Skype)
social networking
search
Creating a network app application
transport
network
Write programs that: data link
physical
run on (different) end
systems
communicate over network
client/server Clients:
communicate with server
Not continuously connected
may have dynamic IP addresses
do not directly communicate with
each other
Ex: web, FTP
Client-server architecture
• There is an always-on host, called the server, which
services requests from many other hosts, called clients.
change IP addresses
complex management
Ex: Bit Torrent
P2P Architecture
• There is minimal dedicated servers in data centers.
• The peers are not owned by the service provider, but are instead
desktops and laptops controlled by users.
aside:
applications with
P2P architectures
have client
Client and Server Processes
A network application consists of pairs of processes that
send messages to each other over a network.
P2P :
◦ 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, one of the two
processes as the client and the other process as the server.
◦ With the Web, a browser is a client process and a Web
server is a server process.
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.
Once the message arrives at the destination host, the message passes
through the receiving process’s door (socket), and the receiving process
then acts on the message.
Sockets
Process sends/receives messages to/from its socket
Socket analogous to door
application application
socket controlled by
process process app developer
transport transport
network network controlled
link
by OS
link Internet
physical physical
Socket is the interface between the application layer and the transport layer
within a host.
The only control that the application developer has on the transport-layer
side is
◦ The choice of transport protocol
◦ The ability to fix a few transport-layer parameters such as maximum
buffer and maximum segment sizes.
◦ Once the application developer chooses a transport protocol the
application is built using the transport-layer services provided by that
protocol
Addressing processes
To receive messages, process must have identifier.
identifier includes both IP address and port numbers associated with process on
host.
4. Security
A transport protocol can provide an application with one or
more security services.
For example,
◦ Sending host, a transport protocol can encrypt all data transmitted by
the sending process,
◦ Receiving host, the transport-layer protocol can decrypt the data before
delivering the data to the receiving process.
◦ Service would provide confidentiality, Integrity and Authentication
between the two processes, even if the data is somehow observed
between sending and receiving processes.
Transport service requirements: common
apps
Internet transport protocols services
Services Not Provided by Internet
Transport Protocols
Popular Internet applications, their application-layer
protocols, and their underlying transport protocols
Application-layer protocol
An application-layer protocol defines how an application’s processes,
running on different end systems, pass messages to each other.
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, the meaning of the information in the fields.
◦ Rules for determining when and how a process sends messages and
responds to messages.
Web
Early 1990, Internet was used only by researchers, academics,
and university students.
Example:
Transferring a webpage from server to client, webpage
consists of a base HTML file and 10 JPEG images.
Total 11 object are reside on server.
Non-persistent HTTP: Response time
RTT(round-trip time):
A time for a small initiate TCP
packet to travel from connection
client to server and RTT
vice versa. request
file
time to
RTT transmit
HTTP response time: file
◦ one RTT to initiate TCP file
connection. received
◦ one RTT for HTTP
request and first few time time
bytes of HTTP response
to return.
◦ File transmission time
The server closes the connection only when it is not used for a
certain configurable amount of time.
Two types:
1. Request Message
2. Response Message
1. HTTP Request Message
It is in ASCII format which means that human-readable
format.
The request line has three fields: the method field, the URL
field, and the HTTP version field.
The method field can take on several different values, including GET,
POST, HEAD, PUT, and DELETE.
The great majority of HTTP request messages use the GET method.
The GET method is used when the browser requests an object, with the
requested object identified in the URL field.
• If the value of the method field is POST, then the entity body
contains what the user entered into the form fields.
• HTML forms often use the GET method and include the inputted
data in the requested URL.
header
lines
Ithas three sections: an initial status line, six header lines,
and then the entity body.
The status line has three fields: the protocol version field, a
status code, and a corresponding status message.
The
Date: header line indicates the time and date when the
HTTP response was created and sent by the server.
The Web cache has its own disk storage and keeps copies
of recently requested objects in this storage.
A user’s browser can be configured so, user’s HTTP requests are first
directed to the Web Cache.
Otherwise cache requests object from origin server, then returns object
to client browser.
An
HTTP request message is a so-called conditional
GET message if
◦ the request message uses the GET method and
◦ the request message includes an If-Modified- Since: header
line.
First,on the behalf of a requesting browser, a proxy cache
sends a request message to a Web server:
GET /fruit/kiwi.gif HTTP/1.1
Host: www.exotiquecuisine.com
Importantly, the cache also stores the last-modified date along with the
object.
Third, one week later, another browser requests the same object via
the cache, and the object is still in the cache.
Sincethis object may have been modified at the Web server in the past
week, the cache performs an up-to-date check by issuing a conditional
GET.
In order for the user to access the remote account, the user
must provide a user identification and a password.
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 connection rather than
the control TCP connection.
High level view of Internet mail system and its key components.
1. User agents
2. Mail servers
3. Simple Mail Transfer Protocol (SMTP)
Email
user
agent
mail user
server agent
SMTP mail user
server agent
SMTP
SMTP user
agent
mail
server
user
agent
user
agent
Outgoing
message queue
user mailbox
User Agent
User
agents allow users to read, reply to, forward, save, and
compose messages.
E.g.
Microsoft Outlook and Apple Mail.
Mail servers:
A mailbox
contains incoming messages for user.
A message
queue of outgoing (to be sent) mail messages.
SMTP
It
is a principal application layer protocol between mail servers to
send email messages.
◦ client: sending mail to server
◦ server: receiving mail from other different mail server
SMTP
Simple Mail Transfer Protocol used in sending and receiving
e-mail.
It restricts the body (not just the headers) of all mail messages
to simple 7-bit ASCII.
SMTP does not use intermediate mail servers for sending mail.
user
m ail acce s s user
SMTP SMTP protocol
agent agent
(e .g., POP,
IMAP )
IMAP
◦ Internet Mail Access Protocol
The recipient can then move and organize the message into
a new, user-created folder, read the message, delete the
message, move messages from one folder to another and so
on.
SMTP
◦ https://www.youtube.com/watch?v=bKECC0DHe9Y
DNS: domain name system
people: many identifiers:
SSN, name, passport #
Alphabetic name
IP Address
remember by human
To resolve the name issues in the internet –use of protocol DNS
In DNS system, If one DNS server doesn't know how to translate a
particular domain name, it asks another one, and so on, until the correct
IP address is returned.
The client first contacts one of the root servers, which returns IP addresses
for TLD servers - top-level domain .com.
A single point of failure: If the DNS server crashes then the entire Internet
will not stop.
A Single DNS Server cannot handle huge DNS traffic but with distributed
system its distributed and reduce overload on server.
Distant centralized database: A single DNS server cannot be “close to” all
the querying clients.
If it is in New York City, then all queries from Australia must travel to the
other side of the globe, perhaps over slow and congested links cause
significant delays.
Iterated query:
A host at cis.poly.edu 2
3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5
gaia.cs.umass.edu
DNS name resolution example
root DNS server
Recursive query:
2 3
A host at cis.poly.edu
7
6
wants IP address for
gaia.cs.umass.edu TLD DNS
server
Heavy load at upper
level of hierarchy. local DNS server 4
dns.poly.edu 5
1 8
gaia.cs.umass.edu
DNS Services
Host aliasing
◦ A host with a complicated hostname can have one or more alias
names.
◦ Alias hostnames, when present, are typically more mnemonic than
canonical hostnames.
Load distribution:
◦ DNS is also used to perform load distribution among replicated
servers, such as replicated Web servers.
◦ The DNS database contains the set of IP addresses.
DNS: Caching, Updating Rcords
once (any) name server learns mapping, it caches mapping
cache entries timeout (disappear) after some time (TTL)
TLD servers typically cached in local name servers
thus root name servers not often visited
type=CNAME
name is alias name for some “canonical” (the real) name
www.ibm.com is really servereast.backup2.ibm.com
value is canonical name
reply is authoritative
additional info (variable # of RRs)
DNS protocol, messages
2 bytes 2 bytes
identification flags
Includes
(1) a name field that contains the name that is being queried, and
(2) a type field that indicates the type of question being asked about the name.
In each resource record there is the Type, the Value, and the TTL.
Redirect attacks
Man-in-middle
Intercept queries
DNS poisoning
Send bogus relies to DNS server, which caches
application application
socket controlled by
process process app developer
transport transport
physical physical
Socket is interface between application and network.
◦ An application creates a socket.
◦ Two type of socket:
1. TCP Socket – Reliable Transmission
2. UDP Socket – Unreliable Transmission
application application
socket controlled by
process process app developer
transport transport
network network controlled
Internet link by OS
link
physical physical
Type of Socket
SOCK_STREAM SOCK_DGRAM
App D1
App
3 2 3 2
1 D2
socket Dest. 1 socket
D3
Two socket types for two transport services:
◦ UDP: unreliable datagram
◦ TCP: reliable, byte stream-oriented
Application Example:
1. Client reads a line of characters (data) from its keyboard
and sends the data to the server.
each packet
rcvr extracts sender IP address and port# from received
packet.
write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
Example app: UDP client
Python UDPClient
include Python’s socket
library from socket import *
serverName = ‘hostname’
serverPort = 12000
create UDP socket for clientSocket = socket(socket.AF_INET,
server
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
Example app: TCP client
Python TCPClient
from socket import *
serverName = ’servername’
create TCP socket for serverPort = 12000
server, remote port 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
sentence = raw_input(‘Input lowercase sentence:’)
No need to attach server clientSocket.send(sentence)
name, port
modifiedSentence = clientSocket.recv(1024)
print ‘From Server:’, modifiedSentence
clientSocket.close()
Example app: TCP server
Python TCPServer
from socket import *
create TCP welcoming
serverPort = 12000
socket serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind((‘’,serverPort))
server begins listening for
incoming TCP requests
serverSocket.listen(1)
print ‘The server is ready to receive’
loop forever while 1:
server waits on accept() connectionSocket, addr = serverSocket.accept()
for incoming requests, new
socket created on return
sentence = connectionSocket.recv(1024)
read bytes from socket (but
not address as in UDP) capitalizedSentence = sentence.upper()
close connection to this
connectionSocket.send(capitalizedSentence)
client (but not welcoming connectionSocket.close()
socket)
Thank You