TFTP - Trivial File Transfer Protocol

PeterREgli 11,141 views 10 slides Dec 04, 2010
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

Overview of the TFTP protocol.

TFTP (Trivial File Transfer Protocol) is, as its name implies, a very simple mechanism for transferring files between 2 hosts.
TFTP is typically used for downloading software and configuration files to Internet and LAN appliances like routers, switches and gateways.
D...


Slide Content

© Peter R. Egli 2015
1/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
Peter R. Egli
INDIGOO.COM
OVERVIEW OF TFTP, A VERY SIMPLE
FILE TRANSFER PROTOCOL FOR SIMPLE
AND CONSTRAINED DEVICES
TFTP
TRIVIAL FILE TRANSFER PROTOCOL

© Peter R. Egli 2015
2/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
Contents
1.WhyTFTP?
2.ComparisonTFTP andFTP
3.The TFTP protocol
4.TFTP and FTP throughput comparison

© Peter R. Egli 2015
3/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
1. WhyTFTP?
In theolddays, TFTP was typicallyusedfordownloadingbootcodetodisklessworkstations.
TFTP was simple enoughtofit intoEEPROMs ofdisklessworkstations
(onlya fewKBytesofcode).
LAN
TFTP Client
(DisklessWorkstation)
TFTP Server
withbootcode
Today, TFTP ismostoftenusedfordownloadingnewcodetoInternet appliances
(Internet Access Devices, routers, switches, VOIP gatewaysetc.).

© Peter R. Egli 2015
4/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
2. TFTP versus FTP
FTP andTFTP bothareprotocolsfortransferringfilesbetweena clientanda server.
However, TFTP andFTP are2 totallydifferent protocolsanddo not haveanythingin common.
Value FTP TFTP
Authentication
Authentication basedon loginwithusername
andpassword.
TFTP doesnot provideauthentication(login).
Connection
FTP usesTCP (reliabletransmission). Errors are
handledbytheunderlyingTCP layer.
TFTP usesUDP andthusnoconnections. Errors in
thetransmission(lostpackets, checksumerrors)
must behandledbytheTFTP server.
Protocol
algorithm
Transmission ofdataandcontrolinformationis
handledbytheunderlyingTCP layer.
TCP guaranteesmaximumthroughput(flow
control, congestioncontrol) anderrorcontrol.
TFTPusesa simple lock-stepprotocol(eachdata
packet needstobeacknowledged). Thus the
throughputislimited.
Footprint
FTP ismorecomplexthanTFTP, thusrequiresa
larger memoryfootprint.
OftenFTP isnot suitedforsmalldevice
bootloaderswhichmust fit intoconstrained
EEPROM storage.
TFTP isverysimple. Becauseitusestheequally
simple UDP transportprotocol, TFTP clientsor
servershavea verysmallfootprintandarethus
suitedforusein bootloaders.
Controlanddata
channel
FTP separates userdataandcontrolinformation
byusing2 separate TCP connections.
TFTP usesonly"1 channel", i.e. controlpackets
(commands) flowin onedirectionwhiledata
packetscarryinguserdataflowin thereverse
directionoverthesame UDP sockets.

© Peter R. Egli 2015
5/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
3. TFTP Protocol RFC1350(1/5)
The TFTP protocol(1/3):
Request –responseprotocol:
TFTP isa simple request/ acknowledgeprotocol.
The modeofoperationislock-stepbecauseeachdatapacket needstobeacknowledgedbeforethenextdata
packet maybesent.
This makestheimplementationverysimple (noflowcontrolneeded), but limitsthethroughputbecauseeach
datapacket requires1 round-trip-time (RTT) fortransmission.
Acknowledgeofdata:
TFTP onlyusespositive acknowledgements(correctlyreceivedpacketsareacknowledgedwithan ACK
packet).
Whenthesenderdoesnot receivean ACK packet in due time, itre-sendsthelast DATA packet.
UDP Ports:
The server"listens" on port69 (TFTP defaultport), but switchestoanotherportforall replies(DATA, ACK) in
ordertofreetheport69 forotherrequests(server‚spawns‘ a newUDP socket forhandlingtheTFTP
request).

© Peter R. Egli 2015
6/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
RRQ (Read Request)
DATA block 1 (512 Bytes)
ACK block 1
DATA block 2 (512 Bytes)
ACK block 2
DATA block n (last) (0 -511 Bytes)
ACK block n
3. TFTP Protocol RFC1350(2/5)
The TFTP protocol(2/3):
TFTP readrequest(RRQ):
TFTP client TFTP server
The transfer is initiated by a read request packet (RRQ).
The server responds with the first data block of 512
bytes.
The client acknowledges the reception of the first data block.
The transfer continues with the next data block which
is acknowledged by the client.
The last data packet contains 0 –511 bytes. This signals
the end of transfer to the client.
If the entire data file to be transferred is dividable by 512,
the last packet contains 0 data bytes (an empty packet).
The transfer is completed by the last acknowledge.

