68
Lecture 12 Overview

Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Embed Size (px)

Citation preview

Page 1: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Lecture 12 Overview

Page 2: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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 2

Page 3: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Network Virtual Terminal

• intermediate representation of a generic terminal

• provides a standard language for communication of terminal control functions

CPE 401/601 Lecture 12 : TELNET protocol 3

NVT NVT

ServerProcess

TCP TCP

Page 4: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

4CPE 401/601 Lecture 12 : TELNET protocol

Page 5: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

5CPE 401/601 Lecture 12 : TELNET protocol

Page 6: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

A Typical Mail Environment

Internet

Mail Server

POPStore

IMAPstore

Mail Server

MailClient

MailClient

SMTP

POP

IMAP

SMTP

SMTP

Interactive Mail Access Protocol

6CPE 401/601 Lecture 12 : E-mail protocols

Page 7: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

7CPE 401/601 Lecture 12 : E-mail protocols

Page 8: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

SMTP

• Used to exchange mail messages between mail servers (Message Transfer Agents)

8

MTAMTA MTAMTA

UAUA

SMTP

FileSystem

FileSystem

MTAMTASMTP

UAUA

CPE 401/601 Lecture 12 : E-mail protocols - SMTP

Page 9: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

9CPE 401/601 Lecture 12 : E-mail protocols - SMTP

Page 10: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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 stuff10CPE 401/601 Lecture 12 : E-mail protocols - SMTP

Page 11: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Message Progress

TCP Connection Establishment

TCP Connection Termination

11CPE 401/601 Lecture 12 : E-mail protocols - SMTP

Page 12: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Reply Codes

• Contain a Lot of Information

• Only the reply codes count– Other information in a reply is purely for humans

354The first digit

indicates success, failure,

or incomplete

The second digit is the category of error message

The third digit is the specific message for that

category

12CPE 401/601 Lecture 12 : E-mail protocols - SMTP

Page 13: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

SMTP Extensions (EHLO)• A mailer supporting extensions uses EHLO

instead of HELO in the greeting$ telnet mail.unr.edu 25Trying 134.197.1.112...

220 smtp.unr.edu ESMTP PostfixEHLO250-smtp.unr.edu250-PIPELINING250-SIZE 30720000250-VRFY250-ENHANCEDSTATUSCODES250-8BITMIME250 DNS

A mailer that supports extensions responds with a list of which ones it can do

A mailer that supports extensions responds with a list of which ones it can do

13CPE 401/601 Lecture 12 : E-mail protocols - SMTP

Page 14: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

14CPE 401/601 Lecture 12 : E-mail protocols - SMTP

Page 15: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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 15

Page 16: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

A sample MIME messageFrom: [email protected] (Jan Trumbo)

Subject: small message with Word attachment

To: [email protected]

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]

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>

This identical boundary marker separates the parts of the mail message

16CPE 401/601 Lecture 12 : E-mail protocols - MIME

Page 17: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

17CPE 401/601 Lecture 12 : E-mail protocols

Page 18: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

POP – Post Office Protocol

• Used to transfer mail from a mail server to a User Agent

18

MailServer

MailServer UAUA

FileSystem

FileSystem

POP

CPE 401/601 Lecture 12 : E-mail protocols - POP3

Page 19: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

19CPE 401/601 Lecture 12 : E-mail protocols - POP3

Page 20: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

A POP3 Exchange> telnet monte pop3Trying 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 readyuser joe+OK User name accepted, password pleasepass joepw+OK Mailbox open, 1 messagesstat+OK 1 412list+OK Mailbox scan listing follows1 412.

20CPE 401/601 Lecture 12 : E-mail protocols - POP3

Page 21: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

POP3 Example Continuedretr 1+OK 412 octetsReturn-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 -0500Date: Mon, 20 Mar 2000 13:49:54 -0500From: Dave Hollinger <[email protected]>Message-Id: <[email protected]>To: [email protected]: O

blah.

21CPE 401/601 Lecture 12 : E-mail protocols - POP3

Page 22: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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 22

Page 23: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

All Messages

POP3:

IMAP:Dr.Amer

Friends

….headers

Whole message

Internet

Internet

POP vs. IMAP

23CPE 401/601 Lecture 12 : E-mail protocols

Page 24: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

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

24CPE 401/601 Lecture 12 : E-mail protocols - WebMail

Page 25: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Lecture 13

File Transfer Protocols

CPE 401 / 601

Computer Network Systems

slides are modified from Dave Hollingerslides are modified from Dave Hollinger and Michael

Page 26: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

