TFTP

本文介绍了TFTP(简单文件传输协议),它基于UDP实现。阐述了5种数据报类型及其结构,包括读请求、写请求等。说明了文件传输方式、错误处理方法,还提出了测试程序时的问题。最后指出该项目可跨平台,后续可实现更多选项、创建UI及实施访问控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

1. Introduction

TFTP is a very simple protocol used to transfer files.  It is from this that its name comes, Trivial File Transfer Protocol or TFTP.  It has been implemented on top of the Internet User Datagram protocol (UDP or Datagram).

2. 5 types of Datagrams

They are Read request(RRQ), Write request(WRQ), Data(DATA), ACK(ACK) and Error(ERROR).

Here is the structure of these 5 datagrams.

OPCODE: 2 Bytes. Indicate which type the datagram belongs to.

Other information in the datagram depends on the type of the datagram.

 

2.1 RRQ

2.2 WRQ

mode: Indicate which kind of method the transportation is using, netascii or octet.

if netascii, you must be aware that: In Windows, it's '\r\n' that returns, while in Unix, it's '\r'. if octet, there is no need in doing these.

2.3 DATA

2.4 ACK

When TFTP session begins, there is no field in the datagram that indicates the length of the file. Then how the sender indicate the end of the file? TFTP uses a special way to indicate this, though it has a flaw(We will see later).

Data block = 512 Bytes

When Data block = 0-511, it is the last block of the file.

2.5 ERROR

TFTP error code:

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

 

3. File Transport

3.1 Read File

3.2 Write File

 

4. Error Handling

TFTP offers a stop-and-wait way to dispose of situations when an error happens.

For example, when a client reads a file from a server, it will send an RRQ. Then some error happens and no ack will be received from the server, so the client will wait forever. However, if the client sets a timeout for each RRQ it sends to the server, such  dilemma as above would be avoided.

 

5. Questions

  1. To test the program, we need to create these errors: no send? no ack? how?
  2. If a server has more than 2 clients(this is no wonder)?
  3. Be careful with these file with size=0, size%512=0.
  4. Block size = 512? Really so? Could block size be negotiated between the server and the client?
  5. Timeout set to 5 seconds? What value is appropriate? Could the timeout value be adjusted dynamically?
  6. If the client resend it's RRQ or WRQ, what should we do?

 

6. Conclusion & Further work

This is a small but interesting project, accomplishable both in Windows and in Unix. After we have dealt with all the problems in Section 5, we can actually do many other things. For example, there are many other options in TFTP we can implement(see RFC 2347), and we can also create a simple UI for the protocol. Moreover, we can employ an access control on the clients(IP, authorization, access time).

 

7. Reference Materials

  • RFC 1350: Trivial File Transfer Protocol
  • RFC 2347: TFTP Option Extension
  • RFC 2348: TFTP Blocksize Option
  • RFC 2349: TFTP Timeout Interval and Transfer Size Options

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/yejp/archive/2012/12/17/2822472.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值