当前位置:网站首页>Simple file transfer protocol TFTP
Simple file transfer protocol TFTP
2022-06-28 02:58:00 【ZhuMou】
One . Introduction to simple file transfer protocol
File transfer protocol (FTP) regulates the way to access files locally from remote servers .
File transfer protocols fall into two categories :1.online-access and 2.whole file copying. The representative agreement of the former is NFS, Similar to sharing documents , Changes to the file locally will affect the file on the server . The latter is essentially a reproduction : Upload files to the server ( Put the local file copy To the server ) And downloading files from the server ( The file copy To local ). Modification of a copy , Will not affect the original file .
TFTP The full name is Trivial File Transfer Protocol, And FTP In comparison, it is simple :
1. be based on UDP Designed application layer protocol . Port is 69. Of course, other transport layer protocols are also supported , such as TCP.
2. No, access control, That is, there is no login verification .
3. There are no folders , All the files are in the root directory .
4. The concept of design is simple, simple and simple , So the cost is very small , It is commonly used in diskless workstations and has strict memory requirements ( Small available memory ) Environment .
Two .TFTP packet format

TFTP packet from TFTP header and TFTP data form . There is a two byte opcode Marked with the TFTP packet The type of , All in all 5 Kind of . We will introduce them one by one .
2.1 RRQ(read request)

opcode = 01( In the decimal sense ), Indicates that the packet by RRQ type , It is used to locally apply to the server for downloading files . The file name is from filename Field assignment , by ASCII Code string , Variable length , With NULL ending .mode The field is also a variable length ASCII Code string , With NULL ending , It defines the file transfer mode ( Transfer mode of files in different formats , Or the way must be different , Such as binary files and txt file ), We'll talk about later .
2.2 WRQ(write request)

It is used to apply for uploading files to the server locally ,opcode by 02. The rest and RRQ Agreement .
2.3 DATA(data)

opcode = 03. Used for data transmission when uploading or downloading files . File is too large. , Will be split into multiple data segments for transmission .block# The field identifies the sequence number of the data segment , Facilitate the reorganization of subsequent data .data Field placement 0-512 Bytes of data . For sizes other than 512 Byte multiples of the file , the last one data packet Of data The size of the field is less than 512 byte ; For exactly 512 Byte multiple size file , In the end, they often send a message data field by 0 Bytes of data packet, To avoid a data field by 512 Byte size data packet As the last of the file data packet.
2.4 ACK(acknowledgement)

opcode = 04. Used by the server for local transport data packet Response . For example, there is a local block# by xxx Of data packet, The server will confirm after receiving it , Return to one block# The field is also xxx Of data packet.
Attention is only to data packet The confirmation of , Yes WRQ and RRQ And other types will not return ACK.
2.5 ERROR(error)

