ch2 APPL 2122 V01deel1
ch2 APPL 2122 V01deel1
ch2 APPL 2122 V01deel1
Chapter 2
Application Layer
Computer Networking
A Top-Down Approach
7th Edition, 2017
Pearson,
James F. Kurose, Keith W. Ross
App 1 App 2
IP TCP-Connection
-d
a ta
gr
am
Internet Protocol
Q:router
How to communicate among
10 Mbit/s local area
56.6 kbit/s remote processes? network
modem connection
2 Mbit/s
ISDN link 100 Gbit/s WDM 140 Mbit/s
local telephone
PDH link
switch transatlantic optical cable Application Layer 2-3
Network Applications
• e-mail • voice over IP (e.g., Skype)
• web • real-time video
conferencing
• text messaging
• social networking
• remote login
• search
• P2P file sharing
• …
• multi-user network
games • …
• streaming stored video
(YouTube, Hulu, Netflix)
clients:
• communicate with server
• may be intermittently connected
• may have dynamic I P addresses
• do not communicate directly with each other
• Instant messaging
– chatting between two users is P2P
– centralized service: client presence detection/location
▪ user registers its IP address with central server when it
comes online
▪ user contacts central server to find IP addresses of contacts
App 1 App 2
IP TCP-Connection
-d
a ta
gr
am
Q: What doInternet
we need for
Protocol
communication
router between two 10 Mbit/s local area
56.6 kbit/s
modem connection
remote applications? network
2 Mbit/s
ISDN link 100 Gbit/s WDM 140 Mbit/s
local telephone
PDH link
switch transatlantic optical cable Application Layer 2-9
What is needed for application-
layer communication?
2. Type of connectivity
– Provided by the lower layer = transport layer protocol
– Two (most used) types:
▪ Reliable byte stream service = TCP
▪ Best-effort datagram service = UDP
TCP connectivity
UDP connectivity
SSH 22 TCP
Telnet 23 TCP
Note that these are assigned by convention (reserved as per RFC 1700).
Port numbers > 1024 can be freely used (e.g., web server at port 443)
timing security
• some apps (e.g., Internet • encryption, data integrity, …
telephony, interactive
games) require low delay to
be “effective”
Bytes stream
l l e w…e p o H ! i H
• UDP = best-effort datagram service
– UDP treats them as separate messages (of max 65507 bytes)
– Application itself must handle lost messages
Hope
Hi!
you’re well
Application Layer 2-14
Network programming using sockets
• Network communication from one process to another
remote process relies on Operating System Calls for
network programming
• Most common API is based on Berkeley Sockets:
• Socket = communication endpoint, referring to the
“door” between the application process and the end-to-
end transport protocol
application application
socket controlled by
process process app developer
transport transport
network network controlled
link
by OS
link Internet
physical physical
server
request reception and thread creation
IP address: 148.35. 2.205
TCP protocol: 6
HTTP port: 80
network
CLIENT 1 CLIENT N
CLIENT 2
IP address: 157.193.122.12 IP address: 134.182.113.65
TCP protocol: 6 IP address: 157.193.122.112 TCP protocol: 6
HTTP port: 1173 TCP protocol: 6 HTTP port:
Application 1173
Layer 2-18
HTTP port: 1212
Applications and application-layer protocols
Web browser Web server
IP:213.118.203.222 IP:104.200.23.95
port:12355 port:80
ComNet.html
Base H T ML - file which
includes several
referenced objects
ietf.gif
First referenced object (with
own url:
https://ietf.org/media/images/ietf-logo
.original.png
)
ugent.png
Second referenced object …
IDLab.jpg
Third referenced object …
to server, port 80
protocols that maintain “state”
• server accepts TCP are complex!
connection from client
• past history (state) must be
• HTTP messages (application- maintained
layer protocol messages)
• if server/client crashes, their
exchanged between browser
views of “state” may be
(HTTP client) and Web server
inconsistent, must be
(HTTP server)
reconciled
• TCP connection closed
Application Layer 2-26
HTTP overview
uses TCP: HTTP is “stateless”
• server is listening (open • server maintains no information
socket, port 80) (application state) about past client
requests
• client initiates TCP connection
(creates socket, port >1024) aside
to server, port 80
protocols that maintain “state”
• server accepts TCP are complex!
connection from client
• past history (state) must be
• HTTP messages (application- maintained
layer protocol messages)
• if server/client crashes, their
exchanged between browser
views of “state” may be
(HTTP client) and Web server
inconsistent, must be
(HTTP server)
reconciled
• TCP connection closed
Application Layer 2-27
HTTP in the global picture
APPLICATION APPLICATION
CLIENT SERVER
transport transport
network network network network
data link data link data link data link data link data link
physical physical physical physical physical physical
time time
• POST • 301
• HEAD • 400
• 404
• PUT • 505
http/1.1
...
header field name SP value CR/LF
POST method:
• web page often includes form input
• input is uploaded to server in entity body
URL method:
• uses GET method
• input is uploaded in URL field of request line:
www.somesite.com/animalsearch?monkeys&banana
...
header field name SP value CR/LF
header
lines
header field name SP value CR/LF
new
CR/LF line
client server
ebay 8734
usual http request msg Amazon server
cookie file creates ID
usual http response 1678 for user create backend
ebay 8734
set-cookie: 1678 entry database
amazon 1678
increasing performance
1971: 1988:
1982: MSMail 1993: 2004:
Invention SMTP (Outlook Webmail Gmail
of email v0)
Internet SMTP
SMTP outgoing
Port 25 message queue
user mailbox
POP3 mail
POP3 server
Post Office Protocol Port 110
Handshaking
pleased to meet you
MAIL FROM:<[email protected]>
250 <[email protected]>... Sender ok
RCPT TO:<[email protected]>
250 <[email protected]>... Recipient ok
DATA
Message
354 Enter mail, end with "." on a line by itself
Subject: example message
John,
hier een kleine test-boodschap.
Close
.
250 KAA29013 Message accepted for delivery
• From:
• Subject:
different from SMTP
commands !
• body
• the “message”, ASCII
characters only
Application Layer 2-64
Message format: multimedia extensions
• MIME (Multipurpose Internet Mail Extensions) :
multimedia mail extension, RFC 2045, 2056
• additional lines in msg header declare MIME content type
From: [email protected]
MIME version To: [email protected]
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data
(base64: 6 bits encoding)
Application Layer 2-65
BASE64
John,
This is an email message with two attached MS-Word documents.
Message
--=====================_909671503==_
Content-Type: application/msword; name="MIMEtest1.doc";
x-mac-type="42494E41"; x-mac-creator="4D535744"
MIME
Content-Transfer-Encoding: base64 header
Content-Disposition: attachment; filename="MIMEtest1.doc"
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAIQAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
...
Attachment1
AAAAAAAAAAAAAAAAAAAAAAAAAA==
--=====================_909671503==_
Content-Type: application/msword; name="MIMEtest2.doc";
x-mac-type="42494E41"; x-mac-creator="4D535744"
MIME
Content-Transfer-Encoding: base64 header
Content-Disposition: attachment; filename="MIMEtest2.doc"
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAIQAAAAAAAAAA
EAAAIwAAAAEAAAD+////AAAAACAAAAD/////////////////////////////////////////////
...
Attachment2
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAA==
--=====================_909671503==_--
.
End Of Layer
Application Message
2-68