{"id":23666112,"url":"https://github.com/rambod-rahmani/tftp","last_synced_at":"2025-09-01T19:31:51.687Z","repository":{"id":97341500,"uuid":"216620784","full_name":"rambod-rahmani/tftp","owner":"rambod-rahmani","description":"A simple TFTP Server and Client Implementation in C.","archived":false,"fork":false,"pushed_at":"2020-01-04T10:26:36.000Z","size":3359,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-29T05:58:01.379Z","etag":null,"topics":["c","client","client-server","filetransfer","network-programming","networking","server","tftp","tftp-client","tftp-protocol","tftp-server"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rambod-rahmani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-21T17:00:10.000Z","updated_at":"2024-12-26T10:27:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd0da281-543d-4ba0-83ba-8547b1a744b7","html_url":"https://github.com/rambod-rahmani/tftp","commit_stats":null,"previous_names":["rambod-rahmani/tftp","rambodrahmani/tftp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Ftftp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Ftftp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Ftftp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Ftftp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rambod-rahmani","download_url":"https://codeload.github.com/rambod-rahmani/tftp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231708706,"owners_count":18414526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","client","client-server","filetransfer","network-programming","networking","server","tftp","tftp-client","tftp-protocol","tftp-server"],"created_at":"2024-12-29T06:43:24.027Z","updated_at":"2024-12-29T06:43:29.305Z","avatar_url":"https://github.com/rambod-rahmani.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TFTP\nA simple TFTP Server and Client Implementation in C. Only `RRQ`, `DATA`, `ACK`,\nand `ERROR` packets have been implemented. The `WRQ` packet is to be\nimplemented.\n\n# Compilation\nThe Project comes with a Makefile which can be used to compile everything:\n```\n$ make\nCompiled src/common.c successfully.\nCompiled src/tftp_server.c successfully.\nCompiled src/tftp_client.c successfully.\nLinking obj/tftp_server.o obj/common.o completed.\nLinking obj/tftp_client.o obj/common.o completed.\n```\nNo clean up is made after compilation. You can manually do it using:\n```\nmake cleanup\n```\n\n# Usage\n![How to use example screenshot](/references/usage.png)\n\n### Project structure\n```\nTFTP |--base_dir/      Contains sample files for testing purposes\n     |--bin/           Contains executable files after linking\n     |--include/       Contains header files (.h)\n     |--obj/           Contains object files (.o) after compilation\n     |--references/    Contains reference PDF files\n     |--src/           Contains source code files (.c)\n     |--Makefile       Project Makefile\n```\n\n# TFTP Protocol\nFollows a brief introduction to the TFTP Protocol as introduced by\n[RFC 1350 -  THE TFTP PROTOCOL (REVISION 2)](https://tools.ietf.org/html/rfc1350)\n. TFTP is a very simple protocol used to transfer files. It is from this that\nits name comes, Trivial File Transfer Protocol or TFTP.\n\nThe protocol was originally designed by Noel Chiappa, and wasredesigned by him,\nBob Baldwin and Dave Clark, with comments fromSteve Szymanski.\n\nIt has been implementedon top of the Internet User Datagram protocol (UDP or\nDatagram) so it may be used to move files between machines on different networks\nimplementing UDP. It is designed to be small and easy to implement. Therefore,\nit lacks most of the features of a regular FTP. The only thing it can do is read\nand write files (or mail) from/to a remote server. It cannot list directories,\nand currently has no provisions for user authentication. In common with other\nInternet protocols, it passes 8 bit bytes of data.\n\nThree modes of transfer are currently supported: netascii (This is ascii as\ndefined in \"USA Standard Code for Information Interchange\" with the\nmodifications specified in \"Telnet Protocol Specification\"). Note that it is 8\nbit ascii. The term \"netascii\" will be used throughout this document to mean\nthis particular version of ascii.); octet (This replaces the \"binary\" mode of\nprevious versions of this document.) raw 8 bit bytes; mail,netascii characters\nsent to a user rather than a file. (The mail mode is obsolete and should not be\nimplemented or used.)  Additional modes can be defined by pairs of cooperating\nhosts.\n\nAny transfer begins with a request to read or write a file, which also serves to\nrequest a connection. If the server grants the request, the connection is opened\nand the file is sent in fixed length blocks of 512 bytes. Each data packet\ncontains one block of data, and must be acknowledged by an acknowledgment packet\nbefore the next packet can be sent. A data packet of less than 512 bytessignals\ntermination of a transfer.\n\nMost errors cause termination of the connection. An error is signalled by\nsending an error packet. This packet is not acknowledged, and not retransmitted\n(i.e., a TFTP server or user mayterminate after sending an error message), so\nthe other end of the connection may not get it. Therefore timeouts are used to\ndetect such a termination when the error packet has been lost. Errors are caused\nby three types of events: not being able to satisfy the request (e.g., file not\nfound, access violation, or no such user), receiving a packet which cannot be\nexplained by a delay or duplication in the network (e.g., an incorrectly formed\npacket), and losing access to a necessary resource (e.g., disk full or access\ndenied during a transfer).\n\n### Initial Connection Protocol\nA transfer is established by sending a request (WRQ to write onto a foreign file\nsystem, or RRQ to read from it), and receiving apositive reply, an\nacknowledgment packet for write, or the first datapacket for read. In general an\nacknowledgment packet will contain the block number of the data packet being\nacknowledged. Each data packet has associated with it a block number; block\nnumbers are consecutive and begin with one. Since the positive response to a\nwrite request is an acknowledgment packet, in this special case the block number\nwill be zero. (Normally, since an acknowledgment packetis acknowledging a data\npacket, the acknowledgment packet will contain the block number of the data\npacket being acknowledged). If the reply is an error packet, then the request\nhas been denied.\n\n### TFTP Packets\nTFTP supports five types of packets, all of which have been mentioned above:\n```\n    opcode  operation\n      1     Read request (RRQ)\n      2     Write request (WRQ)\n      3     Data (DATA)\n      4     Acknowledgment (ACK)\n      5     Error (ERROR)\n```\nThe TFTP header of a packet contains the opcode associated with that packet.\n\nRRQ and WRQ packets (opcodes 1 and 2 respectively) have the formats hown below:\n```\n 2 bytes    string     1 byte    string    1 byte\n+--------+------------+------+------------+------+\n| Opcode |  Filename  |   0  |    Mode    |   0  |\n+--------+------------+------+------------+------+\n```\nThe file name is a sequence of bytes in netascii terminated by a zero byte. The\nmode field contains the string \"netascii\", \"octet\", or \"mail\" (or any\ncombination of upperand lower case, such as \"NETASCII\", \"NetAscii\", etc.) in\nnetascii indicating the three modes defined in the protocol.\n\nData is actually transferred in DATA packets\n```\n 2 bytes     2 bytes      n bytes\n+--------+------------+------------+\n| Opcode |   Block #  |   Data     |\n+--------+------------+------------+\n\n```\nDATA packets (opcode = 3) have a block number and data field. The block numbers\non data packets begin with one and increase by one for each new block of data.\nThis restriction allows the program to use a single number to discriminate\nbetween new packets and duplicates. The data field is from zero to 512 bytes\nlong. If it is 512 bytes long, the block is not the last block of data; if it is\nfrom zero to 511 bytes long, it signals the end of the transfer.\n\nACK Packet:\n```\n 2 bytes    2 bytes\n+--------+------------+\n| Opcode |   Block #  |\n+--------+------------+\n```\nAll packets other than duplicate ACK's and those used for termination are\nacknowledged unless a timeout occurs. Sending a DATA packet is an acknowledgment\nfor the first ACK packet of the previous DATA packet.\n\nERROR packet:\n```\n 2 bytes     2 bytes      string    1 byte\n+--------+------------+------------+------+\n| Opcode |  ErrorCode |   ErrMsg   |   0  |\n+--------+------------+------------+------+\n```\nAn ERROR packet can be the acknowledgment of any other type of packet. The error\ncode is an integer indicating the nature of the error. The error message is\nintended for human consumption, and should be in netascii. Like all other\nstrings, it is terminated witha zero byte.\n\nError Codes:\n```\n   Value     Meaning\n   --------------------------------------------------\n   0         Not defined, see error message (if any).\n   1         File not found.\n   2         Access violation.\n   3         Disk full or allocation exceeded.\n   4         Illegal TFTP operation.\n   5         Unknown transfer ID.\n   6         File already exists.\n   7         No such user.\n   --------------------------------------------------\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frambod-rahmani%2Ftftp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frambod-rahmani%2Ftftp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frambod-rahmani%2Ftftp/lists"}