opcode = 05.errcode Field indicates the error type ,errorstring Field gives an error message . among errorstring In order to ASCII Error prompt in the form of code string , Its variable length , And in NULL ending .
2.6 transfer mode explain
Introduction to transmission txt Of documents Netascii And transfer binary files Octet Pattern .
Netascii Mode is used to transmit txt File format , It is transmitted by line . The sender will add... At the end of each line \r\n, And the receiver will remove it .
Octet For binary file transfer , Is transmitted in bytes , The sender and the receiver do not need to do similar addition and removal processing .
3.TFTP Agreement that
TFTP Agreed packet format Stated , The following instructions TFTP Of operations.
We know TFTP Is a simple file transfer for point-to-point , These two points are actually symmetrical , Can be used as a server or a client .TFTP Is based on UDP The design of the , This is very strange , In particular, it is necessary to ensure the reliability of file transmission , and UDP Reliability is not guaranteed . So who guarantees the reliability of file transfer ? Nature is the application layer TFTP agreement , Its use ACK type packet Guarantee data packet Reliability of transmission .
3.1 TFTP The basic process of transferring documents and the guarantee of reliability
We only consider the process of data transmission ( Just consider ACK and DATA packet), Not for now WRQ and RRQ etc. packet.
Remember two facts :
1. First ,server and client Each end maintains a timer , It is used to judge whether the data it sends has timed out .
2. in addition ,server and client The end transmission data adopts stop and wait The way , No confirmation of the last data was received , Don't send the next one .
Server End send data[1], And start timing , can do with client End ack(1) Response . If timer timeout Still not received after ack(1), be server It is believed that data[1] The loss of , And retransmit ; Once received within the time limit ack(1),server Will be sent immediately ack(2).
Client Termination received data(1), Send it now ack(1), And start timing , Hope to receive server End data(2) Response . If timer timeout Still not received after data(2), be client It is believed that ack(1) The loss of , And retransmit ; Once received within the time limit data(2),client The client will immediately send ack(2).
3.2 SAS(sorcerer's apprentice syndrome)
This represents the original TFTP Defects in the agreement . The original TFTP Protocol design :client Once the end receives ack(n), Whether received or not , All sent immediately data(n+1), Even if data(n+1) Already sent ;server Once the end is data(n), Whether received or not , All sent immediately ack(n). and dealyed but not lost ack May trigger SAS, Make the following data Are transmitted twice .

The solution is in sender Add a judgment to the end algorithm , if ack(n) repeat , No data will be sent data(n+1).
3.3 State transition diagram
Five kinds packet There is no end of transmission in , Need to rely on DATA packet Implicitly represent (data Insufficient domains 512B).


for fear of SAS, You can put server Terminal ACK(n) Change it to :ACK(n) and not duplicate.
3.4 Message sequence diagram

边栏推荐
- PSM summary
- [today in history] June 12: the United States entered the era of digital television; Mozilla's original developer was born; 3com merges with American Robotics
- Mixed programming of C language and assembly language in stm32
- 新手炒股开户选哪家证券平台办理是最好最安全的
- 2021年软件测试工具总结——模糊测试工具
- 2-5 basic configuration -win2003 add attack surface
- Exploration on the construction path of real-time digital warehouse integrating digital intelligence learning and streaming batch
- 把腾讯搬上云:云服务器 CVM 的半部进化史
- [today in history] June 2: Apple launched swift programming language; China Telecom acquires China Unicom C network; OS X Yosemite release
- How to run unity webgl after packaging (Firefox configuration)
猜你喜欢

如何开启多语言文本建议?Win11打开多语言文本建议的方法
![[today in history] June 8: the father of the world wide web was born; PHP public release; IPhone 4 comes out](/img/1b/31b5adbec5182207c371a23e41baa3.png)
[today in history] June 8: the father of the world wide web was born; PHP public release; IPhone 4 comes out

How to run unity webgl after packaging (Firefox configuration)

Summary of software testing tools in 2021 - fuzzy testing tools

JDBC与MySQL数据库

StaticLayout的使用详解

How to systematically learn LabVIEW?

What if win11 cannot use dynamic wallpaper? Solution of win11 without dynamic wallpaper

Reprinted article: the digital economy generates strong demand for computing power Intel releases a number of innovative technologies to tap the potential of computing power
![[today in history] June 6: World IPv6 launch anniversary; Tetris release; Little red book established](/img/06/895913d2c54b03cde86b3116955a9e.png)
[today in history] June 6: World IPv6 launch anniversary; Tetris release; Little red book established
随机推荐
Heartless sword Chinese English bilingual poem 004 Sword
A low-cost method to increase private domain traffic with simple maintenance
Le routage des microservices de la passerelle a échoué au chargement des ressources statiques des microservices
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
[today in history] June 8: the father of the world wide web was born; PHP public release; IPhone 4 comes out
字节跳动面试官:一张图片占据的内存大小是如何计算
Reprinted article: the digital economy generates strong demand for computing power Intel releases a number of innovative technologies to tap the potential of computing power
Gateway微服务路由使微服务静态资源加载失败
Severe Tire Damage:世界上第一个在互联网上直播的摇滚乐队
win11如何添加打印机和扫描仪?win11添加打印机和扫描仪的设置
【方块编码】基于matlab的图像方块编码仿真
Writing based on stm32
Basic flask: template rendering + template filtering + control statement
把腾讯搬上云:云服务器 CVM 的半部进化史
Is it safe for qiniu to open an account? How do I open an account online?
You got 8K in the 3-year function test, but were overtaken by the new tester. In fact, you are pretending to work hard
Arduino esp8266 web LED control
The horizontal scrolling recycleview displays five and a half in one screen, which is lower than the five average distributions
【 amélioration de la correction d'image de Code bidimensionnel】 simulation du traitement d'amélioration de la correction d'image de Code bidimensionnel basée sur MATLAB
微信小程序中生成二维码