Application Layer: Reading Chapter 7 Computer Networks, Tanenbaum
Application Layer: Reading Chapter 7 Computer Networks, Tanenbaum
Application layer
Reading Chapter 7
Computer networks, Tanenbaum
1
Contents
l Application layer
l Fundamental concepts
l Case study: HTTP, Mail, FTP…
2
Fundamental concepts
3
Application layer in OSI model
Application Protocols communication
between parties of the
(HTTP, Mail, …) application
Transport Transmission data between application
(UDP, TCP …)
Network
(IP, ICMP…)
Datalink
(Ethernet, ADSL…)
Physical
(bits…)
4
Application and service?
MUSIC ONLINE
VoIP
GAME CHAT VoD
ON LINE e-Office
SMS e-BANK
MAIL
E-learning
WEB
YOUTUBE
VIDEO
CONFERENCE FTP
EBAY
GOOGLE SKYPE
Social
networks SSH
7
Communication between process
on the Internet
l Socket is an interface between
an application process and host or host or
transport layer server server
l Socket is defined by
controlled by
l Port app developer
process process
l IP address
socket socket
l Transport protocol (TCP or
UDP) transport
Internet
transport
layer layer
l Socket API (Application services services
Programming Interface): Allow
application to choose
parameters for transport controlled
by OS
service
l Choose transport protocol
8
l Type of IO communication …
Application architecture
l Client-server
l P2P
l Hybrid
9
Client-server
l Two kind of components:
client client and server
l Client
l Client sends requests for service
client to server
l Clients do not contact directly to
each other
l Server
client
Server l Always online waiting for service
requests from clients
l There may be backup servers
for assuring high availability in
failures
client
l e.g. Web, Mail, …
10
Pure Peer-to-peer architecture
Peer Peer
l No center server, only
peers as components
l Peers have equal role in
the system
Peer
Peer l Any two peers can
communicate directly to
each other but only
when both are online.
l Peer does not need to
be online all the time
Peer Peer
l E.g. Gnutella, Bittorent
11
Hybrid architecture
Client
l A center server for user
management, indexing
for search purpose.
l Clients communicate
directly to each other
Server after authentication
process with server.
l E.g. Skype (before 2016)
l Skype server manage user
lists, authentification
Client Client l After authentification users
communicate directly to
each other
P2P Comm. 12
Client-Server Comm.
Case study 1: HTTP and
WWW
Reading 7.3
Computer Networks, Tanenbaum
13
HTTP and Web
Web clients
l WWW: World Wide Web
l Application for exchanging the
HTML documents (HyperText
Markup Language) over h tt
IE pr
h tt eq Web
Internet pr ue
st
es
l WWW use HTTP protocol po server
ns
e
l HTTP: HyperText Transfer
Protocol
l Client/Server model Firefox
s t
Client (Web browser)requests ue
l
r eq n se
p po
for webpages and displays h tt s
p re
them on its interface h tt
l Server: Receive request from
client and return results under 14
the form of webpage. Navigator
How HTTP works?
l Server open a TCP socket by default at port 80
waiting for
l Client initiates a TCP connection to server
l Server accept the connection request
l Exchange HTTP message
l HTTP Request
l HTTP Response
l Close connection TCP
15
Format of HTTP request
l ASCII encoding (readable using text editor)
request line
(GET, POST, GET /dccn/index.html HTTP/1.1
HEAD commands) Host: www.it-hut.edu.vn
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:en-us
CR, LF
(extra carriage return, line feed)
indicates end
of message
16
Format of HTTP response
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Tue, 16 Mar 2008 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
header
Last-Modified: Mon, 15 Mar 2008 …...
lines
Content-Length: 8990
Content-Type: text/html
17
Types of HTTP connections
HTTP non-persistent HTTP persistent
l Only one web object l Many web objects can
(text or image) is be sent over a
transferred over a connection TCP.
connection TCP l Option by default in
l Option by default in HTTP/1.1
HTTP/1.0 l HTTP 1.1: RFC 2068
l HTTP 1.0: RFC 1945
18
Operation of HTTP/1.0
Web client Web server
Time Time
Operation of HTTP/1.1
Web client Web server
Send images 2
Stop-and- Pipeline
request images 10 wait! 20
Time Time
HTTP/1.1 with pipeline
Web client Web server
21
Time Time
Methods in HTTP request message
HTTP/1.0 HTTP/1.1
l GET: get an webpage l GET, POST, HEAD
24
Web cache - proxy
25
Web caches
l Proxy: Vừa là client, vừa là server
l Sử dụng bởi các ISP nhỏ, các tổ chức như trường
học, công ty…
l Ảnh hưởng của proxy
l Làm giảm lưu lượng web trên đường ra Internet
l Có thể làm giảm thời gian đáp ứng
l Thử phân tích vài trường hợp
l cache hit
l cache miss
l proxy bị quá tải
l Trang web thay đổi/trang web động?
26
Local cache
l Web pages could be stored in local server
(local cache)
l Using local cache for
l Reading web offline
l Improve performance in accessing web pages
27
Exercise
l A company having an Internet connection
from their LAN with data rate 1.5 Mbps.
l Webpage to be downloaded from the Internet
has the average size 900 kbits
l The frequency of accessing files on the web
is =1,5 times/s.
l Duration for sending an HTTP request from
company router to the Internet is 2 (s)
l What is the average responding time in
following cases? 28
Exercise (cont.)
l If all the links have already some load.
Transmission time on a loaded link is calculated
by the following formular:
l = Wm /(1 - ρ),
l Wm: Transmission time without load
l ρ: load (ratio of traffic/capacity)
l If there is a cache
l Assume that ccache hit rate: p=0.4.
l Hint:
l Use the formular: Tm = Σ pi*Ti,
l pi probability having responding time Ti 29
30
Case study 2: Email
32
Thư điện tử
l MUA (Mail User Agent) l Giao thức:
l Lấy thư từ máy chủ, gửi thư đến l Chuyển thư: SMTP-Simple
máy chủ
Mail Transfer Protocol
l e.g. Outlook, Thunderbird…
l nhận thư
l MTA (Mail Transfer Agent): :
l POP – Post Office Protocol
l Chứa hộp thư đến của NSD (mail
box) l IMAP – Internet Mail Access
l Hàng đợi để gửi thư đi Protocol
l e.g. Sendmail, MS Exchange…
IMAP IMAP
mail mail
POP POP
user server server user
SMTP
agent agent
SMTP SMTP 33
34
Các giao thức nhận thư
SMTP SMTP access user
user
agent protocol agent
l Quota?
35
Web Mail
l Sử dụng Web browser như một MUA
l MUA và MTA giao tiếp thông qua HTTP
l Mails được lưu trữ trên máy chủ
l E.g.
l Gmail,
l Hotmail,
l Yahoo! Mail, etc.
l Ngày nay, rất nhiều các MTA cho phép truy cập
thông qua giao diện web
l http://mail.hut.edu.vn
l http://mail.fit.hut.edu.vn
36
Khuôn dạng thông điệp thư điện
tử
SMTP: Giao thức để truyền
thư
header
blank
RFC 822: Định nghĩa khuôn line
dạng
l Phần đầu
body
l To:
l From:
l Subject:
l Phần thân
l mã hóa dưới dạng mã
ASCII
37
Để chuyển dữ liệu đa phương tiện:
multimedia extensions
l MIME: multimedia mail extension, RFC 2045, 2056
l Thêm một dòng trong phần đầu chỉ rõ khuôn dạng dữ
liệu gửi đi
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
38
Case Study 3
Ứng dụng truyền tệp
39
FTP: File Transfer Protocol
TCP control
connection, port 21
user FTP FTP
interface client server
TCP data
user connection, port 20
41
Ví dụ về ftp client
Command line
43
Giới thiệu chung
l Tên miền: định danh trên tầng ứng dụng cho các nút
mạng
l Trên Internet được quản lý tập trung
l Quốc tế: ICANN
l Việt Nam: VNNIC
l DNS(Domain Name System): hệ thống tên miền gồm
các máy chủ quản lý thông tin tên miền và cung cấp dịch
vụ DNS
l Vấn đề phân giải tên miền sang địa chỉ IP
l Người sử dụng dùng tên miền để truy cập dịch vụ
l Máy tính và các thiết bị mạng không sử dụng tên miền mà dùng
địa chỉ IP khi trao đổi dữ liệu
l Làm thế nào để chuyển đổi tên miền sang địa chỉ IP?
44
Chuyển đổi địa chỉ và ví dụ
• Máy tính dùng địa chỉ IP
Tôi muốn vào địa chỉ
• NSD dùng tên miền www.soict.hust.edu.vn
NSD
Cần có chuyển
Mời truy cập vào
đổi địa chỉ 202.191.56.65
Query: www.foo.rdm. A ?
rdm. server
4
5
Query: www.foo.rdm. A ?
Query: www.foo.rdm. A ? Answer : foo.rdm. NS list
1 8 7 6
Query: www.foo.rdm. A ?
Answer :
www.foo.rdm. A Answer : www.foo.rdm. A
foo.rdm. server
47
Domain Name Service
Root
server
Query: IP address of Q: IP address of
www.hust.edu.vn www.hust.edu.vn
A: NS of .vn
User 3
1
2
8 Q: IP of TLD
www.hust.edu.vn
4 server
DNS 5
A: NS of edu.vn domain .vn
Resolver
Ex: 8.8.8.8
6 Q: IP of
www.hust.edu.vn
7
A: www.hust.edu.vn
Authoritative
www.hust.edu.vn server
48
202.191.57.208
domain .edu.vn
Domain name service
l Root server:
l Manage the list of TLD nameserver based on the
extension of that domain (.com, .net, .org, etc.)
l The root nameservers are overseen by a nonprofit
called the Internet Corporation for Assigned
Names and Numbers (ICANN).
l There are 13 root server but there are mutiple
copies of each one all over the world
49
Domain name service
l Top Level Domain (TLD) nameserver
l maintains information for all the domain names
that share a common domain extension
l Generic top-level domains: .com, .org, .net, .edu, and
.gov.
l Country code top-level domains: .vn, .uk, .fr, .jp …
l If a user searches for google.com, after receiving a response
from a root nameserver, the recursive resolver then sends a
query to a .com TLD nameserver.
53
Thông điệp DNS
l #Answer RRs: Số lượng bản Identification Flags
ghi trả lời
#Question #Answer RRs
l ANSWER: Các bản ghi trả lời
#Authority #Additional
l # Authority RRs: Số lượng RRs RRs
bản ghi từ các máy chủ được
QUESTION
ủy quyền khác
ANSWER
l AUTHORITY: Các bản ghi
của máy chủ được ủy quyền AUTHORITY
khác
ADDITIONAL
l #Additional RRs: Số lượng
các bản ghi bổ sung
l ADDITIONAL: Các bản ghi bổ
sung
54
Ví dụ: dig linux.com
; <> DiG 9.9.2-P1 <> linux.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21655
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2,
ADDITIONAL: 3
;; QUESTION SECTION: TTL: thời gian(s) lưu giữ
;linux.com. IN A trả lời trong cache
;; ANSWER SECTION:
linux.com. 1786 IN A 140.211.167.51
linux.com. 1786 IN A 140.211.167.50
;; AUTHORITY SECTION:
linux.com. 86386 IN NS ns1.linux-foundation.org.
linux.com. 86386 IN NS ns2.linux-foundation.org.
;; ADDITIONAL SECTION:
ns1.linux-foundation.org. 261 IN A 140.211.169.10
ns2.linux-foundation.org. 262 IN A 140.211.169.11
55
Ví dụ: dig linux.com –thực hiện
truy vấn DNS
; <> DiG 9.9.2-P1 <> linux.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21655
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2,
ADDITIONAL: 3
;; QUESTION SECTION: Tên các máy chủ DNS server trả lời truy vấn.
;linux.com. IN A Nếu phần ANSWER rỗng, DNS Resolver gửi
;; ANSWER SECTION: truy vấn tới các máy chủ này
linux.com. 1786 IN A 140.211.167.51
linux.com. 1786 IN A 140.211.167.50
;; AUTHORITY SECTION:
linux.com. 86386 IN NS ns1.linux-foundation.org.
linux.com. 86386 IN NS ns2.linux-foundation.org.
;; ADDITIONAL SECTION:
ns1.linux-foundation.org. 261 IN A 140.211.169.10
ns2.linux-foundation.org. 262 IN A 140.211.169.11
56
Ví dụ: dig linux.com
; <> DiG 9.9.2-P1 <> linux.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21655
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2,
ADDITIONAL: 3
;; QUESTION SECTION: Địa chỉ IP của các máy chủ trả lời truy vấn.
;linux.com. IN A Thông tin này được lưu vào cache
;; ANSWER SECTION:
linux.com. 1786 IN A 140.211.167.51
linux.com. 1786 IN A 140.211.167.50
;; AUTHORITY SECTION:
linux.com. 86386 IN NS ns1.linux-foundation.org.
linux.com. 86386 IN NS ns2.linux-foundation.org.
;; ADDITIONAL SECTION:
ns1.linux-foundation.org. 261 IN A 140.211.169.10
ns2.linux-foundation.org. 262 IN A 140.211.169.11
57
Phân giải tương tác
l Cơ chế mặc định trên các máy chủ DNS
n root
u .v server
t. ed
u s
t .h
s o ic .v n
n s
i d
Hỏ
soict.hust.edu.vn soict.hust.edu.vn
TLD
202.191.56.65 Hỏi dns.hust.edu.vn server
Default dns.vn
so
Server ic t
.h u
(Resolver) st.
20 ed
2 .1 u .v
91 n
.5 6
.6 5 Authoritative
DNS server
dns.hust.edu.vn 58
Phân giải đệ quy
l Tùy chọn mở rộng
Root
u .v n server
t . ed
u s
.h
ic t 6 .6 5
so . 5 soict.hust.edu.vn
. 1 91
2
soict.hust.edu.vn 20 202.191.56.65
TLD
202.191.56.65 server
Default
Server dns.vn
(Resolver) soict.hust.edu.vn
202.191.56.65
Authoritative
DNS server
dns.hust.edu.vn
59
Tóm tắt
l Mô hình ứng dụng
l Client-server vs. P2P
l Một số ứng dụng và giao thức
l HTTP
l Mail
l FTP
l Về nhà, hãy tìm hiểu thêm
l P2P
l ……
l Giao diện lập trình Socket
60
HTTPS
l HTTPS
l Cơ bản về ATTT
l Assymestric system: Public key – Private key
l Chứng chỉ số (certificate)
l Symmestric system
l Chữ ký điện tử
61
Acknowledgment
l Bài giảng có sử dụng các tư liệu và hình vẽ
từ:
l Tài liệu của trường đại học Keio và Ritsumekan
l Tài liệu “Computer Network, a top down
approach” của J.F Kurose và K.W. Ross
62