2. Network Applications
● Applications should run in 2 places
○ Browser program running in User’s Device
○ Web server program running in the Web server host
■ E.g.: Netflix Video on Mobile phone and Server of the company
● There are 2 types of Architectures involved in Network Applications:
○ Application Architecture:
■ is designed by the application developer and dictates how the application is structured over
the various end systems
● client-server architecture
○ Clients do not communicate with each other directly
○ Server has fixed IP address
○ One server is not enough to handle large user request. They use Data
centre
○ E.g.: Web, FTP, Telnet, and e-mail
● peer-to-peer (P2P) architecture
○ Direct communication between Hosts (Peers)
○ Peers are not owned by Service providers. But by users
○ E.g.: BitTorrent
○ Adv: Self scalable, Cost effective
○ Disadv: security, performance, and reliability issue due to their highly
decentralized structure.
○ Hybrid Client Server and P2P
○ Centralized Registration for participants
○ E.g.: Instant Messaging applications
○ Network Architecture:
■ fixed and provides a specific set of services to applications
3. E.g.: E-mail, Web, Instant messaging, speech (voice) over IP, Real-time video conference, Social networks, Remote
login, P2P file sharing, Network games, Streaming Stored Video (YouTube, Netflix, etc.), Search
4. Transport Service available to applications
● Socket is the interface between the application process and the transport- layer protocol. The application at the sending side pushes messages
through the socket. At the other side of the socket, the transport-layer protocol has the responsibility of getting the messages to the socket of
the receiving process.
● Services:
○ Reliable Data Transfer
■ No losing data from sending end to receiving end. Some loss tolerant applications allow slow amount of data loss
○ Throughput
■ the rate at which the sending process can deliver
bits to the receiving process
● bandwidth-sensitive applications have
specific throughput requirements,
● elastic applications can make use of as much,
or as little, throughput as happens to be available
○ Timing
○ Security
● The Internet (and, more generally, TCP/IP networks) makes
two transport protocols available to applications,
○ UDP
○ TCP
● Before creating application we have to choose one of
the above
5. TCP Services
● If one application choose TCP, following services are provided:
○ Connection oriented services:
■ After Handshaking a full duplex TCP connection is exist. At the end the application
should tear down the connection
○ Reliable Data Transfer Service:
■ The stream bytes passed by the application to socket will be at the receiving end without
any losses or duplication.
○ Flow Control:
■ Transmitter does not flood the receiver
○ Accumulation control:
■ Transmitter will slow down the packet speed when the network is congested
○ No guarantee in terms of time or bandwidth
6. UDP Services
● Connectionless. So, no handshaking
● Unreliable data transfer:
○ Data losses will happen
○ Data may not arrive in the order we sent
● No congestion control mechanism is provided
● No guarantee in terms of time or bandwidth
● Many firewalls are designed to block UDP.
7. Application Layer Protocol
● 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
● Application layer protocol is a piece of Network application
8. HTTP
● WWW was the first web application which brought internet to use in Public.
● HTTP is the web’s application layer protocol. [RFC 1945], [RFC 7230] and [RFC 7540].
● HTTP has
○ Client program
○ Server Program
● HTTP defines how Web clients request Web pages from Web servers and how servers transfer Web
pages to clients
● HTTP uses TCP
● HTTP is said to be a stateless protocol. Because it does not contain any information about the client.
(Client request or response)
● Types of connections in HTTP:
○ Non Persistent connection:
■ Request and Response sends over separate TCP connections
○ Persistent Connection
■ Request and Response sent over same TCP connection
9. Non Persistent connection (HTTP 1.0)
• Round Trip Time:
Time taken to send a small packet and receive
the response from the client
• Disadvantages:
▪ Brand new connection should made for
each requested object
▪ Each packet suffer 2 RTT delay
10. Persistent Connection (HTTP 1.1)
● The server leaves the TCP connection open after the first response message is sent
● The server closes the connection after a certain time without use ( timeout )
● 2 Types:
○ Persistent with pipelining:
■ Client sends new request when response to previous one is received
■ One RTT per object
○ Persistent without pipelining:
■ The client sends object requests continuously (as the base page is interpreted)
■ Means an RTT + transmission time for all referenced objects
11. HTTP Message format
● Messages are in ASCII format
● 2 types of messages:
○ Request Message
■ First Line: Request Line
● Method Field (GET, POST, PUT, HEAD. DELETE)
● URL Field
● HTTP version field
■ Other Lines: Header Lines
HTTP 1.0 HTTP 1.1
GET GET
POST POST
HEAD:
Similar to GET method. But the response
will leaves the object requested and return
HTTP message
HEAD
PUT
DELETE
12. ○ Response Message
■ Status Line
● Protocol, Version, Status
■ Header lines
■ Entire Body
● Status Messages
○ 200 OK
○ 301 Moved Permanently
○ 400 Bad Request
○ 404 Not Found
○ 505 HTTP Version Not
Supported
13. Cookies
● It has 4 components
○ Cookie header line in the response
message
○ Cookie header line in the HTTP request
message
○ Cookie file kept in the user’s end system
and managed by the user’s browser
○ Backend database
14. Web caching or Proxy Server
● A network entity that satisfies HTTP requests on
the behalf of an origin Web server.
● Reasons for using web cache
○ reduce the response time for a client request
○ reduce traffic on an institution’s access link
to the Internet
15. Conditional GET
● The copy resides in the web cache may be outdated. HTTP has a mechanism to verify the components are
up to date which is Conditional GET.
○ On behalf of Requesting browser the proxy cache send request message to web server
GET /fruit/kiwi.gif HTTP/1.1
Host: www.exotiquecuisine.com
○ Web server sends a response message with the requested object to the cache
HTTP/1.1 200 OK
Date: Sat, 3 Oct 2015 15:39:29
Server: Apache/1.3.0 (Unix)
Last-Modified: Wed, 9 Sep 2015 09:23:24
Content-Type: image/gif
(data data data data data ...)
○ If user wants the same data after a few days the cache will perform a up-to-date check
GET /fruit/kiwi.gif HTTP/1.1
Host: www.exotiquecuisine.com
If-modified-since: Wed, 9 Sep 2015 09:23:24
○ The web server will send the response.
HTTP/1.1 304 Not Modified
Date: Sat, 10 Oct 2015 15:39:29
Server: Apache/1.3.0 (Unix)
(empty entity body)
16. HTTP/2
● The primary goals:
○ reduce perceived latency by enabling request and response multiplexing over a single TCP connection.
○ Reduce perceived delay when downloading web pages consisting of multiple objects
● Goals are obtained by following mechanisms:
○ Multiplexing of both request and response over ONE and Same TCP connection
○ Use framing and streaming
○ Use Server Push
○ Compression of header Fields
○ Data is binary instead of Plain text
○ The client can prioritize requests
● HTTP/2 does not change HTTP methods, status codes, URLs, or header fields.
● HTTP/2 changes how the data is formatted and transported between the client and server.
● It reduces the Head of Line (HOL) blocking problem.
○ HTTP/1.1 use parallel TCP connections to avoid HOL.
○ HTTP/2 use framing sublayer to create several frames for a website.
○ Framing sublayer also binary encode the frames. These are more efficient to parse, lead to smaller frames and are less
error prone
17. Challenges with HTTP/1.1
● HTTP/1.1
○ Using a TCP connection to download resources from same webserver.
○ Sends multiple requests and replies one after the other over the same TCP connection - pipelining
○ One TCP connection per web page reduces the load on the web server, each client gets their share of
server resources
○ First Come First Server (FCFS): The order of the responses from the server corresponds to the order of
incoming requests
○ FCFS cause head of Line (HOL) blocking. Small object have to wait for a long time if there is a large
object before them.
■ HOL is avoided by using several TCP connections by HTTP/1.1 browsers
■ By using several TCP connections, the browser cheat by using a large proportion of available
bandwidth
18. HTTP/2 framing
● The solution to avoid HOL blocking is to split both request and reply messages into
smaller pieces, « frames »
● The bits are then merged with bits from other interleaving messages over the same TCP
network. connection
● The messages are divided by the sender and put together by the recipient
● This is done by the HTTP / 2 protocol (in a separate «sublayer», «binary framing layer»)
○ Ex. A response message sent from server to client will be divided into a "frame" for the header the fields and
one or more "frames" for the rest of the message.
● These bits ("frames") are now sent back mixed with "frames" from other response
messages to the client over the same TCP connection
● Similarly for a request message; one "frame" for the header fields and one for the rest.
● The sublayer ensures that the bits are sent binary - more efficiently than plain text
20. Streams and Frames
● HTTP / 2 operates with the term « stream » in addition to
« frame »:
● Remember: All communication, ie exchange of request
and response messages between client and server, go over
CP connection
● Typically, a request message and associated response
message be linked to a (logical) « stream »
● Furthermore, the messages are divided into «frames»,
each frame gets one "Stream id" (among other things so
that the receiver can set them together)
● So, a message (request and / or response) is included in a
stream, frames are part of a stream
21. HTTP/2 Prioritizations and Server Push
● The client can prioritize the objects (actually the "stream") as requested
○ 1 - 256 (highest priority)
○ In addition, dependencies can be set between the objects ("streams")
● Server divides the objects into «frames», server can thus start sending the pieces with
the highest priority, then the second highest, etc.
● Server push:
○ The server can analyze the base page (eg index.html) and make sure to send all referenced objects to the
client without having received requests for these
○ Saves request messages from the client ← and faster response overall
22. HTTP/2 Compression of Header fields
● All header fields in an HTTP1.1 message are sent as plain text.
● This normally provides 500-800 bytes of extra data per message, sometimes more if
cookies are in use (may then be several kilobytes)
● To avoid unnecessary data traffic and improve performance, HTTP / 2 compresses
header fields using so-called HPACK compression
23. HTTP/3
● HTTP/3 is yet a new HTTP protocol that is designed to operate over QUIC. (new
“transport” protocol that is implemented in the application layer over the bare-bones
UDP protocol)
● Features:
○ message multiplexing (interleaving),
○ per-stream flow control
○ low-latency connection establishment
24. Email system
● Electronic mails have following features compare to postal mail:
○ fast,
○ easy to distribute
○ Inexpensive
● Internet mail system has
○ user agents:
■ User agents allow users to read, reply to, forward, save, and compose messages.
● E.g.: Microsoft Outlook, Apple Mail, Web based Gmail, the Gmail App running in a smartphone
○ mail servers:
■ Mail servers form the core of the e-mail infrastructure. Each recipient have a mailbox.
■ If sender’s mail not received has some issue in sending then it will be stored in message queue. For every 30 minutes the mail server
will try to send the main. If that failed after days then the server will notify the client.
○ Simple Mail Transfer Protocol (SMTP):
■ uses the reliable data transfer service of TCP to transfer mail
■ This has 2 sides
● Client side: when it receive mail from other server
● Server side: when it send mail t other server
25.
26. SMTP-Simple Mail Transfer Protocol
● Older than HTTP. So this uses 7 bits ASCII codes for messages. To send some media file
it has to be encoded to 7 bits ASCII
● Uses TCP for reliable transmission of messages from client to server, port 25
● SMTP is a PUSH protocol.
● Here the email exchange with servers occur
● 3 phases:
○ Open TCP
○ Transmit Message
○ Close the connection
27. What happens when sending a message?
1. Alice invokes her user agent for e-mail, provides Bob’s e-mail address (for example,
bob@someschool.edu), 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 TCP connection to an SMTP server, running on Bob’s mail server.
4. After some initial SMTP handshaking, the SMTP client sends Alice’s message into the TCP
connection.
5. At Bob’s mail server, the server side of SMTP receives 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.
28. What the SMTP client and Server do?
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr ... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... 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 connection
29. Mail message format
● Header
● Body:
○ After header lines there will be a blank line.
○ Then the body in ASCII format
● MIME is the is the Multimedia Mail Extension to send multimedia files.
○ Additionally with the header
■ MIME version: 1.0
■ Content transfer encoding: base 64
■ Content type: image/jpeg
● Email protocols and their communicating entities
30. ● Base64:
○ Principles:
■ What is to be sent is seen as a sequence of bytes
■ Sequences of 3 bytes (24 bits) are divided into four 6-bit "words“
■ These six bits are translated into one of the ASCII characters: az, AZ, 0-9, /, +
○ A variant called “Modified base64” / UTF-7 is used with MIME
○ MIME types:
■ Text : Plain, HTML
■ Image : jpeg, gif
■ Audio : basic (8-bit mu-law encoded), 32kadpcm (32kbps coding)
■ Video : mpeg, quicktime
■ Application : msword
● POP (Post Office Protocol):
○ Authentication and Download
○ Uses port 110
○ POP3:
■ Authentication phase
● Client Commands (user: Username, pass: Password)
● Server Response (+OK, -ERR)
■ Transaction phase
● List : List messges and size
● Retr : download messages with specified number
● Share : delete a message
● Quit
31. ● IMAP (Internet Mail Access Protocol)
○ more functionality (more complex)
○ manipulation of stored messages on e-mail server
● HTTP:
○ From client to server
○ Send and Receive
32. SMTP vs HTTP
SMTP HTTP
Requires that the message ( head & body ) is
7-bits ASCII
Both have ASCII command / response
interaction and status codes
Special strings are not allowed in the
message. Messages are normally to be coded
in base64)
We can relatively easily implement one email
client in one or the other programming
language
PUSH only PULL and PUSH
Multiple objects are sent in same message each object is encapsulated in its own
response message
33. DNS
● 2 ways to identify host
○ IP address
○ Hostname
● DNS (Domain Name System)
○ Translate Hostname into IP address
● DNS is:
○ a distributed database implemented in a hierarchy of DNS servers (often UNIX machines running the
Berkeley Internet Name Domain (BIND) software)
○ an application-layer protocol that allows hosts to query the distributed database
○ A basic service on the Internet
○ A hierarchically organized namespace
● The DNS protocol runs over UDP and uses port 53.
34. Services provide by DNS
● Translate Hostname into IP address
○ This might give some delay in internet. But the desired IP address is cached nearby DNS
server. So the delay is reduced.
● Host aliasing
○ Handle complicated host names. One canonical hostname can have more Alias hostnames
■ relay1.west-coast.department6.enterprise.com : Canonical hostname
■ enterprise.com and www.enterprise.com : Alias hostnames
○ Mail server aliasing
■ Mail server night be relay1.west-coast.yahoo.com instead of yahoo.com.
■ MS records permits the companies' mail server and web server to be the same
○ Load distributions.
■ Busy servers have multiple servers with different IP address.
35. ● Problems of using a centralized DNS server:
○ 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
○ Distant centralized database. A single DNS server cannot be “close to” all the querying clients.
Create delays.
○ Maintenance. The single DNS server would have to keep and update records for all Internet hosts.
36. A Distributed, Hierarchical Database
● The mappings are distributed across the DNS servers.
● 3 levels of classes
○ Root DNS Server:
■ There are more than 1000 root servers instances scattered all over the world Top Level DNS Server. These root
servers are copies of 13 different root servers, managed by 12 different organizations, and coordinated through the
Internet Assigned Numbers Authority (IANA)
■ Root name servers provide the IP addresses of the TLD servers.
○ Top Level Domain Servers:
■ For each of the top-level domains—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—there is TLD server (or server cluster).
■ .com : Verisign Global Registry Services
■ .edu: company Educause
○ Authoritative DNS server:
■ 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. An organization’s
authoritative DNS server houses these DNS records. An organization can choose to implement its own authoritative
DNS server to hold these records; alternatively, the organization can pay to have these records stored in an
authoritative DNS server of some service provider. Most universities and large companies implement and maintain
their own primary and secondary (backup) authoritative DNS server.
○ Local DNS Servers:
■ These are not inside the hierarchy
■ Each ISP or company has its own (at least one) local name server
■ Does not really as a "proxy" (deputy) for the client
● DNS requests always go first to the local name server
● This is what you see when typing ipconfig / all
1,8: Recursive
Others: Iterative
38. DNS requests
● 2 types of DNS Requests
○ Recursive requests:
■ moves the workload to the contacted name server. The
name server acts on behalf of client
○ Iterative requests:
■ contacted server responds with the name of the server
that can be contacted
■ "I do not know this name, try this server instead!"
DNS Caching
● DNS servers store DNS information in their servers for a short period of time (2 days)
● because of caching, root servers are bypassed for all but a very small fraction of DNS queries.
Recursive
Iterative
39. DNS Records and Messages
● Distributed databases stores Recourse Records (RR)
● Each DNS response contains one or more resource records.
● Resource record format: ( name , value , type , time to live)
○ Name and value are depend on type
○ Type = A (AAAA = IPv6):
■ name is hostname
■ value is IP address
● relay1.bar.foo.com, 145.37.93.126, A
○ Type = NS
■ name is domain name ex. company1.no
■ value is the official hostname of name server for this domain ex. dns.bedrift1.no
● (foo.com, dns.foo.com, NS)
○ Type = CNAME
■ name is an alias for a name
■ value is a correct / official name (canonical name)
● (foo.com, relay1.bar.foo.com, CNAME)
○ Type = MX
■ name can be a domain name ex. uit.no
■ value is real (canonical) name for e-mail server associated with name
● (foo.com, mail.bar.foo.com, MX)
■ 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
40. DNS Messages
● Request and response use the same message format
● Message header (12 bytes):
○ Identification (16 bits): Identify the query. This identifier is copied into the
reply message to a query, allowing the client to match received replies with sent
queries.
○ Flag (1 bit): To identify the request and answer.
■ recursion-desired flag: when a client (host or DNS server) desires that the
DNS server perform recursion when it doesn’t have the record.
■ recursion-available field: set in a reply if the DNS server supports recursion
○ Question section: information about the query that is being made.
1. a name field that contains the name that is being queried,
2. a type field that indicates the type of question being asked about the name
○ Answer section: In a reply. contains the resource records for the name that was
originally queried. A reply can have multiple RR since the hostname has multiple IP
address.
○ Authority section: contains records of other authoritative servers.
○ Additional section: contains other helpful records. Example, the answer field in
a reply to an MX query contains a resource record providing the canonical hostname of
a mail server. The additional section contains a Type A record providing the IP address
for the canonical hostname of the mail server.
41. Inserting Records into DNS
● Register a domain name at registrar (a commercial entity that verifies the uniqueness of the domain name, enters the domain name into
the DNS database and collects a small fee from you for its services)
● For some registrar we have to provide the names and the IP addresses of your primary and secondary
authoritative DNS server.
● For each of these two authoritative DNS servers, the registrar would then make sure that a Type NS
and a Type A record are entered into the TLD com servers.
E.g. registrar would insert the following two resource records into the DNS system:
○ (networkutopia.com, dns1.networkutopia.com, NS)
○ (dns1.networkutopia.com, 212.212.212.1, A)
● You’ll also have to make sure that the Type A resource record for your Web server
www.networkutopia.com and the Type MX resource record for your mail server
mail.networkutopia.com are entered into your authoritative DNS servers.
● Then the user can view the website and also they can send mail to employees with the mail address.
42. FTP (File Transfer Protocol)
● Transfer file between computers where FTP is installed
● Client/Server model
○ Client: Initiate the connection, run the client part of FTP
○ Server: Run the server part of FTP, listen to port 21
● HTTP and FTP are similar in some manners. They are used in file transfer and both
are based on TCP
● FTP opens 2 parallel TCP connections for the following reasons:
○ Control: Exchange command between client and server
○ Data: In the form of files to or from the server
● FTP server maintains state ( state ), e.g.: current directory, previous authentication,
etc.
○ Limits the number of concurrent FTP connections a server has can handle
43. FTP Commands and Replies
● Command
○ Sent ASCII text above control channel
○ USER username
○ PASS password
○ LIST: return the list of files in current
catalog
○ RETR filename: download the file
○ LARGE filename: save file in a remote
machine
● Return Code
○ Status codes and phrases
○ 331 Username OK, Password required
○ 125 data connection already open,
transfer starting
○ 425 Can’t open data connection
○ 452 Error writing file