Lecture - 05 - Chapter 2 - 03 Sep 2024

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

National University of

Computer & Emerging Sciences


CS 3001 – COMPUTER NETWORKS

Lecture 05
Chapter 2

3rd September, 2024

Nauman Moazzam Hayat


[email protected]

Office Hours: 02:00 pm till 04:30 pm (Every Tuesday & Thursday)


Chapter 2
Application Layer
A note on the use of these PowerPoint slides:
We’re making these slides freely available to all (faculty, students,
readers). They’re in PowerPoint form so you see the animations; and
can add, modify, and delete slides (including this one) and slide
content to suit your needs. They obviously represent a lot of work on
our part. In return for use, we only ask the following:
▪ If you use these slides (e.g., in a class) that you mention their
source (after all, we’d like people to use our book!)
▪ If you post any slides on a www site, that you note that they are
adapted from (or perhaps identical to) our slides, and note our
copyright of this material.
Computer Networking: A
For a revision history, see the slide note for this page.
Top-Down Approach
Thanks and enjoy! JFK/KWR 8th edition n
All material copyright 1996-2023
Jim Kurose, Keith Ross
J.F Kurose and K.W. Ross, All Rights Reserved Pearson, 2020

Application Layer: 2-2


Application layer: overview
▪ P2P applications
▪ Principles of network ▪ video streaming and content
applications distribution networks
▪ Web and HTTP ▪ socket programming with
▪ E-mail, SMTP, IMAP UDP and TCP
▪ The Domain Name System
DNS

Application Layer: 2-3


Processes communicating
process: program running clients, servers
within a host client process: process
that initiates
▪within same host, two communication
processes communicate server process: process
using inter-process that waits to be contacted
communication (defined by
OS) ▪ note: applications with
P2P architectures have
▪processes in different hosts client processes &
communicate by exchanging server processes
messages
Application Layer: 2-4
How do we distinguish between two or
more processes running on the same
host?

Port Numbers
Then what is the difference between Process ID (PID) & Port Numbers?
A process ID is a unique identifier assigned to a running process in an operating system. It is used to track and manage
individual processes. On the other hand, a port number is a communication endpoint in a network, used to identify a specific
process or service running on a computer. Port numbers are essential for enabling communication between different processes or
services over a network. While a process ID is specific to a single operating system instance, a port number is used for network
communication between multiple systems.
Let's consider a scenario where you have a web server running on your computer. The web server is a process that listens for
incoming requests on a specific port number, typically port 80 for HTTP or port 443 for HTTPS.

In this case, the process ID (PID) is a unique identifier assigned to the running instance of the web server process. The operating
system assigns this PID to keep track of the process, manage its resources, and allow interaction with it.

The port number, on the other hand, is used to identify the specific service or process within the network. When the web server
process starts, it binds itself to a specific port number (e.g., port 80). This means that the web server process will listen for incoming
requests on that port number.

When a client (such as a web browser) wants to access a webpage hosted by your web server, it initiates a connection to your
computer's IP address on port 80. The operating system receives this incoming network request on port 80 and forwards it to the web
server process associated with that port.

The web server process, identified by its PID, receives the incoming request, processes it, and sends back the requested webpage to
the client over the same connection.

So, in summary, the PID identifies the running instance of the web server process on your computer, while the port number (in this
case, port 80) allows incoming network requests to be directed to the correct process for handling and responding to those requests.
Addressing processes
▪ to receive messages, process ▪ identifier includes both IP address
must have identifier and port numbers associated with
▪ host device has unique 32-bit process on host.
IP address ▪ example port numbers:
▪ Q: does IP address of host on • HTTP server: 80
which process runs suffice for • mail server: 25
identifying the process? ▪ to send HTTP message to
▪ A: no, many processes gaia.cs.umass.edu web server:
can be running on • IP address: 128.119.245.12
same host • port number: 80
▪ more shortly…
Application Layer: 2-7
Sockets (A combination of port number and IP address)

▪ process sends/receives messages to/from its socket


▪ socket analogous to door
• sending process shoves message out door
• sending process relies on transport infrastructure on other side of
door to deliver message to socket at receiving process
• two sockets involved: one on each side