File Transfer Protocols

• File Transfer Protocol (RFC 959)– Why FTP?– FTP’s connections– FTP in action– FTP commands/responses

• Trivial File Transfer Protocol (RFC 1350)– TFTP and TFTP’s message formats– FTP and TFTP compared

26CPE 401/601 Lecture 13 : File Transfer Protocols

Page 27: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Why do we need a FTP Service?

• Purpose: To Transfer files between two computers

• Goals of FTP Service– Promote sharing of files (programs and/or data)– Encourage indirect/implicit use of remote

computers– Shield users from variations in file storage among

hosts– Transfer data reliably and efficiently

27CPE 401/601 Lecture 13 : File Transfer Protocols

Page 28: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Problems of File Transfer

• At first, file transfer may seem simple• Heterogeneous systems use different:

– Operating Systems– Character Sets– Naming Conventions– Directory Structures– File Structures and Formats

• FTP need to address and resolve these problems

28CPE 401/601 Lecture 13 : File Transfer Protocols

Page 29: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

File Transfer Protocol

• Exchange and manipulate files over TCP• Separate control and data connections

between the client and server applications• RFC 959 includes information and details

– parameters for commands– lists of reply status codes– protocol state diagrams– support for a variety of file structures– sample sessions

29CPE 401/601 Lecture 13 : FTP

Page 30: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

The FTP Model

30

Server PIServer PI

FileFileSystemSystem

User InterfaceUser Interface

User PIUser PI

UserUser

User DTPUser DTPServer DTPServer DTPFileFileSystemSystem

DataData

ControlControl

PI: Protocol InterpreterPI: Protocol InterpreterDTP: Data Transfer ProtocolDTP: Data Transfer Protocol

PI: Protocol InterpreterPI: Protocol InterpreterDTP: Data Transfer ProtocolDTP: Data Transfer Protocol

CPE 401/601 Lecture 13 : FTP

Page 31: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Control and Data Connections

• Control functions (commands) and reply codes are transferred over the control connection.

• All data transfer takes place over the data connection.

• The control connection must be “up” while data transfer takes place.

31CPE 401/601 Lecture 13 : FTP

Page 32: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Control Connection

• The control connection is the “well known” service.

• The control connection uses the TELNET protocol.

• Commands and replies are all line oriented text (default is ASCII).

32CPE 401/601 Lecture 13 : FTP

Page 33: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP’s Connections

UserInterface

User Data Transfer Function

UserProtocolInterpreter

ServerProtocolInterpreter

Server Data Transfer Function

client

server

ControlConnection

DataConnection

* Insulates users from “raw” FTP commandsServer is listening on port 21for connection requests

* Routes “raw” FTP commands * Receives server’s replies

* Persistent command and reply connection

Non-persistent data connection

21

20

*Server uses port 20for data connections

CPE 401/601 Lecture 13 : FTP 33

Page 34: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP - Connection Establishment

UserInterface

User Data Transfer Function

UserProtocolInterpreter

ServerProtocolInterpreter

Server Data Transfer Function

client

server

ControlConnection

DataConnection

ftp> open cse.unr.eduConnected to cse.unr.edu220 cse FTP server ready.530 Please login with USER and PASS

USER mgunes

331 Password req for mgunes.Password:

PASS mypass

230 User mgunes logged in.ftp>

CPE 401/601 Lecture 13 : FTP 34

Page 35: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP - Data Transfer

User Data Transfer Function

Server Data Transfer Function

UserInterface

UserProtocolInterpreter

ServerProtocolInterpreter

client

server

ControlConnection

DataConnection

ls client.txt

Passive open onPort 5001

PORT 192,168,100,173,19,137200 Port Command SucessfulLIST client.txt150 Data Connection will be open shortly226 Closing Data Connection

-rw-r--r-- mgunes client.txt

Establish Data Connection

UserProtocolInterpreter

ServerProtocolInterpreter

CPE 401/601 Lecture 13 : FTP 35

Page 36: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP - Connection Closing

UserInterface

UserProtocolInterpreter

ServerProtocolInterpreter

client

server

ControlConnection

DataConnection

User Data Transfer Function

Server Data Transfer Function

bye

QUIT221 Service Closing

CPE 401/601 Lecture 13 : FTP 36

Page 37: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP Connections

37CPE 401/601 Lecture 13 : FTP

Page 38: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP Client CommandsCommand Description

get filename Retrieve file from server

mget filename* Retrieve multiple files from server*

put filename Copy local file to server

mput filename* Copy multiple local files to server*

open server Begin login to server

