컴퓨터 네트워크
PART 02 프로토콜
(chapter 04 응용계층 )
임효택
E-mail : [email protected]
Home page : http://kowon.dongseo.ac.kr/~htlim
chapter 04 응용계층
OSI 참조 모델 응용
4.1.1 세션 , 표현 계층
세션 계층의 개관
OSI 참조 모델 5 계층에 해당
전송 제어 기능을 상위 계층에 제공
서비스 측면의 기능들을 제공하는 데 목적이 있다 .
제공 서비스
기본적으로 연결형 서비스를 제공한다 .
전송되는 데이터의 순서는 중요한 의미를 가진다 .
지원되는 서비스의 종류가 많다 .
기능단위와 사용자가 필요한 기능단위를 선택하여 사용할 수 있다 .
chapter 04 응용계층
연결형 서비스 과정
– 연결 설정 단계 , 데이터 전송 단계 , 연결 해제 단계로 나눈다 .
세션 연결의 특성
– (a) 트랜스포트와 세션 연결이 일대 일로 대응한다 . ( 가장 일반적 ) – (b) 다시 새로운 세션 연결을 시작할 때 트랜스포트 연결을 그대로 사용
할수 있다 .
– (c) 하나의 세션 연결에 대하여 트랜스포트 연결이 중간에 해제되었다가
다시 연결되어 사용된다 .
chapter 04 응용계층
대화 관리 (Dialogue management)
chapter 04 응용계층
동기 (Synchronization)
– 두 세션 사용자 간의 데이터를 교환하다가 문제가 발생하였을때
미리 정해 놓은 동기점으로 되돌아가 다시 시작하도록 하는 것 .
– 대동기점 , 소동기점[ 그림 4.3] 세션 계층에서의 동기점
[ 그림 4.4] 대동기점과 소동기점
chapter 04 응용계층
액티비티 (Activity)
– 세션 사용자 간에 어떤 일의 논리적인 단위를 표시하기 위한 것 . – 독립적인 특성을 가지며 영향을 받지 않는다 .
chapter 04 응용계층
토큰 (Token)
– 어떠한 서비스를 수행할 수 있는 권리를 나타내는 것
» 데이터토큰 , 해제 토큰 , 소동기 토큰 , 대동기 / 액티비티 토큰
서비스 프리미티브와 SPDU
서비스 프리미티브는 ISO 8326 또는 X.215 에 정의됨 .
SPDU 는 ISO8327, X.255 에 정의 됨 .
에러검출 및 복구의 기능이 없다 .
chapter 04 응용계층
4.1.2 응용계층
응용 서비스 요소
응용 프로그램이 필요로 하는 최소의 단위를 응용 서비스 요소라 한다 .
엔티티 : 특정한 하나의 응용 프로그램에 필요한 통신 서비스 요소들의 결합
형태
chapter 04 응용계층
SASE
– FTAM (file access & management) – VT (virtual terminal)
– MOTIS (message oriented text interchange system) – JTM (job transfer & manipulation)
– RDA (remote database access) – 트랜젝션 처리
– OSI 관리
CASE
– ACSE (association control service element) – CCR (commitment concurrency & recovery) – ROS (remote operation service)
chapter 04 응용계층
메시지 처리 시스템 (MHS) 서비스
대표적인 예 : 전자우편
파일 전송 , 접근과 관리 (FTAM)
디렉토리 서비스
각 자원의 위치에 관계하는 명칭을 알고 필요한 어드레스를 요구하는 기능
가상 터미널 서비스
가상 터미널이 응용 프로그램 또는 터미널 이용자에게 제공하는 서비스
OSI 관리
Application 이 필요한 트랜스포트 서비스는
?
Data loss
some apps (e.g., audio) can tolerate some loss
other apps (e.g., file transfer, telnet) require 100% reliable
data transfer
Timing
some apps (e.g., Internet
telephony, interactive games) require low delay to be
“effective”
Bandwidth
some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”
other apps (“elastic apps”) make use of whatever bandwidth they get
common apps
Application file transfer e-mail Web documents real-time audio/video stored audio/video interactive games financial apps
Data loss no loss no loss
loss-tolerant loss-tolerant loss-tolerant loss-tolerant no loss
Bandwidth elastic
elastic elastic
audio: 5Kb-1Mb video:10Kb-5Mb same as above few Kbps up elastic
Time Sensitive no
no no
yes, 100’s msec
yes, few secs
yes, 100’s msec
yes and no
Internet 응용 프로토콜과 트랜스포트 프로토콜
Application e-mail remote terminal access Web file transfer streaming multimedia remote file server Internet telephony
Application layer protocol smtp [RFC 821]
telnet [RFC 854]
http [RFC 2068]
ftp [RFC 959]
proprietary
(e.g. RealNetworks) NSF
proprietary
(e.g., Vocaltec)
Underlying
transport protocol TCP
TCP TCP TCP
TCP or UDP
TCP or UDP
typically UDP
Web 상식
Web page:
consists of “objects”
addressed by a URL
Web 페이지의 구성 :
base HTML page, and
several referenced objects.
URL 의 두가지 구성요소 : host name and path name:
User agent for Web is called a browser:
MS Internet Explorer
Netscape Communicator
Server for Web is called Web server:
Apache (public domain)
MS Internet Information Server
www.someSchool.edu/someDept/pic.gif
The Web: the http protocol
http: hypertext transfer protocol
Web’s application layer protocol
client/server model
client: browser that requests, receives,
“displays” Web objects
server: Web server sends objects in response to requests
http1.0: RFC 1945
http1.1: RFC 2068
PC running Explorer
Server running NCSA Web
server Mac running
Navigator
http request
http request http re
sponse
http response
The http protocol: more
http: TCP transport service:
client initiates TCP connection (creates socket) to server, port 80
server accepts TCP connection from client
http messages (application-layer protocol messages) exchanged between browser (http client) and Web server (http server)
TCP connection closed
http is “stateless”
server maintains no information about past client requests
Protocols that maintain “state” are complex!
past history (state) must be maintained
if server/client crashes, their views of “state” may be
inconsistent, must be reconciled
aside
http example
Suppose user enters URL
www.someSchool.edu/someDepartment/home.index1a. http client initiates TCP connection to h ttp server (process) at www.someSchool .edu. Port 80 is default for http server.
2. http client sends http request
message (containing URL) into TCP connection socket
1b. http server at host www.someSchool.ed u waiting for TCP connection at port 8 0. “accepts” connection, notifying clien t
3. http server receives request message, for ms response message containing reque sted object (someDepartment/home.inde x), sends message into socket
time
(contains text, references to 10
jpeg images)
http example (cont.)
5. http client receives response 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
4. http server closes TCP connection.
time
Non-persistent and persistent connections
Non-persistent
HTTP/1.0
server parses request, respond s, and closes TCP connection
2 RTTs to fetch each object
Each object transfer suffers fro m slow start
Persistent
default for HTTP/1.1
on same TCP connection: serve r, parses request, responds, pa rses new request,..
Client sends requests for all ref erenced objects as soon as it re ceives base HTML.
Fewer RTTs and less slow start.
But most 1.0 browsers use
parallel TCP connections.
Non-Persistent HTTP: Response time
Definition of RTT: time to send a small packet to travel from client to server and back.
Response time:
one RTT to initiate TCP connection
one RTT for HTTP request and first few bytes of HTTP
response to return
file transmission time total = 2RTT+transmit time
time to transmit file
initiate TCP connection
RTT request file
RTT file received
time time
Persistent HTTP
Nonpersistent HTTP issues:
requires 2 RTTs per object
OS overhead for each TCP connection
browsers often open parallel TCP connections to fetch referenced objects
Persistent HTTP
server leaves connection open after sending response
subsequent HTTP messages between same client/server sent over open connection
Persistent without pipelining:
client issues new request only when previous response has been received
one RTT for each referenced object
Persistent with pipelining:
default in HTTP/1.1
client sends requests as soon as it encounters a referenced
object
as little as one RTT for all the referenced objects
request
two types of http messages: request, response
http request message:
ASCII (human-readable format)
GET /somedir/page.html HTTP/1.0 User-agent: Mozilla/4.0
Accept: text/html, image/gif,image/jpeg Accept-language:fr
(extra carriage return, line feed) request line
(GET, POST, HEAD commands)
header
lines
Carriage return,
http request message: general format
http message format: respone
HTTP/1.0 200 OK
Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821 Content-Type: text/html
data data data data data ...
status line (protocol status code status phrase)
header lines
data, e.g.,
requested
html file
http response status codes
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in this message (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
In first line in server->client response message.
A few sample codes:
yourself
1. Telnet to your favorite Web server:
Opens TCP connection to port 80
(default http server port) at www.eurecom.fr.
Anything typed in sent
to port 80 at www.eurecom.fr telnet www.eurecom.fr 80
2. Type in a GET http request:
GET /~ross/index.html HTTP/1.0
By typing this in (hit carriage return twice), you send
this minimal (but complete)
GET request to http server
Web Caches (proxy server)
user sets browser: Web accesses via web cache
client sends all http requests to web cache
if object at web cache, web cache immediately returns object in http response
else requests object from origin server, then returns http response to client
Goal:
satisfy client request without involving origin serverclient
Proxy server
client
http request http request http re
sponse http response
http request http response http request http re
sponse
origin server origin server
Why Web Caching?
Assume: cache is “close” to client (e.g., in same
network)
smaller response time:
cache “closer” to client
decrease traffic to distant servers
link out of institutional/local ISP network often
bottleneck
origin servers
public Internet
institutional
network 10 Mbps LAN 1.5 Mbps
access link
institutional
Web caches (proxy server)
user sets browser: Web accesses via cache
browser sends all HTTP requests to cache
object in cache: cache returns object
else cache requests object from origin server, then returns object to client
Goal:
satisfy client request without involving origin serverclient
Proxy server
client
HTTP r
equest HTTP request HTTP r
esponse HTTP response
HTTP request HTTP response
origin server origin server
More about Web caching
Cache acts as both client and server
Typically cache is installed by ISP (university, company, residential ISP)
Why Web caching?
Reduce response time for client request.
Reduce traffic on an institution’s access link.
Internet dense with caches:
enables “poor” content
providers to effectively deliver content (but so does P2P file sharing)
Caching example
Assumptions
average object size = 100,000 bits
avg. request rate from institution’s browsers to origin servers = 15/sec
delay from institutional router to any origin server and back to router = 2 sec
Consequences
utilization on LAN = 15%
utilization on access link = 100%
total delay = Internet delay + access delay + LAN delay
= 2 sec + minutes + milliseconds
origin servers
public Internet
institutional
network 10 Mbps LAN 1.5 Mbps
access link
institutional
cache
Caching example (cont)
Possible solution
increase bandwidth of access link to, say, 10 Mbps
Consequences
utilization on LAN = 15%
utilization on access link = 15%
Total delay = Internet delay + access delay + LAN delay
= 2 sec + msecs + msecs
often a costly upgrade
origin servers
public Internet
institutional
network 10 Mbps LAN 10 Mbps
access link
institutional
Caching example (cont)
Install cache
suppose hit rate is .4
Consequence
40% requests will be satisfied almost immediately
60% requests satisfied by origin server
utilization of access link reduced to 60%, resulting in negligible delays (say 10 msec)
total avg delay = Internet delay + access delay + LAN delay = . 6*(2.01) secs + .4*milliseconds
< 1.4 secs
origin servers
public Internet
institutional
network 10 Mbps LAN 1.5 Mbps
access link
institutional
cache
ftp: the file transfer protocol
transfer file to/from remote host
client/server model
client: side that initiates transfer (either to/from remote)
server: remote host
ftp: RFC 959
ftp server: port 21
file transfer FTP server userFTP
interface
clientFTP
local file system
remote file system user
at host
ftp: separate control, data connections
ftp client contacts ftp server at port 21, specifying TCP as
transport protocol
two parallel TCP connections opened:
control: exchange commands, responses between client, server.
“out of band control”
data: file data to/from server
ftp server maintains “state”:
current directory, earlier authentication
client FTP FTP
server
TCP control connection port 21
TCP data connection port 20
ftp commands, responses
Sample commands:
sent as ASCII text over control channel
USER username
PASS password
LIST return list of file in current directory
RETR filename retrieves (gets) file
STOR filename stores (puts) file onto remote host
Sample return codes
status code and phrase (as in http)
331 Username OK, password required
125 data connection already open; transfer starting
425 Can’t open data connection
452 Error writing file
TCP Connection Establishment
Control Connection
Control functions (commands) and reply codes are transferred over the control connection.
Example:-
Commands Reply Codes
USER 331
PASS 230
CWD 250
PWD 257
TYPE I 200
PASV 227
STOR 125
226
-For more commands and Reply codes -Check on RFC 959
http://www.faqs.org/rfcs/rfc959.html
Ethereal Captured Screen For FTP
-Control connection
Works Done here
1. Send username seongyee
2. Response with 331 (PasswordRequired)
3. Send password password4. Response with 230 (Successful Login)
5. Change Directory with CWD6. Response with 250 (CWD command successed)
7. List Current Directory with PWD8. Response with 257 (List Current Directory)
9. Set the data type to I10. Response with 200 (Type Set to I)
11. Set to Passive Mode12. Response with 277(Entering Passive Mode)
13. Download Chap2.ppt by sending STOR Command14. Response with 125(Data Connection Opened) 15. Response with 226(Transfer complete)
Data
Packet Capture For Data Connection
Another TCP connection where 192.168.112.94:3287 to 203.241.187.71:1163
Established For data connection
chapter 04 응용계층
E-mail(
전자메일 ) 컴퓨터 사용자가 동일한 컴퓨터 또는 네트워크에 연결된 다른 컴퓨터 사용자와 보통의 메일 서비스를 전산망 상에서 온라인으로 사용할 수 있는 서비스 .
TCP/IP는 전자메일을 주고받기 위한 SMTP 를 정의한다 .
[그림 4.13] 은 TCP/IP 를 사용한 전자메일의 전체적인 구성도를 보여준다 .
Electronic Mail
Three major components:
user agents
mail servers
simple mail transfer protocol: smtp User Agent
a.k.a. “mail reader”
composing, editing, reading mail m essages
e.g., Eudora, Outlook, elm, Netscap e Messenger
outgoing, incoming messages store d on server
user mailbox outgoing message queue
servermail
agentuser
agentuser
agentuser servermail
agentuser agentuser
servermail
agentuser
SMTP
SMTP
SMTP
Electronic Mail: mail servers
Mail Servers
mailbox contains incoming message s (yet to be read) for user
message queue of outgoing (to be s ent) mail messages
smtp protocol between mail servers to send email messages
client: sending mail server
“server”: receiving mail server
servermail
agentuser
agentuser
agentuser servermail
agentuser servermail
agentuser
SMTP
SMTP
SMTP
chapter 04 응용계층
SMTP 동작
SMTP 동작의 세 가지 단계
1. SMTP
클라이언트와 서버 간의 연결이 확립된다 .2.
전자메일이 연결을 따라 전송된다 .3.
연결이 해제된다 . SMTP Command , Reply
Command From Client To Server
Reply From Server to Client
-Quite similar with FTP
-For more command and reply , refer to RFC 2821
http://rfc.net/rfc2821.html
Electronic Mail: smtp [RFC 821]
uses tcp to reliably transfer email msg from client to server, port 25
direct transfer: sending server to receiving server
three phases of transfer
handshaking (greeting)
transfer of messages
closure
command/response interaction
commands: ASCII text
response: status code and phrase
messages must be in 7-bit ASCII
Sample smtp interaction
S: 220 hamburger.edu C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: <[email protected]>
S: 250 [email protected]... Sender ok C: RCPT TO: <[email protected]>
S: 250 [email protected] ... 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
try smtp interaction for yourself:
telnet servername 25
see 220 reply from server
enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands
above lets you send email without using email client (reader)
Ethereal Captured Screen For SMTP
Works Flow in SMTP
Steps involved
1. Open TCP connection to port 25 of the server 2. Server Response with code 220 (Service Ready) 3. Client send command EHLO (Client authentication) 4. Server Response with code 250 (OK)
5. Client send command AUTH PLAIN
6. Server Response with code 235 (Authentication successes) 7. Sender send command MAIL ( Enter sender name)
8. Server Response with code 250 (OK)
9. Sender send command RCPT TO ( Enter recipient name) 10. Server Response with code 250 (OK)
11. Sender send command DATA (Beginning Transmission) 12. Server Response with code 354 (Start Email Input)
13. Sender send command Message Body (The body of the msg)
14. Server Response with code 250 (OK)
Mail access protocols
SMTP: delivery/storage to receiver’s server
Mail access protocol: retrieval from server
POP: Post Office Protocol [RFC 1939]
authorization (agent <-->server) and download
IMAP: Internet Mail Access Protocol [RFC 1730]
more features (more complex)
manipulation of stored msgs on server
HTTP: Hotmail , Yahoo! Mail, etc.
agentuser
sender’s mail server agentuser
SMTP SMTP POP3 or IMAP
receiver’s mail server
POP3 protocol
authorization phase
client commands:
user: declare username
pass: password
server responses
+OK
-ERR
transaction phase,
client: list: list message numbers
retr: retrieve message by number
dele: delete
quit
C: list S: 1 498 S: 2 912 S: .
C: retr 1
S: <message 1 contents>
S: .
C: dele 1 C: retr 2
S: <message 1 contents>
S: .
S: +OK POP3 server ready C: user alice
S: +OK
C: pass hungry
S: +OK
user successfully logged onchapter 04 응용계층
4.2.5 DNS
DNS (Domain Name Server)
IP 주소는 사람이 기억하기에 어려워 기억하기 쉽게 바꾸어 놓은 것이
도메인 이름이다 .
컴퓨터가 속해 있는 기관이나 국가에 따라서 계층적으로 형성됨
Domain Name 을 IP 주소로 또는 그 반대로 바꿔 주는 것을
DNS(Domain Name System) 이라 한다 .
도메인 네임
– 도메인 네임의 구조 : 호스트 이름 . 소속단체 . 단체성격 . 소속국가
Nslookup 명령
– 가끔씩 컴퓨터가 도메인 주소를 이해 못하는 경우가 발생할 수 있으며 ,
사용자가 특별히 특정 호스트 이름에 해당하는 IP 주소를 알고 싶을 때
사용하는 명령어
DNS: Domain Name System
People: many identifiers:
SSN, name, passport #
Internet hosts, routers:
IP address (32 bit) - used for addressing datagrams
“name”, e.g.,
ww.yahoo.com - used by humans
Q: map between IP addresses and name ?
Domain Name System:
distributed database implemented in hierarchy of many name servers
application-layer protocol host, routers, name servers to
communicate to resolve names (address/name translation)
note: core Internet function, implemented as application- layer protocol
complexity at network’s “edge”
DNS
Why not centralize DNS?
single point of failure
traffic volume
distant centralized database
maintenance doesn’t scale!
DNS services
Hostname to IP address translation
Host aliasing
Canonical and alias names
Mail server aliasing
Load distribution
Replicated Web servers: set of IP addresses for one
canonical name
Root DNS Servers
com DNS servers org DNS servers edu DNS servers poly.edu
DNS servers
umass.edu DNS servers yahoo.com
DNS servers amazon.com DNS servers
pbs.org
DNS servers
Distributed, Hierarchical Database
Client wants IP for www.amazon.com; 1
stapprox:
Client queries a root server to find com DNS server
Client queries com DNS server to get amazon.com DNS server
Client queries amazon.com DNS server to get IP address for
www.amazon.com
DNS: Root name servers
contacted by local name server that can not resolve name
root name server:
contacts authoritative name server if name mapping not known
gets mapping
returns mapping to local name server
13 root name servers worldwide
b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA e NASA Mt View, CA
f Internet Software C. Palo Alto, CA (and 17 other locations)
i Autonomica, Stockholm (plus 3 other locations) k RIPE London (also Amsterdam, Frankfurt)
m WIDE Tokyo a Verisign, Dulles, VA
c Cogent, Herndon, VA (also Los Angeles) d U Maryland College Park, MD
g US DoD Vienna, VA h ARL Aberdeen, MD j Verisign, ( 11 locations)
TLD and Authoritative Servers
Top-level domain (TLD) servers: responsible for com, org, net, edu, etc, and all top-level country domains uk, fr, ca, jp.
Network solutions maintains servers for com TLD
Educause for edu TLD
Authoritative DNS servers: organization’s DNS servers, providing authoritative hostname to IP mappings for organization’s servers (e.g., Web and mail).
Can be maintained by organization or service provider
Local Name Server
Does not strictly belong to hierarchy
Each ISP (residential ISP, company, university) has one.
Also called “default name server”
When a host makes a DNS query, query is sent to its local DNS server
Acts as a proxy, forwards query into hierarchy.
requesting host
root DNS server
local DNS server
dns.poly.edu
1
2 3
4 5
6
authoritative DNS server