lecture 10 ftp tftp l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Lecture 10 FTP & TFTP PowerPoint Presentation
Download Presentation
Lecture 10 FTP & TFTP

Loading in 2 Seconds...

play fullscreen
1 / 48

Lecture 10 FTP & TFTP - PowerPoint PPT Presentation


  • 578 Views
  • Uploaded on

Lecture 10 FTP & TFTP. CPE 401 / 601 Computer Network Systems. slides are modified from Dave Hollinger and Michael mgunes. Overview. File Transfer Protocol (RFC 959) Why FTP? FTP’s connections FTP in action FTP commands/responses Trivial File Transfer Protocol (RFC 1350)

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Lecture 10 FTP & TFTP' - zocha


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
lecture 10 ftp tftp

Lecture 10FTP & TFTP

CPE 401 / 601Computer Network Systems

slides are modified from Dave Hollinger and Michael mgunes

overview
Overview
  • 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

FTP

why do we need a ftp service
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

FTP

problems of file transfer
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

FTP

the ftp model
The FTP Model

PI: Protocol Interpreter

DTP: Data Transfer Protocol

User Interface

User

Control

Server PI

User PI

Data

File

System

File

System

Server DTP

User DTP

FTP

control and data connections
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.

FTP

control 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).

FTP

ftp s connections

* Persistent command

and reply connection

Non-persistent data

connection

Server is listening on port 21

for connection requests

* Insulates users from “raw”

FTP commands

*Server uses port 20

for data connections

* Routes “raw” FTP commands

* Receives server’s replies

FTP’s Connections

client

User

Interface

server

User

Protocol

Interpreter

Server

Protocol

Interpreter

Control

Connection

21

User

Data Transfer

Function

Data

Connection

Server

Data Transfer

Function

20

ftp s connections establishment
FTP’s Connections – Establishment

ftp> open cse.unr.edu

Connected to cse.unr.edu

220 cse FTP server ready.

530 Please login with USER and PASS

client

331 Password req for mgunes.

Password:

User

Interface

230 User mgunes logged in.

ftp>

USER mgunes

PASS mypass

server

User

Protocol

Interpreter

Server

Protocol

Interpreter

Control

Connection

User

Data Transfer

Function

Server

Data Transfer

Function

Data

Connection

ftp s connections data transfer
FTP’s Connections Data Transfer

client

ls client.txt

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

User

Interface

226 Closing Data Connection

PORT 192,168,100,173,19,137

LIST client.txt

200 Port Command Sucessful

150 Data Connection will be open shortly

server

User

Protocol

Interpreter

User

Protocol

Interpreter

Server

Protocol

Interpreter

Server

Protocol

Interpreter

Control

Connection

Passive open on

Port 5001

User

Data Transfer

Function

Server

Data Transfer

Function

Data

Connection

Establish Data Connection

ftp s connections connection closing
FTP’s Connections – Connection Closing

bye

client

User

Interface

221 Service Closing

QUIT

server

User

Protocol

Interpreter

Server

Protocol

Interpreter

Control

Connection

User

Data Transfer

Function

Server

Data Transfer

Function

Data

Connection

ftp client commands issued by user interface
FTP Client Commands (issued by user interface)

* Sent to server as multiple command by User Protocol Interpreter

access control commands
Access Control Commands

USER specify user

PASS specify password

CWD change directory

CDUP change directory to parent

QUIT logout

FTP

transfer parameter commands
Transfer Parameter Commands

PORT publish local data port

PASV server should listen

TYPE establish data representation

MODE establish transfer mode

STRU establish file structure

FTP

data transfer modes
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 (EOF, EOR, restart marker).
  • COMPRESSED:
    • uses a simple compression scheme - compressed blocks are transmitted.

FTP

service commands
Service Commands

RETR retrieve file

STOR send file

STOU send file and save as unique

APPE send file and append

ABOR abort prev. service command

PWD print working directory

LIST transfer list of files over data link

FTP

ftp replies
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.

FTP

ftp reply status code
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).

FTP

ftp reply status code20
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.

FTP

example ftp responses
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

FTP

rfc 959
RFC 959
  • The RFC includes lots more information and many details including:
    • parameters for commands
    • lists of reply status codes
    • protocol state diagrams
    • support for a variety of file structures
    • sample sessions

FTP

trivial ftp tftp
Trivial FTP (TFTP)
  • Used only to read and write files from/to a remote server
    • Cannot list directories
  • Useful for bootstrapping diskless systems
    • Workstations
    • X terminals
  • 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)

TFTP

diskless workstation booting 1 the call for help
Diskless Workstation Booting 1The call for help

Help! I don't know who I am!

My Ethernet address is:

4C:23:17:77:A6:03

Diskless

Workstation

RARP

TFTP

slide26

The answer from the all-knowing

RARP

Server

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

Diskless

Workstation

RARP REPLY

TFTP

slide27

The request for instructions

I need the file named

boot-128.113.45.211

Diskless

Workstation

TFTP Request (Broadcast)

TFTP

slide28

The dialog

TFTP

Server

here is part 1

I got part 1

here is part 2

Diskless

Workstation

boot file

TFTP File Transfer

TFTP

tftp protocol
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.

TFTP

tftp message formats

FILENAME

MODE

DATA

ERROR MESSAGE

TFTP Message Formats

OPCODE

0

0

OPCODE

BLOCK#

OPCODE

BLOCK#

OPCODE

BLOCK#

0

2 bytes

2 bytes

TFTP

tftp transfer modes
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.

TFTP

netascii transfer mode
NetAscii Transfer Mode

Unix - end of line marker is just '\n'

  • receiving a file
    • you need to remove '\r' before storing data.
  • sending a file
    • you need to replace every '\n' with "\r\n" before sending

TFTP

slide33

Read Request

01

filename

0

mode

0

null terminated ascii string

containing name of file

null terminated ascii string

containing transfer mode

2 byte opcode

network byte order

variable length fields!

TFTP

write request
Write Request

02

filename

0

mode

0

null terminated ascii string

containing name of file

null terminated ascii string

containing transfer mode

2 byte opcode

network byte order

variable length fields!

TFTP

tftp data packet
TFTP Data Packet

03

block #

data 0 to 512 bytes

2 byte block number

network byte order

2 byte opcode

network byte order

all data packets have 512 bytes

except the last one.

TFTP

tftp acknowledgment
TFTP Acknowledgment

04

block #

2 byte block number

network byte order

2 byte opcode

network byte order

TFTP

tftp error packet
TFTP Error Packet

05

errcode

errstring

0

null terminated ascii error string

2 byte opcode

network byte order

2 byte error code

network byte order

TFTP

tftp error codes 16 bit int
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

TFTP

lost data packets original protocol specification
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".

TFTP

sorcerer s apprentice syndrome
Sorcerer’s Apprentice Syndrome

send 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)

TFTP

the fix
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.

TFTP

concurrency
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.

TFTP

tftp concurrency
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.

TFTP

when is it over
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!

TFTP

issues
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!

TFTP

ftp vs tftp
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

TFTP