- 想在ESP32上用TCP来实现ftp服务器,抓一下ftp通信包分析一下。
- 总的来说就是两个TCP通道,一个命令通道,一个数据通道;
- 数据通道只有在遍历目录、下载、上传的时候才开启,其余时候均不开启;
- 主要就是协议对接好就OK咯。
USER
- USER slim
- 331 Password required for slim\r\n
PASS
- PASS root
- 230 Logged on\r\n
PWD
- PWD\r\n
- 257 “/” is current directory.\r\n
CWD
- CWD .\r\n
- 250 CWD successful. “/” is current directory.\r\n
LIST
- LIST\r\n
- 150 Opening data channel for directory listing of “/”\r\n
- data通道:目录内容
- 226 Successfully transferred “/”\r\n
NLST
- NLST\r\n
- 150 Opening data channel for directory listing of “/”\r\n
- data通道:目录内容
- 226 Successfully transferred “/”\r\n
MLSD
- MLSD\r\n
- 150 Opening data channel for directory listing of “/”\r\n
- data通道:发送目录信息
- 226 Successfully transferred “/”\r\n
TYPE
- TYPE A\r\n
- 200 Type set to A\r\n
STOR
- STOR /ftp_dir.c\r\n
- 150 Opening data channel for file upload to server of “/ftp_dir.c”\r\n
- data通道:发送文件内容
- 226 Successfully transferred “/ftp_dir.c”\r\n
1. STOR文本
2. STOR图片
RETR
- RETR /test_buff.c\r\n
- 150 Opening data channel for file download from server of “/test_buff.c”\r\n
- data通道:传输数据内容
- 226 Successfully transferred “/test_buff.c”\r\n
1. RETR文本
2. RETR图片
PORT
- PORT 127,0,0,1,210,140\r\n
- 200 Port command successful\r\n
PASV
- PASV\r\n
- 227 Entering Passive Mode (127,0,0,1,202,112)\r\n
- 异常情况
QUIT
- QUIT\r\n
- 221 Goodbye\r\n
DELE
- DELE /tmp.exe\r\n
- 250 File deleted successfully\r\n
MKD
- MKD dir1\r\n
- 257 “/dir1” created successfully\r\n
RMD
- RMD dir3\r\n
- 250 Directory deleted successfully\r\n
CDUP
- CDUP\r\n
- 200 CDUP successful. “/test.c” is current directory.\r\n
RNFR
- RNFR dir-1111\r\n
- 350 Directory exists, ready for destination name.\r\n
RNTO
- RNTO dir-new\r\n
- 250 file renamed successfully\r\n
FEAT
- FEAT
- 211-Features:\r\n
MDTM\r\n
REST STREAM\r\n
SIZE\r\n
MLST type*;size*;modify*;\r\n
MLSD\r\n
UTF8\r\n
CLNT\r\n
MFMT\r\n
EPSV\r\n
EPRT\r\n
211 End\r\n
[Current working directory: ]
SIZE
- SIZE /test_buff.c\r\n
- 213 5245\r\n
SYST
- SYST\r\n
- 215 UNIX emulated by FileZilla\r\n
NOOP
- NOOP\r\n
- 200 OK\r\n
ABOR
MODE
HELP
XPWD(不支持)
MDTM(不支持)
APPE(不支持)
AUTH (不支持)
最后记录一下响应码:
FTP返回码 | 响应码: |
---|---|
(响应代码 | 解释说明) |
110 | 新文件指示器上的重启标记 |
120 | 服务器准备就绪的时间(分钟数) |
125 | 打开数据连接,开始传输 |
150 | 打开连接 |
200 | 成功 |
202 | 命令没有执行 |
211 | 系统状态回复 |
212 | 目录状态回复 |
213 | 文件状态回复 |
214 | 帮助信息回复 |
215 | 系统类型回复 |
220 | 服务就绪 |
221 | 退出网络 |
225 | 打开数据连接 |
226 | 结束数据连接 |
227 | 进入被动模式(IP 地址、ID 端口) |
230 | 登录完成 |
250 | 文件行为完成 |
257 | 路径名建立 |
331 | 要求密码 |
332 | 要求帐号 |
350 | 文件行为暂停 |
421 | 服务关闭 |
425 | 无法打开数据连接 |
426 | 结束连接 |
450 | 文件不可用 |
451 | 遇到本地错误 |
452 | 磁盘空间不足 |
500 | 无效命令 |
501 | 错误参数 |
502 | 命令没有执行 |
503 | 错误指令序列 |
504 | 无效命令参数 |
530 | 未登录网络 |
532 | 存储文件需要帐号 |
550 | 文件不可用 |
551 | 不知道的页类型 |
552 | 超过存储分配 |
553 | 文件名不允许 |