Fundamentals of
Telecommunications
Chapter 2
Application Layer
Thái Truyển Đại Chấn
Introduction
• Network applications are reasons for being of a computer network
• Applications have been the driving force behind the Internet’s success
Introduction
• 1970s, 1980s: text email, remote access, file transfers,
• 1990s:
• WWW (surfing, search, electronic commerce)
• Instant messaging (MSN, Yahoo Messenger, …)
• 2000s:
• Voice and video applications
• VoIP, video conferencing over IP (Skype)
• Youtube
• Movies on demand (Netflix)
• Multi-player online games (Second Life, World of Warcraft,…)
• Social network (Facebook, Twitter, Yahoo 360, …)
• 2010s:
• …, Uber, Grab, …
2.1 Principles of Network Applications
• Programs running on different end systems and communicate with each other over the
network
• Web application
• Browser program in the client
• Web server program in the server
• P2P file-sharing system
• A program in each host
• The programs may be similar or identical
2.1 Principles of Network Applications
• You need to write software running on end systems
• Do not need to write software running on network core
devices (routers, link-layer switches, …)
2.1.1 Network Application Architectures
• You should have a broad architectural plan
• Application’s architecture is different from
• Network architecture (e.g., the 5 layers)
• Architectural paradigms
• Client-server architecture
• Peer-to-peer (P2P) architecture
2.1.1 Network Application Architectures
• Client-server architecture:
• Client–server model is a distributed application structure that partitions tasks or workloads:
• Server provides a resource/service;
• Client requests a resource/service.
• Resource: software/programs, electronic
components, data, processors and storage devices.
• Service: sharing of resources of a server.
• Inter-server/server-to-server communication: for
data synchronization.
2.1.1 Network Application Architectures
• Client-server architecture:
• The servers are always ON.
• A client sends a request for an object to the server.
• The server responds w/ the object.
• Clients do not directly communicate with each other
• 2 browsers do not directly communicate.
• The server has a fixed IP address.
• Web, FTP, Telnet, and e-mail.
2.1.1 Network Application Architectures
• Client-server architecture
• A data center
• A large number of hosts;
• A powerful virtual server;
• Google has 30 to 50 data centers;
• A data center can have 100s of 1000s of
servers.
2.1.1 Network Application Architectures
• P2P architecture
• Direct communication between pairs of connected hosts (peers);
• Most traffic-intensive applications are P2P
• File sharing (e.g., BitTorrent),
• Peer-assisted download acceleration (e.g., Xunlei),
• Internet Telephony (e.g., Skype),
• Internet Protocol television (IPTV,
e.g., Kankan and PPstream)
2.1.1 Network Application Architectures
• P2P architecture
• Advantages
• Self-scalability
• A peer can distribute content to other peers
• Cost effective
• Don’t require significant server infrastructure
and server bandwidth
• Challenges
• ISP Friendly
• Security
• Incentives
• Volunteer bandwidth, storage, and computation
resources
2.1.1 Network Application Architectures
• Hybrid architectures
• Both client-server and P2P elements
• E.g., instant messaging applications
• Servers to check IP address of clients
• Clients directly communicate w/ e/ other
2.1.2 Processes Communicating
• A process can be thought of as a program running in an end system
• Processes in an operation system communicate with each other 🡪 not considered.
• Processes in different operation systems communicate with each other:
• Exchanging messages across the computer network;
• The processes reside in the application layer.
2.1.2 Processes Communicating
• Client and Server Processes Transport-layer protocol
• Process initiating the communication is the client
• Process waiting to be contacted is the server.
• The Interface Between the Process and the Application
Computer Network Socket
• Processes send and receive messages through a
software interface called a socket;
• Socket: Application Programming Interface (API)
between the application and the network
2.1.2 Processes Communicating
• The Interface Between the Process and the Computer Network
2.1.2 Processes Communicating
• The Interface Between the Process and the Computer Network
• The only control that the application developer has on the transport-layer side is
• The choice of transport protocol;
• A few transport-layer parameters such as maximum buffer and maximum segment sizes
• Addressing Processes
• IP address
• Port number
2.1.3 Transport Services Available to Applications
• Reliable Data Transfer
• Loss-tolerant applications
• Throughput
• Bandwidth-sensitive applications
• Elastic applications
• Timing
• Security
2.1.4 Transport Services Provided by the Internet
• UDP or TCP
2.1.4 Transport Services Provided by the Internet
• TCP Services :
• Connection-oriented service;
• Reliable data transfer service:
• Without error and in the proper order;
• Congestion-control mechanism.
• UDP Services:
• Connectionless;
• No guarantee that the message reaches the receiving process;
• No order;
• No congestion-control mechanism.
2.1.4 Transport Services Provided by the Internet
2.1.5 Application-Layer Protocols
• Distinguish btw
• Network applications
• Application-layer protocols
• For example
• Web application consists of many components:
• Standard for document formats (HTML),
• Web browsers (Firefox and Microsoft IE),
• Web servers (Apache and Microsoft servers),
• Application-layer protocol (HTTP):
• Defines the format and sequence of messages exchanged between browser and
Web server.
2.1.5 Application-Layer Protocols
• For example
• E-mail application
• Mail servers,
• Mail clients (Outlook),
• Email structure,
• Application-layer protocol (SMTP=Simple Mail Transfer Protocol)
• How messages are passed between servers;
• Btw servers and clients;
• How to interpret message headers.
2.2 The Web and HTTP
• The Internet was used primarily by researchers, academics, …
• The early 1990s, the Web appeared
• Operating on demand
• Users receive what they want, when they want it
• Easy for everyone to publish
• Hyperlinks and search engines: easy to navigate
• Forms, JavaScript, Java applets, … allow interactions
• A platform for YouTube, Gmail, and Facebook
2.2.1 Overview of HTTP
• HyperText Transfer Protocol (HTTP) is implemented in a client program and a server program
• A Web page consists
• a base HTML file
• several objects.
• An object = a file addressable by a single URL
• e.g, an HTML file, a JPEG image, a Java applet, a video clip
• The base HTML file references the other w/ URLs
[Link]
[Link]
hostname path name
2.2.1 Overview of HTTP
• Web browsers (e.g., Internet Explorer and Firefox)
implement the client side of HTTP
• Web servers
• implement the server side of HTTP,
• house Web objects
• addressable by a URL popular Web (e.g.,
Apache and Microsoft Internet Info. Server)
• HTTP:
• How Web clients request Web pages from Web servers;
• How servers transfer Web pages to clients.
2.2.1 Overview of HTTP
• HTTP Request:
• client process 🡪 client socket interface 🡪 TCP connection 🡪 server socket interface🡪 server
process
• HTTP response: …
• HTTP is stateless protocol.
2.2.2 Non-Persistent and Persistent Connections
• HTTP with Non-Persistent Connections
• [Link]
1. client process initiates a TCP connection to the server [Link]
• Port number 80
2. client: HTTP request to the server via its socket
• /someDepartment/[Link].
3. server process receives the request message via its socket,
• retrieves the object /someDepartment/[Link] from its storage (RAM or disk),
• encapsulates the object,
• sends the response to the client via its socket.
4. server process tells TCP to close the connection
5. client receives the response message,
• closes the connection;
• extracts the file, examines the HTML file, and finds references to the 10 JPEG objects.
• The first 4 steps are repeated for each of referenced JPEG objects
2.2.2 Non-Persistent and Persistent Connections
• HTTP with Non-Persistent Connections
• TCP connections for 10 JPEG objects can
be
• Serial
• Parallel
• “three-way handshake”
• Initiation
• Acknowledge
• Acknowledge + HTTP request
• Total time = RTT + RTT + file transmit
time
Round-trip time (RTT)
2.2.2 Non-Persistent and Persistent Connections
• HTTP with Non-Persistent Connections
• Disadvantages
• Occupying resource: buffer, variables,
…
• Two types of RTT
2.2.2 Non-Persistent and Persistent Connections
• HTTP with Persistent Connections
• A TCP connection can be used for
• Multiple objects in a Web page;
• Multiple Web pages for single server-single client pair.
• The connection is closed when not used for a certain time
2.2.3 HTTP Message Format
• HTTP Request Message
GET /somedir/[Link] HTTP/1.1
Host: [Link]
Connection: close
User-agent: Mozilla/5.0
Accept-language: fr
• Method field:
• GET, POST, HEAD, PUT, and DELETE
• POST: entity body contains
what the user entered into the
form fields, e.g., Google search
• GET to search, include the
inputted data (in the form
fields) in the requested URL
[Link]/animalsearch?monkeys&bananas
2.2.4 User-Server Interaction: Cookies
• Cookies allow sites to keep track of users
• Cookie technology has four components
• A cookie header line in the HTTP response
message;
• One in request message;
• A cookie file on the client side;
• A back-end database at the Web site.
2.2.4 User-Server Interaction: Cookies
• Cookies can be used to create a user session
layer on top of stateless HTTP
• Amazon can remember what a client
searches or buys
• Can also be considered as an invasion of
privacy
• If the client registered in Amazon,
Amazon can sell information to a third
party
2.2.5 Web Caching
• Students’ presentation
2.4 DNS—The Internet’s Directory Service
• Students’ presentation
2.6 Peer-to-Peer Applications
• Server-client architecture
• Web, email, DNS
• Always-on infrastructure
• Peer-to-peer architecture
• Minimal/no always-on infrastructure
• Pairs of intermittently connected peers directly communicate
• Peers (users’ desktops, laptops …) not owned by ISPs
2.5 Peer-to-Peer Applications
2.5.1 P2P File Distribution
• Distributing a large file from a single server to a large number of peers
• An existing operating system, or a movie, …
• In client-server distribution,
• The server sends a copy of the file to each of the peers
• In P2P file distribution,
• Each peer redistributes any portion of the file
2.5.1 P2P File Distribution
• Scalability of P2P Architectures
• The distribution time is the time it takes
to get a copy of the file to all N peers.
• Assume that the Internet core has
abundant bandwidth
• All of the bottlenecks are in access
networks
• Assume that the server and clients are
not participating in any other network
applications
2.5.1 P2P File Distribution
• Client-server architecture
• For large N, DCS is given by NF/uS
• If in one week, N increases by 1,000
from 1,000 to 1,000,000
• DCS also increases by 1,000
2.5.1 P2P File Distribution
• P2P architecture
• A lower bound for the distribution
time
2.5.1 P2P File Distribution
• F/u = 1 hour,
us = 10u,
dmin ≥ us
BitTorrent
• Torrent = all peers participating in a file distribution.
• Peers in download chunks w/ the same size.
• When a peer first joins a torrent, it has no chunks.
Over time it accumulates more and more chunks.
• Once a peer has acquired the entire file,
• it may (selfishly) leave the torrent, or
• (altruistically) remains in the torrent and
continues to upload chunks to other peers.
BitTorrent
• BitTorrent is a rather complicated protocol and
system.
• Each torrent has an infrastructure node called a
tracker.
• When a peer joins a torrent,
• it registers itself with the tracker and
• periodically informs the tracker that it is still in
the torrent
• A torrent may have < 10, or > 1000 peers
BitTorrent
• When Alice joins the torrent,
• the tracker randomly selects a subset of
participating peers,
• sends the IP addresses of these peers to
Alice.
• Alice establishes TCP connections w/ all
peers on the list.
• “Neighboring peers”: successful
connections w/ Alice.
• By time, peers may leave and other peers
may attempt to establish TCP connections
with Alice
BitTorrent
• Each peer has a different subset of chunks.
• Periodically, Alice asks neighboring peers for the list of the
chunks they have.
• Alice requests for chunks she does not have.
• Which chunks should she request first?
• Rarest first 🡪 the rarest chunks get more quickly
redistributed 🡪 equalized among chunks
BitTorrent
• To which neighbors should she send requested chunks?
• The ones supplying her at the highest rate.
• She measures the rate she receives bits;
• chooses the 4 peers feeding her at the highest rate;
• every 10 seconds, she recalculates the rates
• These 4 peers are said to be unchoked.
• The set seems to be locked?
• Every 30 seconds, she picks one additional neighbor at random (optimistically
unchoked) and sends it chunks
Peers uploading at compatible rates tend to find each other.
2.7 Socket Programming: Creating Network Applications
• A typical network application 🡪
• A client program + a server program.
• A client process + a server process are created.
• The processes read and write to sockets
2.7 Socket Programming: Creating Network Applications
• There are 2 types of network applications
• “Open” network application
• Operation is specified in a protocol standard
• Client and server programs conform to the rules
• Programs by different developers must cooperate
• Proprietary network application
• An application-layer protocol not openly published
• A single developer creates both client and server programs
• Other developers cannot develop code interoperating w/ the application
2.7 Socket Programming: Creating Network Applications
• The key issues in developing a client-server application
• Choosing TCP or UDP
• “Open” application 🡪 use the well-known port number associated w/ the protocol
• Proprietary application 🡪 avoid such well-known port numbers
2.7.1 Socket Programming with UDP
• Process ↔ house; process’s socket ↔ door.
Transport-layer protocol
Application
Socket
• The application developer has control of everything on the application-layer side of the socket
• And little control of the transport-layer side.
• The sending process attaches a destination address to the packet
• And push it out the socket door
• The address: the destination host’s IP address and the destination socket’s port number
• UDP does not attach the source address
Problems
• P4
• P5
• P22
• P23
• P24
• P26