application application
socket controlled by
process process app developer

transport transport
network network controlled
link by OS
link Internet
physical physical

Application Layer: 2-8


number
An application-layer protocol defines:
▪ types of messages exchanged, open protocols:
• e.g., request, response ▪ defined in RFCs, everyone
▪ message syntax: has access to protocol
• what fields in messages & definition
how fields are delineated ▪ allows for interoperability
▪ message semantics ▪ e.g., HTTP, SMTP
• meaning of information in proprietary protocols:
fields
▪ e.g., Skype, Zoom
▪ rules for when and how
processes send & respond to
messages
Application Layer: 2-11
What transport service does an app need?
data integrity throughput
▪ some apps (e.g., file transfer, ▪ some apps (e.g., multimedia)
web transactions) require require minimum amount of
100% reliable data transfer throughput to be “effective”
▪ other apps (e.g., audio) can ▪ other apps (“elastic apps”)
tolerate some loss make use of whatever
throughput they get
timing
▪ some apps (e.g., Internet security
telephony, interactive games) ▪ encryption, data integrity,
require low delay to be “effective” …
Application Layer: 2-12
Transport service requirements: common apps
application data loss throughput time sensitive?

file transfer/download no loss elastic no


e-mail no loss elastic no
Web documents no loss elastic no
real-time audio/video loss-tolerant audio: 5Kbps-1Mbps yes, 10’s msec
video:10Kbps-5Mbps
streaming audio/video loss-tolerant same as above yes, few secs
interactive games loss-tolerant Kbps+ yes, 10’s msec
text messaging no loss elastic yes and no
Application Layer: 2-13
Internet transport protocols services
TCP service: UDP service:
▪ reliable transport between sending ▪ unreliable data transfer
and receiving process between sending and receiving
▪ flow control: sender won’t process
overwhelm receiver ▪ does not provide: reliability,
▪ congestion control: throttle sender flow control, congestion
when network overloaded control, timing, throughput
guarantee, security, or
▪ connection-oriented: setup required connection setup.
between client and server processes
Q: why bother? Why
▪ does not provide: timing, minimum
is there a UDP?
throughput guarantee, security
Application Layer: 2-14
Internet applications, and transport protocols
application
application layer protocol transport protocol

file transfer/download FTP [RFC 959] TCP


e-mail SMTP [RFC 5321] TCP
Web documents HTTP [RFC 7230, 9110] TCP
Internet telephony SIP [RFC 3261], RTP [RFC TCP or UDP
3550], or proprietary
streaming audio/video HTTP [RFC 7230], DASH TCP
interactive games WOW, FPS (proprietary) UDP or TCP

Application Layer: 2-15


Securing TCP
Vanilla TCP & UDP sockets: TLS implemented in
▪ no encryption application layer
▪ cleartext passwords sent into socket ▪ apps use TLS libraries, that
traverse Internet in cleartext (!) use TCP in turn
Transport Layer Security (TLS) ▪ cleartext sent into “socket”
▪ provides encrypted TCP connections traverse Internet encrypted
▪ data integrity ▪ more: Chapter 8
▪ end-point authentication

Application Layer: 2-16


Application layer: overview
▪ P2P applications
▪ Principles of network ▪ video streaming and content
applications distribution networks
▪ Web and HTTP ▪ socket programming with
▪ E-mail, SMTP, IMAP UDP and TCP
▪ The Domain Name System
DNS

Application Layer: 2-17


Web and HTTP
First, a quick review…
▪ web page consists of objects, each of which can be stored on
different Web servers
▪ object can be HTML file, JPEG image, Java applet, audio
file,…
▪ web page consists of base HTML-file which includes several
referenced objects, each addressable by a URL, e.g.,
www.someschool.edu/someDept/pic.gif

host name path name

Application Layer: 2-18


Uniform Record Locator (URL)

protocol://host-name[:port]/directory-
path/resource

▪ protocol: http, ftp, https, smtp, rtsp, etc.


