Download Unit 1: Application Layer

Document related concepts

AppleTalk wikipedia , lookup

Server Message Block wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

SIP extensions for the IP Multimedia Subsystem wikipedia , lookup

Internet protocol suite wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Remote Desktop Services wikipedia , lookup

Dynamic Host Configuration Protocol wikipedia , lookup

Lag wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Real-Time Messaging Protocol wikipedia , lookup

Hypertext Transfer Protocol wikipedia , lookup

Transcript
Unit 1: Application Layer
Prof. Nalini Mhetre
Unit 1:Application layer… syllabus (04 Hrs)
• OSI Model Block Diagram
• Application layer protocols: Functionality and header formats,
•
•
•
•
•
•
HTTP
FTP
DNS
SMTP
TELNET
DHCP
CN UNIT 1
2
OSI Model: Block Diagram
CN UNIT 1
3
OSI
Model
Layers
CN UNIT 1
4
Why layered architecture?
• Designing of protocol between two different entities.
• Levels of details required may be different.
• Transmitting data to its most fundamental form.
• Identified functions are grouped which serves as a layer
CN UNIT 1
5
Protocol
• A protocol is a set of rules that governs data communication. A
protocol defines :
a. What is communicated ? {syntax}
b. How it is communicated ? {semantics}
c. When it is communicated ?{timings}
CN UNIT 1
6
OSI layers
CN UNIT 1
7
Note to remember:
• Headers are added to the data at layers 6, 5, 4, 3, and 2.
• Trailers are usually added only at layer 2.
CN UNIT 1
8
Summary of layers
CN UNIT 1
9
Internet protocol stack
• application: supporting network
applications
• FTP, SMTP, HTTP
• transport: process-process data transfer
• TCP, UDP
• network: routing of datagrams from
source to destination
• IP, routing protocols
• link: data transfer between neighboring
network elements
• PPP, Ethernet
application
transport
network
link
physical
• physical: bits “on the wire”
CN UNIT 1
10
ISO/OSI reference model
• presentation: allow applications to
interpret meaning of data, e.g.,
encryption, compression, machine-specific
conventions
• session: synchronization, checkpointing,
recovery of data exchange
• Internet stack “missing” these layers!
• these services, if needed, must be
implemented in application
• needed?
CN UNIT 1
application
presentation
session
transport
network
link
physical
11
source
message
segment
M
Ht
M
datagram Hn Ht
M
frame Hl Hn Ht
M
Encapsulation
application
transport
network
link
physical
link
physical
switch
destination
M
Ht
M
Hn Ht
Hl Hn Ht
M
M
application
transport
network
link
physical
Hn Ht
Hl Hn Ht
M
M
network
link
physical
Hn Ht
M
router
CN UNIT 1
12
TCP/IP and OSI model
SCTP
CN UNIT 1
13
Creating a network app
write programs that:
• run on (different) end systems
• communicate over network
• e.g., web server software communicates
with browser software
no need to write software for network-core
devices
• network-core devices do not run user
applications
• applications on end systems allows for
rapid app development, propagation
CN UNIT 1
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
14
Application architectures
possible structure of applications:
• client-server
• peer-to-peer (P2P)
CN UNIT 1
15
Client-server architecture
server:
• always-on host
• permanent IP address
• data centers for scaling
clients:
client/server
• communicate with server
• may be intermittently connected
• may have dynamic IP addresses
• do not communicate directly
with each other
CN UNIT 1
2-16
P2P architecture
• no always-on server
• arbitrary end systems
directly communicate
• peers request service from
other peers, provide service
in return to other peers
• self scalability – new
peers bring new service
capacity, as well as new
service demands
• peers are intermittently
connected and change IP
addresses
• complex management
peer-peer
CN UNIT 1
2-17
Processes communicating
process:
program running within a host
clients, servers
client process: process
• within same host, two processes
communicate using inter-process
communication (defined by OS)
• processes in different hosts
communicate by exchanging
messages
server process: process
that initiates
communication
that waits to be contacted