bye / close / exit Logoff server

ls / dir List files in current remote dir on server

lcd Change local directory

cd Change remote directory

rhelp / remotehelp Lists commands the server accepts

* Sent to server as multiple command by User Protocol InterpreterCPE 401/601 Lecture 13 : FTP 38

Page 39: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Data Transfer Modes

• STREAM: – file is transmitted as a stream of bytes

• BLOCK: – file is transmitted as a series of blocks preceded by

headers containing count and descriptor code

• COMPRESSED: – uses a simple compression scheme on transmitted

blocks

39CPE 401/601 Lecture 13 : FTP

Page 40: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP Replies

• All replies are sent over control connection.

• Replies are a single line containing– 3 digit status code (sent as 3 numeric chars).– text message.

• The FTP spec. includes support for multiline text replies.

40CPE 401/601 Lecture 13 : FTP

Page 41: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP Reply Status Code

• First digit of status code indicates type of reply:– ‘1’: Positive Preliminary Reply (got it, but wait).– ‘2’: Positive Completion Reply (success).– ‘3’: Positive Intermediate Reply (waiting for more

information).– ‘4’: Transient Negative Completion (error - try

again).– ‘5’: Permanent Negative Reply (error - can’t do).

41CPE 401/601 Lecture 13: FTP

Page 42: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP Reply Status Code

• 2nd digit indicates function groupings.– ‘0’: Syntax (problem with command syntax).– ‘1’: Information (reply to help or status cmds).– ‘2’: Connections (problem with a connection).– ‘3’: Authentication (problem with login).– ‘4’: Unspecified.– ‘5’: File system (related to file system).

• 3rd digit indicates specific problem within function group.

42CPE 401/601 Lecture 13 : FTP

Page 43: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Example FTP Responses

• 120 Service will be ready shortly• 200 Command OK• 230 User login OK• 331 User name OK; password is needed• 421 Service not available• 530 User not logged in• 552 Requested action aborted; exceeded

storage allocation

43CPE 401/601 Lecture 13 : FTP

Page 44: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Trivial FTP

Page 45: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Trivial FTP (TFTP)• Simple and small:

– 5 message formats– Runs on UDP– Designed to fit in ROM– Uses a “stop and wait” protocol– NO BUILT IN SECURITY FEATURES (login)

• Used only to read and write files from/to a server– Cannot list directories

• Useful for bootstrapping diskless systems– Workstations– X terminals

45CPE 401/601 Lecture 13 : TFTP

Page 46: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Diskless Workstation Booting 1

The call for help

46

DisklessWorkstation

Help! I don't know who I am!My Ethernet address is:4C:23:17:77:A6:03

RARP

CPE 401/601 Lecture 13 : TFTP

Page 47: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

The answer from the all-knowing

47

DisklessWorkstation

I know all! You are to be know as: 128.113.45.211

RARP REPLY

RARPServer

CPE 401/601 Lecture 13 : TFTP

Page 48: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

The request for instructions

48

DisklessWorkstation

I need the file named boot-128.113.45.211

TFTP Request (Broadcast)

CPE 401/601 Lecture 13 : TFTP

Page 49: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

The dialog

49

DisklessWorkstation

TFTP File Transfer

TFTPServer

here is part 1

I got part 1

here is part 2

boot file

CPE 401/601 Lecture 13 : TFTP

Page 50: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Protocol• 5 message types:

– Read request– Write request– Data– ACK (acknowledgment)– Error

• Each is an independent UDP Datagram• Each has a 2 byte opcode (1st 2 bytes)

– The structure of the rest of the datagram depends on the opcode

50CPE 401/601 Lecture 13 : TFTP

Page 51: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Message Formats

FILENAMEOPCODE 0 0MODE

BLOCK# DATA

BLOCK#

OPCODE

OPCODE

OPCODE BLOCK# ERROR MESSAGE 0

2 bytes 2 bytesCPE 401/601 Lecture 13 : TFTP 51

Page 52: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP transfer modes

• octet : for transferring binary files.– no translation done.

• netascii : for transferring text files.– all lines end with \r\n (CR,LF).– provides standard format for transferring text files.– both ends responsible for converting to/from

netascii format.

52CPE 401/601 Lecture 13 : TFTP

Page 53: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Read Request

54

01 filename 0 mode 0

2 byte opcode2 byte opcodenetwork byte ordernetwork byte order

null terminated ascii stringnull terminated ascii stringcontaining name of filecontaining name of file

null terminated ascii stringnull terminated ascii stringcontaining transfer modecontaining transfer mode