▪ hostname: DNS name (or domain name), IP address
▪ port: defaults to protocol’s standard port; e.g. http: 80 https: 443
▪ directory path: hierarchical, reflecting file system (on the server side)
▪ resource: Identifies the desired resource
HTTP overview
HTTP: hypertext transfer protocol
▪ Web’s application-layer protocol
▪ client/server model: PC running
• client: browser that requests, Firefox browser
receives, (using HTTP protocol) and
“displays” Web objects
• server: Web server sends (using server running
Apache Web
HTTP protocol) objects in response server
to requests
iPhone running
Safari browser

Application Layer: 2-20


HTTP overview (continued)
HTTP uses TCP: HTTP is “stateless”
▪ client initiates TCP connection ▪ server maintains no
(creates socket) to server, port 80 information about past client
▪ server accepts TCP connection requests
from client aside
▪ HTTP messages (application-layer protocols that maintain
“state” are complex!
protocol messages) exchanged
▪ past history (state) must be
between browser (HTTP client) and maintained
Web server (HTTP server) ▪ if server/client crashes, their
▪ TCP connection closed views of “state” may be
inconsistent, must be reconciled

Application Layer: 2-21


HTTP connections: two types
Non-persistent HTTP Persistent HTTP
1. TCP connection opened ▪TCP connection opened to
2. at most one object sent a server
over TCP connection ▪multiple objects can be
3. TCP connection closed sent over single TCP
connection between
downloading multiple client, and that server
objects required multiple ▪TCP connection closed
connections

Application Layer: 2-22


Non-persistent HTTP: example
User enters URL: www.someSchool.edu/someDepartment/home.index
(containing text, references to 10 jpeg images)

1a. HTTP client initiates TCP


connection to HTTP server 1b. HTTP server at host
(process) at www.someSchool.edu on www.someSchool.edu waiting for TCP
port 80 connection at port 80 “accepts”
connection, notifying client
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection 3. HTTP server receives request message,
socket. Message indicates forms response message containing
time that client wants object requested object, and sends message
someDepartment/home.index into its socket
Application Layer: 2-23
Non-persistent HTTP: example (cont.)
User enters URL: www.someSchool.edu/someDepartment/home.index
(containing text, references to 10 jpeg images)

4. HTTP server closes TCP


5. HTTP client receives response connection.
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects

6. Steps 1-5 repeated for


each of 10 jpeg objects
time

Application Layer: 2-24


Non-persistent HTTP: response time

RTT (definition): time for a small


packet to travel from client to initiate TCP
server and back connection
RTT
HTTP response time (per object):
▪ one RTT to initiate TCP connection request file
time to
▪ one RTT for HTTP request and first few RTT
transmit
bytes of HTTP response to return file
file received
▪ object/file transmission time

time time
Non-persistent HTTP response time = 2RTT+ file transmission time
Application Layer: 2-25
Non Persistent HTTP Shortcomings
❖ Most Web pages have multiple objects
▪ e.g., HTML file and a bunch of embedded images

❖ How do you retrieve those objects (naively)?


▪ One item at a time

❖ Brand New TCP connection per requested object!


(even for small object), thus significant TCP resources
need to be allocated at both server & client side (TCP
buffers)

❖ Burden on Web Servers which are servicing multiple


simultaneous clients
❖ Also each object suffers a delivery delay of 2 RTTs
(one to establish the TCP connection and one to
request & receive the object)
Persistent HTTP (HTTP 1.1)
Non-persistent HTTP issues: Persistent HTTP (HTTP1.1):
▪ requires 2 RTTs per object ▪ server leaves connection open
▪ OS overhead for each TCP after sending response
connection ▪ subsequent HTTP messages
▪ browsers often open multiple between same client/server sent
parallel TCP connections to over open connection
fetch referenced objects in ▪ client sends requests as soon as it
parallel encounters a referenced object
▪ as little as one RTT for all the
referenced objects (cutting
response time in half)
Application Layer: 2-28
Quiz
• # 1 (Chapter – 1) (Already Announced)

- Quiz # 1 for Chapter 1 to be taken in the class on Thursday, 5 th September, 2024


during the lecture time (or in the next class in case of a public holiday.)

No Retake
Be on time

You might also like