Telnet and E-mail Protocols

advertisement
Lecture 11 Overview
Router Architecture Overview
• Two key router functions:
– run routing algorithms/protocol (RIP, OSPF, BGP)
– forwarding datagrams from incoming to outgoing link
CPE 401/601 Lecture 11 : Router Architectures
2
Input Port Functions
• Goal: complete input port processing at ‘line
speed’
Physical layer:
bit-level reception
Data link layer:
e.g., Ethernet
CPE 401/601 Lecture 11 : Router Architectures
Network layer:
Routing & forwarding
3
Input Port Queuing
• Queuing when datagrams arrive faster than
forwarding rate into switch fabric
• queuing delay and loss due to input buffer overflow!
• Head-of-the-Line (HOL) blocking: queued datagram
at front of queue prevents others in queue from
moving forward
CPE 401/601 Lecture 11 : Router Architectures
4
Three types of switching fabrics
CPE 401/601 Lecture 11 : Router Architectures
5
Output Ports
• Buffering required when datagrams arrive
from fabric faster than the transmission rate
• Queuing: Scheduling discipline chooses
among queued datagrams for transmission
CPE 401/601 Lecture 11 : Router Architectures
6
How much buffering?
• RFC 3439 rule of thumb:
– buffering equal to typical RTT (say 250 msec)
times link capacity C
• e.g., C = 10 Gps link:
– 2.5 Gbit buffer
• Recent recommendation:
– with N flows, buffering equal to
CPE 401/601 Lecture 11 : Router Architectures
RTT . C
N
7
Bridge Software
• A bridge connects networks and forwards
frames from one network to another.
PORTS
A
B
E
F
BRIDGE
C
D
CPE 401/601 Lecture 11 : Bridges
G
H
8
Selective Forwarding
• If A sends a frame to E
– the frame must be forwarded by the bridge
• If A sends a frame to B
– there is no reason to forward the frame
A
B
E
F
BRIDGE
C
D
CPE 401/601 Lecture 11 : Bridges
G
H
9
Bridge Database
• The bridge needs a database that contains
information about which hosts are on which
network.
Hard to add
new computers
• The realistic options are:
– The system administrator can create and maintain
the database.
– The bridge can acquire the database on the fly.
Some loss of efficiency
CPE 401/601 Lecture 11 : Bridges
10
Learning the host mapping
• Bridge forwards packets whose destination
network is unknown
• Every time bridge forwards a packet it can
record the network on which the sender is
• Each host mapping expires when it is unused
for a “long” period of time
• New hosts can be added at any time
• Requires no setup information from humans
• A host can be moved to another network
CPE 401/601 Lecture 11 : Bridges
11
What is the problem ?
A
0
Bridge 1
1
D
B
E
C
F
0
CPE 401/601 Lecture 11 : Bridges
Bridge 2
1
12
Possible Solutions
• Forget about smart bridges
• Tell customers to avoid topologies that include
loops
– design bridges so that they detect loops and
scream at the customer
• Design bridges that prune the network
topology into something with no loops.
CPE 401/601 Lecture 11 : Bridges
13
Spanning Tree Creation
• The bridges must communicate!
– They send configuration bridge protocol data units
(BPDUs)
– Multicast: special data link address
• Each bridge has a unique ID
• Use an algorithm to construct a spanning tree
based on local messages
CPE 401/601 Lecture 11 : Bridges
14
Spanning Tree
B
B
B
B
B
B
B
Prune
B
B
B
CPE 401/601 Lecture 11 : Bridges
B
B
bridge
B
network
15
Lecture 12
Telnet and E-mail Protocols
CPE 401 / 601
Computer Network Systems
slides
modified
from
Dave
Hollinger
slides
are are
modified
from
Dave
Hollinger
TELNET
• TELNET is a protocol that provides
– general,
– bi-directional,
– eight-bit byte oriented communications
• Over TCP connection
– data and control over the same connection
• Many application protocols are built upon the
TELNET protocol
• Used to test HTTP, FTP, SMTP, POP3, IRC, etc.
CPE 401/601 Lecture 12 : TELNET protocol
17
Network Virtual Terminal
• intermediate representation of a generic
terminal
• provides a standard language for
communication of terminal control functions
Server
Process
NVT
NVT
TCP
TCP
CPE 401/601 Lecture 12 : TELNET protocol
18
Negotiated Options
• All NVTs support a minimal set of capabilities
– Some terminals have more capabilities
• Set of options is not part of TELNET protocol
– so that new terminal features can be incorporated
without changing the TELNET protocol
• Two endpoints negotiate a set of mutually
acceptable options
– Line mode vs. character mode
– echo modes
– character set (EBCDIC vs. ASCII)
CPE 401/601 Lecture 12 : TELNET protocol
19
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
CPE 401/601 Lecture 12 : TELNET protocol
20
Control Functions
• Interrupt Process (IP)
– suspend/abort process
• Abort Output (AO)
– send no more output to user’s terminal
• Are You There (AYT)
– check to see if system is still running
• Erase Character (EC)
– delete last character sent
• Erase Line (EL)
– delete all input in current line
CPE 401/601 Lecture 12 : TELNET protocol
21
Command Structure
• Commands start with a special character
called the Interpret as Command escape
character
– The IAC code is 255
– If a 255 is sent as data, it must be followed by
another 255
• If IAC is found and the next byte is IAC
– a single byte is presented to application/terminal
• If IAC is followed by any other code
– the TELNET layer interprets this as a command
CPE 401/601 Lecture 12 : TELNET protocol
22
Playing with TELNET
• 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
• Many Unix systems have these servers running
(by default):
– echo
– daytime
port 7
port 13
CPE 401/601 Lecture 12 : TELNET protocol
discard
chargen
port 9
port 19
23
telnet hostname port
> telnet amele-2.cse.unr.edu 7
Trying 134.197.40.246...
Connected to amele-2.cse.unr.edu
(134.197.40.246).
Escape character is '^]'.
Hi mehmet
Hi mehmet
stop it
stop it
^]
telnet> quit
Connection closed.
CPE 401/601 Lecture 12 : TELNET protocol
24
E-mail Protocols
Email
• SMTP - Simple Mail Transfer Protocol
– 1982 (RFC 821, 5321, …)
• POP - Post Office Protocol (v3)
– 1984 (RFC 1939 , …)
• IMAP (v4)
– 1986 (RFC 1730, 3501 , …)
• MIME extensions
– 1992 (RFCs 1521, 1522 , …)
CPE 401/601 Lecture 12 : E-mail protocols
26
A Typical Mail Environment
Internet
Interactive Mail
Access Protocol
SMTP
Mail
Server
Mail Server
IMAP
IMAP
store
POP
Store
Mail
Client
SMTP
POP
SMTP
Mail
Client
CPE 401/601 Lecture 12 : E-mail protocols
27
Terminology
• User Agent
– end-user mail program
• Message Transfer Agent
– responsible for communicating with remote hosts
and transmitting/receiving email
• both a client and server
• Mail Exchanger
– host that takes care of email for a domain
CPE 401/601 Lecture 12 : E-mail protocols
28
SMTP
• Used to exchange mail messages between
mail servers (Message Transfer Agents)
MTA
SMTP
MTA
SMTP
MTA
File
System
UA
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
UA
29
SMTP Protocol
• SMTP sender is the client
• SMTP receiver is the server
• Alternating dialogue:
– client sends command and server responds with
command status message
– Order of the commands is important!
– Status messages include
• ASCII encoded numeric status code (like HTTP,FTP) and
• text string
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
30
SMTP Commands
• HELO
– identifies sender
• MAIL FROM:
– starts mail transaction and identifies mail originator
• RCPT TO:
– identifies individual recipient
– there may be multiple RCPT TO: commands
• DATA
– sender ready to transmit a series of lines of text, each ends
with ‘\r\n’
– A line containing only a period ‘.’ indicates end of the data
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
31
Data Format
• ASCII only
– must convert binary to an ASCII representation to
send via email
• What if we want to send a line containing only
a period?
– Sender prepends a period to any line staring with
a period (in the message)
– Receiver strips the leading period in any line that
starts with a period and has more stuff
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
32
Message Progress
TCP Connection
Establishment
TCP Connection
Termination
Typical Exchange
> telnet mail.cse.unr.edu 25
Trying 134.197.40.1...
Connected to mail.cse.unr.edu.
Escape character is '^]'.
220 ponderosa.cse.unr.edu ESMTP Postfix
HELO cse.unr.edu
250 ponderosa.cse.unr.edu
MAIL FROM: bill@microsoft.com
250 2.1.0 Ok
RCPT TO: mgunes
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Hi Mehmet
.
250 2.0.0 Ok: queued as C0D242F8D9
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
34
Leading Period
DATA
354 Enter mail, end with "." on a line by itself
Hi Mehmet - this message is a test of SMTP
..
..foo
..
.
250 2.0.0 Ok: queued as VAA0771
Resulting Message:
Hi Mehmet - this message is a test of SMTP
.
.foo
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
35
Reply Codes
• Contain a Lot of Information
The first digit
indicates
success, failure,
or incomplete
354
The third digit
is the specific
message for that
category
The second digit is the category
of error message
• Only the reply codes count
– Other information in a reply is purely for humans
Other SMTP Commands
• VRFY
– confirm that a name is a valid recipient
• EXPN
– expand an alias (group email address)
• TURN
– switch roles (sender <=> receiver)
• NOOP
– send back a positive reply code
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
37
Other SMTP Commands
• SOML
– Send Or Mail
• if recipient is logged in, display message on terminal,
otherwise email
• SAML
– Send and Mail
• RSET
– abort current transaction
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
38
SMTP Extensions (EHLO)
• A mailer supporting extensions uses EHLO
instead of HELO in the greeting
$ telnet mail.unr.edu 25
Trying 134.197.1.112...
220 smtp.unr.edu ESMTP Postfix
EHLO
250-smtp.unr.edu
250-PIPELINING
250-SIZE 30720000
250-VRFY
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DNS
TCP / IP model
A mailer that supports
extensions responds with a
list of which ones it can do
39
Mail Headers
• Email messages contain many headers
– some headers are created by the UA
– some are automatically added by the MTA
• Every MTA adds (at least) a “Received:”
header
• Some of the headers are parsed by
intermediate MTAs
– but the message content is ignored and passed on
transparently
CPE 401/601 Lecture 12 : E-mail protocols - SMTP
40
Multipurpose Internet Mail Extensions
• Defines extensions to support binary
attachments of arbitrary format
– Images, Audio, Video and multi-media messages
– Text having unlimited line length or overall length
– Multiple objects in a single message
– Character sets other than ASCII
– Multi-font messages
• Requires more capable UAs to interpret
messages
CPE 401/601 Lecture 12 : E-mail protocols - MIME
41
A sample MIME message
From: trumbo@Opus1.COM (Jan Trumbo)
Subject: small message with Word attachment
To: trumbo@Opus1.COM
MIME-version: 1.0
Content-type: MULTIPART/MIXED; BOUNDARY="Boundary_[ID_nf99lkyavAuSoClF/HeK0Q]"
--Boundary_[ID_nf99lkyavAuSoClF/HeK0Q]
Content-type: text/plain; charset=us-ascii
Joel, attached is a Word document.
- Jan
--Boundary_[ID_nf99lkyavAuSoClF/HeK0Q]
This identical boundary
marker separates the
parts of the mail message
Date: Thu, 19 Sep 1996 16:49:52 -0700
Content-type: application/mac-binhex40; name=tiny_text_Word_doc.doc
Content-disposition: attachment; filename=tiny_text_Word_doc.doc
<Word document and more stuff below here>
CPE 401/601 Lecture 12 : E-mail protocols - MIME
42
Pulling Emails
• Offline (POP3 model)
– Client connects to server and pulls all email down to client
– Everything is stored on the client
• Online (Original IMAP model)
– Client connects to server for every transaction
– Everything is stored on the server
• Disconnected (Later IMAP model)
– Client and server share storage burden
– Server is always authoritative and client must synchronize
to server
CPE 401/601 Lecture 12 : E-mail protocols
43
POP – Post Office Protocol
• Used to transfer mail from a mail server to a
User Agent
Mail
Server
POP
UA
File
System
CPE 401/601 Lecture 12 : E-mail protocols - POP3
44
POP (version 3)
• Similar to SMTP command/reply lockstep
• Minimizes server resources
• Used to retrieve mail for a single user
– requires authentication
• Commands and replies are ASCII lines
– Replies start with “+OK” or “-ERR”
– Replies may contain multiple lines
• POP has no security
– Except when used with SSL, TLS
CPE 401/601 Lecture 12 : E-mail protocols - POP3
45
POP-3 Commands
• USER
– specify username
• PASS
– specify password
• STAT
– get mailbox status
– number of messages in the mailbox and their size
• LIST
– get a list of messages and sizes
– One per line, termination line contains ‘.’ only
CPE 401/601 Lecture 12 : E-mail protocols - POP3
46
More POP-3 Commands
• RETR
– retrieve a message
• DELE
– mark a message for deletion from the mailbox
• NOOP
– send back positive reply
• RSET
– All deletion marks are unmarked
• QUIT
– remove marked messages and close connection
CPE 401/601 Lecture 12 : E-mail protocols - POP3
47
Optional Commands
• TOP
– send header lines from messages
• APOP
– alternative authentication
• message digest based on opening greeting sent from
POP server
• Requires shared secret!
• No cleartext password on the network
• Does not authenticate the server!!!!
CPE 401/601 Lecture 12 : E-mail protocols - POP3
48
A POP3 Exchange
> telnet monte pop3
Trying 128.213.8.110...
Connected to monte.cs.rpi.edu (128.213.8.110).
Escape character is '^]'.
+OK POP3 monte.cs.rpi.edu v7.59 server ready
user joe
+OK User name accepted, password please
pass joepw
+OK Mailbox open, 1 messages
stat
+OK 1 412
list
+OK Mailbox scan listing follows
1 412
.
CPE 401/601 Lecture 12 : E-mail protocols - POP3
49
POP3 Example Continued
retr 1
+OK 412 octets
Return-Path: <hollingd>
Received: (from hollingd@localhost)
by monte.cs.rpi.edu (8.9.3/8.9.3) id
NAA06943
for joe; Mon, 20 Mar 2000 13:49:54 -0500
Date: Mon, 20 Mar 2000 13:49:54 -0500
From: Dave Hollinger <hollingd@monte.cs.rpi.edu>
Message-Id: <200003201849.NAA06943@monte.cs.rpi.edu>
To: joe@monte.cs.rpi.edu
Status: O
blah
.
CPE 401/601 Lecture 12 : E-mail protocols - POP3
50
Internet Message Access Protocol
• On-line, off-line, or disconnected mode
operation
• Server-side Mailbox Manipulation
– Multiple mailbox support
– Control of all folders everywhere
• Online performance optimization
– User can check email header or search a string
before downloading
• Real authentication
CPE 401/601 Lecture 12 : E-mail protocols - IMAP
51
POP vs. IMAP
POP3:
Internet
IMAP:
Dr.Amer
Friends
….
Internet
All Messages
WebMail
• Web-base email access
• User agent -> web browser
• User agent-mail server communication based
on HTTP
– HTTP to send messages from user to the mail
server of the user
– HTTP to get mail from the mail server of the
destination
TCP / IP model
53
Download