© Peter R. Egli 2015
7/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
WRQ (Write Request)
ACK block 0
DATA block 1 (512 Bytes)
ACK block 1
DATA block n (last) (0 -511 Bytes)
ACK block 2
3. TFTP Protocol RFC1350(3/5)
The TFTP protocol(2/3):
TFTP writerequest(RRQ):
The transfer is initiated by a write request packet (WRQ).
To keep the scheme with acknowledging every packet as is
the case in RRQ, the server acknowledges the "virtual"
data block 0 which acknowledges the WRQ packet.
The client sends the first data block of 512 bytes.
The server acknowledges the first data block.
The transfer is completed by the last acknowledge.
DATA block 2 (512 Bytes)
ACK block n
The transfer continues with the next data block which
is acknowledged by the server.
Again, the last data packet contains 0 –511 bytes signaling
the end of the transfer to the client.
TFTP client TFTP server

© Peter R. Egli 2015
8/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
RRQ (read)
WRQ (write)
DATA
Data packet
ACK
packet
ERROR
packet
3. TFTP Protocol RFC1350(4/5)
Packet layout:
2 bytes n bytes 1 byte mode 1 byte
Opcode
1=RRQ, 2=WRQ
Filename 0x00
“netascii” (=text),
“octet” (=binary)
0x00
2 bytes 2 bytes
Opcode
4=ACK
Block number
2 bytes 2 bytes
Opcode
5=ERROR
Error number
n bytes
Error message 0x00
1 byte
All data packets
contain 512 bytes
except the last
one (0-511 bytes).
2 bytes 2 bytes
Opcode
3=DATA
Block number
n bytes
Data (0-512 bytes)

© Peter R. Egli 2015
9/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
Wireshark trace of TFTP read request:
C: 1 0.000000 193.5.54.112:44143 -> 193.5.54.29:69 TFTP Read Request, File: text.txt,
Transfer type: netascii
S: 2 0.001569 193.5.54.29:70 -> 193.5.54.112:44143 TFTP Data Packet, Block: 1
C: 3 0.002043 193.5.54.112:44143 -> 193.5.54.29:70 TFTP Acknowledgement, Block: 1
S: 4 0.002159 193.5.54.29:70 -> 193.5.54.112:44143 TFTP Data Packet, Block: 2 (last)
C. 5 0.009594 193.5.54.112:44143 -> 193.5.54.29:70 TFTP Acknowledgement, Block: 2
Wireshark trace of TFTP write request:
C: 1 0.000000 193.5.54.112:44547 -> 193.5.54.29:69 TFTP Write Request, File: text.txt,
Transfer type: netascii
S: 2 0.075201 193.5.54.29:70 -> 193.5.54.112:44547 TFTP Acknowledgement, Block: 0
C: 3 0.075949 193.5.54.112:44547 -> 193.5.54.29:70 TFTP Data Packet, Block: 1
S: 4 0.077696 193.5.54.29:70 -> 193.5.54.112:44547 TFTP Acknowledgement, Block: 1
C: 5 0.077937 193.5.54.112:44547 -> 193.5.54.29:70 TFTP Data Packet, Block: 2 (last)
S: 6 0.084512 193.5.54.29:70 -> 193.5.54.112:44547 TFTP Acknowledgement, Block: 2
3. TFTP Protocol RFC1350(5/5)
RRQ (Read Request) andWRQ (Write Request) traces:
C: Packet sentbyclient
S: Packet sentbyserver

© Peter R. Egli 2015
10/10
Rev. 2.50
TFTP -Trivial File Transfer Protocol indigoo.com
Theoreticalthroughputexample:
MeasuredRTT = 0.282ms (withping); Ws= 8192Bytes; assumptions: protocolprocessing
doesnot consumetime; TCP mechanisms(delayedacketc.) do not increaseRTT.
TFTP: 512 Bytes in 0.282ms 1.8MBytes/s
FTP: 8192 Bytes in 0.282ms 29MBytes/s
FTP isroughly16 timesfasterthanTFTP.
Measuredthroughputexample:
TFTP: 143872 Bytes in 0.8s 180KBytes/s
FTP: 143872 Bytes in 0.11s 1.3MBytes/s
FTP was roughly7 timesfasterthanTFTP.
The effectivetransferrate ismuchlowerthanthetheoreticalmaximumdue toprocessing
delayson clientandserver(increasedRTT) andlessthanideal usageofprotocols(TCP
windowsizeisnot fullyexploited).
4. TFTP andFTP throughputcomparison
Due tothedifferent transmissionalgorithms, themaximumachievablethroughputfor
TFTP andFTP isdifferent:
TFTP theoretical max. throughput = 512Bytes / RTT RTT = Round Trip Time
FTP theoretical max. throughput = Ws / RTT Ws = Window size