CN UNIT 1
note: applications with P2P
architectures have client
processes & server
processes
18
Sockets
• 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
application
process
socket
application
process
transport
transport
network
network
link
Internet
link
controlled by
app developer
controlled
by OS
physical
physical
CN UNIT 1
2-19
Addressing processes
• identifier includes both IP
address and port numbers
associated with process on
host.
• example port numbers:
• to receive messages, process must
have identifier
• host device has unique 32-bit IP
address (version 4)
• Q: does IP address of host on which
process runs suffice for identifying
the process?
• HTTP server: 80
• mail server: 25
 A: no, many processes
can be running on same
host
• to send HTTP message to
gaia.cs.umass.edu web
server:
• IP address: 128.119.245.12
• port number: 80
• more shortly…
CN UNIT 1
20
App-layer protocol defines
• types of messages
exchanged,
• e.g., request, response
• message syntax:
• what fields in messages
& how fields are defined
• message semantics
• meaning of information
in fields
• rules for when and how
processes send & respond to
messages
CN UNIT 1
open protocols:
• defined in RFCs
• allows for interoperability
• e.g., HTTP, SMTP
proprietary protocols:
• e.g., Skype
21
Web and HTTP
First, a review…
• web page consists of objects
• object can be HTML file, JPEG image, Java applet, audio file,…
• web page consists of base HTML-file which includes several referenced
objects
• each object is addressable by a URL, e.g.,
www.someschool.edu/someDept/pic.gif
path name
host name
CN UNIT 1
23
HTTP overview
HTTP: hypertext transfer
protocol
• Web’s application layer
protocol
• client/server model
• client: browser that
requests, receives,
(using HTTP protocol)
and “displays” Web
objects
• server: Web server
sends (using HTTP
protocol) objects in
response to requests
PC running
Firefox browser
server
running
Apache Web
server
iphone running
Safari browser
CN UNIT 1
24
HTTP overview (continued)
uses TCP:
HTTP is “stateless”
• client initiates TCP
connection (creates socket)
to server, port 80
• server accepts TCP
connection from client
• HTTP messages (applicationlayer protocol messages)
exchanged between
browser (HTTP client) and
Web server (HTTP server)
• TCP connection closed
• server maintains no
information about
past client requests
CN UNIT 1
25
HTTP connections
non-persistent HTTP
• at most one object sent over TCP
connection
• connection then closed
• downloading multiple objects
required multiple connections
CN UNIT 1
persistent HTTP
• multiple objects can be
sent over single TCP
connection between
client, server
26
Non-persistent HTTP
suppose user enters URL:
www.someSchool.edu/someDepartment/home.index
1a. HTTP client initiates TCP
connection to HTTP server
(process) at
www.someSchool.edu on port 80
2. HTTP client sends HTTP request
message (containing URL) into
TCP connection socket.
Message indicates that client
wants object
someDepartment/home.index
(contains text,
references to 10
jpeg images)
1b. HTTP server at host
www.someSchool.edu waiting
for TCP connection at port 80.
“accepts” connection, notifying
client
3. HTTP server receives request
message, forms response
message containing requested
object, and sends message into
its socket
time
CN UNIT 1
27
Non-persistent HTTP (cont.)
4. HTTP server closes TCP
connection.
5. HTTP client receives response
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects
time
6. Steps 1-5 repeated for each of
10 jpeg objects
CN UNIT 1
28
Non-persistent HTTP: response time
RTT (definition): time for a small
packet to travel from client to
server and back
HTTP 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
• non-persistent HTTP response
time =
2RTT+ file transmission
time
initiate TCP
connection
CN UNIT 1
RTT
request
file
time to
transmit
file
RTT
file
received
time
time
2-29
Persistent HTTP
non-persistent 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
• client sends requests as
soon as it encounters a
referenced object
• as little as one RTT for all
the referenced objects
CN UNIT 1
30
HTTP request message
• two types of HTTP messages: request, response
• HTTP request message:
• ASCII (human-readable format)
request line
(GET, POST,
HEAD commands)
header
lines
carriage return,
line feed at start
of line indicates
end of header lines
carriage return character
line-feed character
GET /index.html HTTP/1.1\r\n
Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
Keep-Alive: 115\r\n
Connection: keep-alive\r\n
\r\n
CN UNIT 1
31
HTTP request message: general format
method
sp
URL
header field name
sp
version
value
cr
cr
value
cr
request
line
header
lines
~
~
header field name
lf
lf
~
~
~
~
cr
lf
lf
entity body
CN UNIT 1
~
~
body
32
Uploading form input
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
CN UNIT 1
33
Method types
HTTP/1.0:
HTTP/1.1:
• GET
• POST
• HEAD
• asks server to leave
requested object out of
response
• GET, POST, HEAD
• PUT
• uploads file in entity
body to path specified
in URL field
• DELETE
• deletes file specified in
the URL field
CN UNIT 1
34
HTTP request message: general format
method
sp
URL
header field name
sp
version
value
cr
cr
value
cr
request
line
header
lines
~
~
header field name
lf
lf
~
~
~
~
cr
lf
lf
entity body
CN UNIT 1
~
~
body
35
HTTP response message
status line
(protocol
status code
status phrase)
header
lines
data, e.g.,
requested
HTML file
HTTP/1.1 200 OK\r\n
Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\n
ETag: "17dc6-a5c-bf716880"\r\n
Accept-Ranges: bytes\r\n
Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-88591\r\n
\r\n
data data data data data ...
CN UNIT 1
36
HTTP response message: general format
CN UNIT 1
37
HTTP response status codes
status code appears in 1st line in server-toclient response message.
 some sample codes:

200 OK
• request succeeded, requested object later in this msg
301 Moved Permanently
• requested object moved, new location specified later in this msg
(Location:)
400 Bad Request
• request msg not understood by server
404 Not Found
• requested document not found on this server
505 HTTP Version Not Supported
CN UNIT 1
38
FTP: the file transfer protocol
FTP
user
interface
file transfer
FTP
client
user
at host


local file
system
FTP
server
remote file
system
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
CN UNIT 1
39
FTP: separate control, data connections
• FTP client contacts FTP server at
port 21, using TCP
• client authorized over control
connection
• client browses remote directory,
sends commands over control
connection
• when server receives file transfer
command, server opens 2nd TCP
data connection (for file) to client
• after transferring one file, server
closes data connection
TCP control connection,
server port 21
FTP
client
TCP data connection,
server port 20
FTP
server
server
opens another TCP data
connection to transfer another file
control connection: “out of band”
FTP server maintains “state”:
current directory, earlier
authentication
CN UNIT 1
40
Commands ,which are sent from FTP client control process ,are in the form
of ASCII uppercase. Commands can be divided in to six categories:
• access commands
• file management commands
• data formatting commands
• defining commands
• file transferring commands
• miscellaneous commands
CN UNIT 1
41
1.Access commands:
USER-user Information, PASS-password, ACCT-account information, REINreinitialize, QUIT-log out, ABOR-abort previous command
2. File Mgmt commands:
CWD-change to another directory, CDUP-change to parent directory, LIST-list
subdirectories or files, MKD-create new directory, PWD, DELE, RNFR-identify
the file to be renamed, RNTO-rename the file, SMNT-mount the file system
3. Data formatting commands:
TYPE-file type, STRU-structure, MODE-transmission mode.
CN UNIT 1
42
4. Port defining commands :
PORT-client chooses a port, PASV-server chooses a port
5. File transfer commands:
RETR-retrieve remote file, STOR-store to remote server, APPE-append mode,
STOU-store uniquely
6.Miscellaneous commands:
HELP, NOOP-check if server is alive, SYST-OS of server
CN UNIT 1
43
Response: Every FTP command generates at least one response. A
response has two parts. 1.a three digit no. followed by text. We
represent numeric part as xyz. The meaning of each will be as follows.
First Digit:
1yz:positive preliminary reply – Action has started. Server sends another
reply before accepting 2nd command.
2yz:Positive completion reply – Action completed
3yz:Positive intermediate reply – Command accepted but further
information required.
4yz: transient negative completion reply - Action did not take place but the
error is temporary.
5yz: Permanent negative reply- command can not be completed.
CN UNIT 1
44
Second digit:
x0z: (syntax) ,
x1z:(information) ,
x2z: (connection) ,
x3z: (authentication & accounting),
x5z: (file system)
Third digit: Provides additional information.
CN UNIT 1
45
FTP commands, responses
sample commands:
sample return codes
sent as ASCII text over control
channel:
• USER username
• PASS password
status code and phrase (as in HTTP)
• LIST return list of file in current
directory
• 125 data connection already open;
transfer starting
• RETR filename retrieves (gets) file
• 425 Can’t open data connection
• 452 Error writing file
• 331 Username OK, password
required
• STOR filename stores (puts) file
onto remote host
CN UNIT 1
46
DNS
CN UNIT 1
47
DNS: domain name system
people: many identifiers:
• SSN, name, passport #
Internet hosts, routers:
• IP address (32 bit) used for addressing
datagrams
• “name”, e.g.,
www.yahoo.com - used
by humans
Q: how to map between IP
address and name, and
vice versa ?
Domain Name System:
• distributed database
implemented in hierarchy of
many name servers
• application-layer protocol:
hosts, name servers
communicate to resolve names
(address/name translation)
• note: core Internet function,
implemented as applicationlayer protocol
• complexity at network’s
“edge”
CN UNIT 1
48
DNS: services, structure
DNS services
why not centralize DNS?
• hostname to IP address
translation
• host aliasing
•
•
•
•
• canonical, alias names
single point of failure
traffic volume
distant centralized database
maintenance
• mail server aliasing
• load distribution
• replicated Web servers:
many IP addresses
correspond to one
name
CN UNIT 1
A: doesn’t scale!
49
DNS: a distributed, hierarchical database
Root DNS Servers
…
com DNS servers
yahoo.com
amazon.com
DNS servers DNS servers
…
org DNS servers
pbs.org
DNS servers
edu DNS servers
poly.edu
umass.edu
DNS serversDNS servers
client wants IP for www.amazon.com; 1st approx:
• client queries 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
CN UNIT 1
50
TLD, authoritative, local DNS servers
top-level domain (TLD) servers:
• responsible for com, org, net, edu, aero, jobs, museums, and all top-level
country domains, e.g.: uk, fr, ca, jp
• Network Solutions maintains servers for .com TLD
• Educause for .edu TLD
authoritative DNS servers:
• organization’s own DNS server(s), providing authoritative hostname to IP
mappings for organization’s named hosts
• can be maintained by organization or service provider
CN UNIT 1
51
Local DNS name server
• does not strictly belong to hierarchy
• each ISP (residential ISP, company, university) has one
• also called “default name server”
• when host makes DNS query, query is sent to its local DNS server
• has local cache of recent name-to-address translation pairs (but may be out of
date!)
• acts as proxy, forwards query into hierarchy
CN UNIT 1
52
DNS name
resolution example
root DNS server
2
• host at cis.poly.edu
wants IP address for
gaia.cs.umass.edu
iterated query:


