Exploring TFTP Client Example on W55RP20-EVB-PICO
Running a TFTP Client in C on Visual Studio Code
https://github.com/WIZnet-ioNIC/WIZnet-PICO-C/tree/main/examples/ftp
In this WCC, an example for the TFTP Client is covered. If you're looking for an example for FTP, you can find examples for both the Server and Client here.
TFTP (Trivial File Transfer Protocol) and FTP (File Transfer Protocol) are both file transfer protocols, but they have several important differences.
TFTP vs FTP
Complexity:
- TFTP is a very simple protocol, supporting only file read and write operations.
- FTP provides rich file management features, including directory navigation, file deletion, and permission management, in addition to file transfer.
Underlying Protocol:
- TFTP uses UDP, enabling fast transfers but with less reliability.
- FTP uses TCP, ensuring reliable transfers by setting up a connection and retransmitting data in case of errors.
Security:
- TFTP lacks security features and does not support authentication or encryption.
- FTP does not encrypt by default, but secure versions such as FTPS and SFTP provide encryption and authentication.
Use Cases:
- TFTP is mainly used for small file transfers between network devices, network booting, and firmware updates.
- FTP is suitable for general file transfers, file sharing between servers and clients, and transferring large files.
Hardware Requirements
- W55RP20-EVB-PICO
- Desktop or Laptop
- USB Type-C Cable
Software Tools
- Visual Studio Code
- Serial Terminal : Tera Term
- TFTP Server : SolarWinds TFTP
Setup board
To run this example, you need to apply the 0002_iolibrary_driver_tftp.patch file as follows:
git apply ./patches/0002_iolibrary_driver_tftp.patch
And need to set up the board in the 'WIZnet-PICO-PING-C/CMakeLists.txt' file.
Activate the 8th line in this file by setting 'set(BOARD_NAME W55RP20_EVB_PICO)'.
If you want to view log messages via USB serial, modify the following file as shown below.
Setup Network Info
Set up the desired network information.
The IP address of the server to test and the name of the file to be read should be changed according to your environment at the following location.
If you want to change the port setting for the TFTP server to test in the example, you can modify it as follows.
If the target system does not use a storage device, you need to comment this part in '#define F_STORAGE'
in the 'libraries\ioLibrary_Driver\Internet\TFTP\tftp.h'
directory. In this example, since the storage is not used, this part has been commented.
Run
The TFTP server used for testing in this example can be found here.
After launching the server, navigate to the File tab in the upper-left corner and select the Configure menu to set the file path that the client will read from.
Then, create the file to be read in the configured path.
The following is the example execution screen.
The following is the screen when the read request fails.
The TFTP read request process, based on the captured Wireshark screen, is as follows.
- The server receives the request and sends the first data block to the client.
- The client acknowledges the data block by sending an ack packet.
- The server then sends the next data block.
- The transfer ends when the last data block is smaller than 512 bytes, indicating the end of the file.
Thank you for reading !