variable length fields!variable length fields!CPE 401/601 Lecture 13 : TFTP

Page 54: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Write Request

55

02 filename 0 mode 0

2 byte opcode2 byte opcodenetwork byte ordernetwork byte order

null terminated ascii stringnull terminated ascii stringcontaining name of filecontaining name of file

null terminated ascii stringnull terminated ascii stringcontaining transfer modecontaining transfer mode

variable length fields!variable length fields!CPE 401/601 Lecture 13 : TFTP

Page 55: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Data Packet

56

03 block # data 0 to 512 bytes

2 byte opcode2 byte opcodenetwork byte ordernetwork byte order

2 byte block number2 byte block numbernetwork byte ordernetwork byte order

all data packets have 512 bytesall data packets have 512 bytesexcept the last one.except the last one.

CPE 401/601 Lecture 13 : TFTP

Page 56: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Acknowledgment

57

04 block #

2 byte opcode2 byte opcodenetwork byte ordernetwork byte order

2 byte block number2 byte block numbernetwork byte ordernetwork byte order

CPE 401/601 Lecture 13 : TFTP

Page 57: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Error Packet

58

05 errcode errstring

2 byte opcode2 byte opcodenetwork byte ordernetwork byte order

2 byte error code2 byte error codenetwork byte ordernetwork byte order

null terminated ascii error stringnull terminated ascii error string

0

CPE 401/601 Lecture 13 : TFTP

Page 58: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Error Codes (16 bit int)

• 0 - not defined• 1 - File not found• 2 - Access violation• 3 - Disk full• 4 - Illegal TFTP operation• 5 - Unknown port• 6 - File already exists• 7 - No such user

59CPE 401/601 Lecture 13 : TFTP

Page 59: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Connection Establishment

60CPE 401/601 Lecture 13 : TFTP

Page 60: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Session

61CPE 401/601 Lecture 13 : TFTP

Page 61: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Lost Data Packets

• Original Protocol Specification

• Sender uses a timeout with retransmission.– sender could be client or server.

• Duplicate data packets must be recognized and ACK retransmitted.

• This original protocol suffers from the "sorcerer’s apprentice syndrome".

62CPE 401/601 Lecture 13 : TFTP

Page 62: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Sorcerer’s Apprentice Syndromesend DATA[n]

(time out)retransmit DATA[n]

receive ACK[n]send DATA[n+1]

receive ACK[n] (dup)send DATA[n+1](dup)

...

receive DATA[n]send ACK[n]

receive DATA[n] (dup)send ACK[n] (dup)

receive DATA[n+1] send ACK[n+1]

receive DATA[n+1] (dup)send ACK[n+1] (dup)

CPE 401/601 Lecture 13 : TFTP 63

Page 63: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

The Fix

• Sender should not resend a data packet in response to a duplicate ACK.

• If sender receives ACK[n]– don’t send DATA[n+1] if the ACK was a duplicate.

64CPE 401/601 Lecture 13 : TFTP

Page 64: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Concurrency

• TFTP servers use a "well known address" – UDP port number

• How would you implement a concurrent server?– forking (alone) may lead to problems!– Can provide concurrency without forking, but it

requires lots of bookkeeping.

65CPE 401/601 Lecture 13 : TFTP

Page 65: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

TFTP Concurrency

• According to the protocol, the server may create a new udp port and send the initial response from this new port.

• The client should recognize this, and send all subsequent messages to the new port.

66CPE 401/601 Lecture 13 : TFTP

Page 66: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

When is it over?

• There is no length of file field sent!

• All data messages except the last one contain 512 bytes of data.– message length is 2 + 2 + 512 = 516

• The last data message might contain 0 bytes of data!

67CPE 401/601 Lecture 13 : TFTP

Page 67: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

Issues

• What if more than 65535 chunks are sent?– 65536 blocks x 512 bytes/block = 33,554,432

bytes.

• The RFC does not address this issue!• Remember that the network can duplicate

packets!

68CPE 401/601 Lecture 13 : TFTP

Page 68: Lecture 12 Overview. TELNET TELNET is a protocol that provides – general, – bi-directional, – eight-bit byte oriented communications Over TCP connection

FTP vs. TFTP• FTP provides (minimal) security through login

procedure• TFTP has NO login procedure• FTP Provides a reliable service through its use of TCP• TFTP must handle its own retransmissions since it

uses UDP• FTP uses two connections• TFTP uses one connection (stop and wait)• FTP provides many commands• TFTP can only read and write files

69CPE 401/601 Lecture 13 : TFTP