contacted server
replies with name of
server to contact
“I don’t know this
name, but ask this
server”
3
TLD DNS server
4
5
local DNS server
dns.poly.edu
1
8
7
6
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu
gaia.cs.umass.edu
CN UNIT 1
53
DNS name
resolution example
root DNS server
3
2
7
recursive query:


puts burden of name
resolution on
contacted name
server
heavy load at upper
levels of hierarchy?
6
TLD DNS
server
local DNS server
dns.poly.edu
1
5
4
8
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu
gaia.cs.umass.edu
CN UNIT 1
54
DNS protocol, messages
• query and reply messages, both with same message format
msg header


identification: 16 bit # for
query, reply to query uses
same #
flags:
 query or reply
 recursion desired
 recursion available
 reply is authoritative
2 bytes
2 bytes
identification
flags
# questions
# answer RRs
# authority RRs
# additional RRs
questions (variable # of questions)
answers (variable # of RRs)
authority (variable # of RRs)
additional info (variable # of RRs)
CN UNIT 1
58
DNS protocol, messages
name, type fields
for a query
RRs in response
to query
records for
authoritative servers
additional “helpful”
info that may be used
2 bytes
2 bytes
identification
flags
# questions
# answer RRs
# authority RRs
# additional RRs
questions (variable # of questions)
answers (variable # of RRs)
authority (variable # of RRs)
additional info (variable # of RRs)
CN UNIT 1
59
Electronic Mail
• SMTP
• POP3
• IMAP
CN UNIT 1
62
outgoing
message queue
Electronic Mail
user mailbox
user
agent
Three major components:
• user agents
mail
server
• mail servers
SMTP
• simple mail transfer protocol: SMTP
1. User Agent
user
agent
SMTP
• a.k.a. “mail reader”
mail
server
user
agent
SMTP
• composing, editing, reading mail messages
user
agent
mail
server
• e.g., Eudora, Outlook, elm, Mozilla
Thunderbird
user
agent
• outgoing, incoming messages stored on server
user
agent
CN UNIT 1
63
Electronic Mail: mail servers
user
agent
2.Mail Servers
• mailbox contains incoming messages for user
mail
server
• message queue of outgoing (to be sent) mail
messages
user
agent
SMTP
3. SMTP protocol between mail servers to transmit
email messages
• “Client”: sending mail server
• “server”: receiving mail server
SMTP
mail
server
user
agent
SMTP
user
agent
mail
server
user
agent
user
agent
CN UNIT 1
64
Scenario: Alice sends message to Bob
1) Alice uses UA to compose message and
“to” [email protected]
4) SMTP client sends Alice’s message
over the TCP connection
2) Alice’s UA sends message to her mail
server; message placed in message
queue
5) Bob’s mail server places the
message in Bob’s mailbox
6) Bob invokes his user agent to read
message
3) Client side of SMTP opens TCP
connection with Bob’s mail server
mail
server
1
user
agent
2
mail
3
server
4
CN UNIT 1
5
6
user
agent
65
Electronic Mail: SMTP [RFC 2821]
• uses TCP to reliably transfer email message 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
CN UNIT 1
66
SMTP: final words
• SMTP uses persistent connections
Comparison with HTTP:
• SMTP requires message (header & body) to
be in 7-bit ASCII
• HTTP: pull
• SMTP server uses CRLF.CRLF to determine
end of message
• SMTP: push
• both have ASCII command/response
interaction, status codes
• HTTP: each object encapsulated in its own
response msg
• SMTP: multiple objects sent in multipart msg
CN UNIT 1
69
Mail message format
SMTP: protocol for exchanging email msgs
header
RFC 822: std for text message format:
• header lines, e.g.,
• To:
• From:
• Subject:
different from SMTP commands!
blank
line
body
• body
• the “message”, ASCII characters only
CN UNIT 1
70
Mail access protocols
SMTP
SMTP
access
protocol
user
agent
sender’s mail
server
user
agent
receiver’s mail
server
• SMTP: transfer/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: gmail, Hotmail, Yahoo! Mail, etc.
CN UNIT 1
71
POP3 protocol
S:
C:
S:
C:
S:
authorization phase
• client commands:
• user: declare username
• pass: password
• server responses
• +OK
• -ERR
+OK POP3 server ready
user bob
+OK
pass hungry
+OK user successfully logged
on
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 2 contents>
S: .
C: dele 2
C: quit
S: +OK POP3 server signing off
transaction phase, client:
• list: list message numbers
• retr: retrieve message by
number
• dele: delete
• quit
CN UNIT 1
72
POP3 (more) and IMAP
More about POP3
• Previous example uses
“download and delete”
mode.
• Bob cannot re-read e-mail
if he changes client
• “Download-and-keep”:
copies of messages on
different clients
• POP3 is stateless across
sessions
IMAP
• Keep all messages in one
place: the server
• Allows user to organize
messages in folders
• IMAP keeps user state
across sessions:
• names of folders and
mappings between message
IDs and folder name
CN UNIT 1
73
Dynamic Host Configuration Protocol (DHCP)
• Module about dynamic assignment of IP addresses with DHCP.
CN UNIT 1
74
Dynamic Assignment of IP addresses
• Dynamic assignment of IP addresses is desirable for several reasons:
• IP addresses are assigned on-demand
• Avoid manual IP configuration
• Support mobility of laptops
• Three Protocols:
• RARP (until 1985, no longer used)
• BOOTP (1985-1993)
• DHCP (since 1993)
• Only DHCP is widely used today.
CN UNIT 1
75
Solutions for dynamic assignment of IP addresses
• Reverse Address Resolution Protocol (RARP)
• RARP is no longer used
• Works similar to ARP
• Broadcast a request for the IP address associated with a
given MAC address
• RARP server responds with an IP address
• Only assigns IP address (not the default router and subnet
mask)
IP address
(32 bit)
ARP
RARP
CN UNIT 1
Ethernet MAC
address
(48 bit)
2-76
BOOTP(BOOTstrap Protocol )
 Not only assigns IP address, but also default router, network mask,
etc.
• Host can configure its IP parameters at boot time.
• 3 services.
• IP address assignment.
• Detection of the IP address for a serving machine.
• The name of a file to be loaded and executed by the client machine (boot file
name)
• Sent as UDP messages (UDP Port 67 (server) and 68 (host))
• Use limited broadcast address (255.255.255.255):
• These addresses are never forwarded
CN UNIT 1
77
BOOTP Interaction
Argon
128.143.137.144
00:a0:24:71:e4:44
(a)
Argon
00:a0:24:71:e4:44
(b)
DHCP Server
BOOTP Response:
IP address: 128.143.137.144
Server IP address: 128.143.137.100
Boot file name: filename
BOOTP Server
BOOTP Request
00:a0:24:71:e4:44
Sent to 255.255.255.255
(c)
• BOOTP can be used for
downloading memory
image for diskless
workstations
• Assignment of IP
addresses to hosts is static
CN UNIT 1
78
DHCP
• Dynamic Host Configuration Protocol (DHCP)
• Designed in 1993
• An extension of BOOTP (Many similarities to BOOTP)
• Same port numbers as BOOTP
• Extensions:
• Supports temporary allocation (“leases”) of IP addresses
• DHCP client can acquire all IP configuration parameters
• DHCP is the preferred mechanism for dynamic assignment of IP addresses
• DHCP can interoperate with BOOTP clients.
CN UNIT 1
79
DHCP Interaction (simplified)
Argon
128.143.137.144
00:a0:24:71:e4:44
DHCP Server
DHCP Response:
IP address: 128.143.137.144
Default gateway: 128.143.137.1
Netmask: 255.255.0.0
CN UNIT 1
80
BOOTP/DHCP Message Format
OpCode
Hardware Type
Number of Seconds
Hardware Address
Hop Count
Length
Unused (in BOOTP)
Flags (in DHCP)
Transaction ID
Client IP address
Your IP address
Server IP address
Gateway IP address
Client hardware address (16 bytes)
Server host name (64 bytes)
Boot file name (128 bytes)
Options
CN UNIT 1
(There are >100 different options)
81
BOOTP/DHCP
• OpCode: 1 (Request), 2(Reply) Note: DHCP message type is sent in an option
• Hardware Type: 1 (for Ethernet)
• Hardware address length: 6 (for Ethernet)
• Hop count: set to 0 by client
• Transaction ID: Integer (used to match reply to response)
• Seconds: number of seconds since the client started to boot
• Client IP address, Your IP address, server IP address, Gateway IP address, client hardware address,
server host name, boot file name:
client fills in the information that it has, leaves rest blank
CN UNIT 1
82
DHCP Message Type
• Message type is sent as an option.
Value
CN UNIT 1
Message Type
1
DHCPDISCOVER
2
DHCPOFFER
3
DHCPREQUEST
4
DHCPDECLINE
5
DHCPACK
6
DHCPNAK
7
DHCPRELEASE
8
DHCPINFORM
2-83
Other options (selection)
• Other DHCP information that is sent as an option:
Subnet Mask, Name Server, Hostname, Domain Name, Forward On/Off, Default IP TTL,
Broadcast Address, Static Route, Ethernet Encapsulation, X Window Manager, X Window
Font, DHCP Msg Type, DHCP Renewal Time, DHCP Rebinding, Time SMTP-Server, SMTPServer, Client FQDN, Printer Name, …
CN UNIT 1
84
DHCP Operation
DHCP Client
00:a0:24:71:e4:44
DHCP Server
DHCPDISCOVER
• DCHP DISCOVER
Sent to 255.255.255.255
DHCP Server
DHCP Client
00:a0:24:71:e4:44
DHCPOFFER
DHCP Server
DHCPOFFER
DCHP OFFER
DHCP Server
CN UNIT 1
85
DHCP Operation
DHCP Client
00:a0:24:71:e4:44
DHCP Server
DHCPREQUEST
DCHPREQUEST
DHCPACK
At this time, the DHCP
client can start to use the IP
address
Renewing a Lease
(sent when 50% of lease has
expired)
If DHCP server sends
DHCPNACK, then address
is released.
DHCP Server
DHCP Client
00:a0:24:71:e4:44
DHCP Server
DHCPREQUEST
DHCPACK
DHCP Server
CN UNIT 1
86
DHCP Operation
DHCP Client
00:a0:24:71:e4:44
DHCP Server
DHCPRELEASE
DCHP RELEASE
At this time, the DHCP
client has released the IP
address
DHCP Server
CN UNIT 1
87
The TELNET Protocol
Reference: RFC 854
TELNET vs. telnet
• TELNET is a protocol that provides “a general, bi-
directional, eight-bit byte oriented
communications facility”.
• telnet is a program that supports the TELNET
protocol over TCP.
• Many application protocols are built upon the
TELNET protocol.
CN UNIT 1
89
The TELNET Protocol
• TCP connection
• data and control over the same connection.
• Network Virtual Terminal [NVT]
• Negotiated options
• One computer can connect to another to use its
services
• Connecting Privileges:
guest - usually logins are not required
full - requires username and password.
CN UNIT 1
90
Network Virtual Terminal
Server
Process
NVT
NVT
TCP
TCP
CN UNIT 1
91
Network Virtual Terminal
• Intermediate representation of a generic terminal.
• Provides a standard language for communication of terminal control
functions.
CN UNIT 1
92
Negotiated Options
• All NVTs support a minimal set of capabilities.
• Some terminals have more capabilities than the minimal set.
• The 2 endpoints negotiate a set of mutually acceptable options
(character set, echo mode, etc).
CN UNIT 1
93
Negotiated Options [Cntd.]
• The set of options is not part of the TELNET protocol, so that new
terminal features can be incorporated without changing the TELNET
protocol.
• The protocol for requesting optional features is well defined and
includes rules for eliminating possible negotiation “loops”.
CN UNIT 1
94
Option examples
• Line mode vs. character mode
• echo modes
• character set (EBCDIC vs. ASCII)
CN UNIT 1
95
Control Functions
• TELNET includes support for a series of control functions commonly
supported by servers.
• This provides a uniform mechanism for communication of (the
supported) control functions.
CN UNIT 1
96
Control Functions
• Interrupt Process (IP)
• suspend/abort process.
• Abort Output (AO)
• process can complete, but send no more output to user’s terminal.
• Are You There (AYT)
• check to see if system is still running.
CN UNIT 1
97
More Control Functions
• Erase Character (EC)
• delete last character sent
• typically used to edit keyboard input.
• Erase Line (EL)
• delete all input in current line.
CN UNIT 1
98
Command Structure
• All TELNET commands and data flow through the same TCP
connection.
• Commands start with a special character called the Interpret as
Command (IAC) escape character
• The IAC code is 255.
• If a 255 is sent as data - it must be followed by another 255.
CN UNIT 1
99
Looking for Commands
• Each receiver must look at each byte that arrives and look for IAC.
• If IAC is found and the next byte is IAC - a single byte is presented to
the application/terminal (a 255).
• If IAC is followed by any other code - the TELNET layer interprets this
as a command.
CN UNIT 1
100
Command Codes
•
•
•
•
•
•
•
•
•
•
IP
AO
AYT
EC
EL
WILL
WON’T
DO
DON’T
IAC
243
244
245
246
247
251
252
253
254
255
CN UNIT 1
101
Playing with TELNET
• You can use the telnet program to play with the TELNET protocol.
• telnet is a generic TCP client.
• Sends whatever you type to the TCP socket.
• Prints whatever comes back through the TCP socket.
• Useful for testing TCP servers (ASCII based protocols).
CN UNIT 1
102
Some TCP Servers you can play with
• Many Unix systems have these servers running (by default):
•
•
•
•
echo
discard
daytime
chargen
port 7
port 9
port 13
port 19
CN UNIT 1
103
telnet hostname port
> telnet rcs.rpi.edu 7
Trying 128.113.113.33...
Connected to cortez.sss.rpi.edu
(128.113.113.33).
Escape character is '^]'.
Hi dave
Hi dave
stop it
stop it
^]
telnet> quit
Connection closed.
CN UNIT 1
104
telnet vs. TCP
• Not all TCP servers talk TELNET (most don't)
• You can use the telnet program to play with these
servers, but the fancy commands won't do anything.
• type ^], then "help" for a list of fancy TELNET stuff you can do in
telnet.
CN UNIT 1
105
END
CN UNIT 1
106