1. Introduction The SUFTP is a custom protocol to be used in a small-scale peer-to-peer file transfer application. Its main objective is not to replace any widely-used protocol for peer-to-peer distribution (such as Gnutella or BitTorrent), but to explore techniques in peer-to-peer networks and distribution. SUFTP stands for Simple and Unreliable File Transfer Protocol. The unreliable does not come from the fact that files will commonly be corrupted; rather, it comes from the fact that UDP will be used for data transfer, and from the fact that no authentication will be performed by the server (hence, anyone can join the network and possibly compromise it). Because of the latter, it is not recommended that the protocol be used in any large network in its current state. 2. Overview The SUFTP is inspired from current peer-to-peer networks, such as Gnutella and BitTorrent. Each of these protocols has their own benefits and drawbacks. For example, the Gnutella network contains a lot of bogus files and other malware. The SUFTP will take certain things from each protocol, as well as custom things, and combine them together. 3.1 Description of Service The SUFTP service will use UDP on ports 55500 to 55510, which are declared as dynamic ports for private services as defined by the Internet Assigned Numbers Authority. As such, clients should ensure that no BitTorrent clients are running in that range since there may be conflicts. The Server computer must be located on a network that has all traffic on port 55500 forwarded to it. No other computer on the SUFTP network will accept messages on that port. Most computers today are located behind a Network Address Translator (NAT) since they are part of a network at home or in the office. This means that packets are sent to a router, and not a computer itself. The router must then decide what computer to send this packet to. That is why some services need port forwarding. However, the SUFTP network will not require users to forward any ports to their computer. This is because when each user connects, it sends an outbound message through its router. The router assigns this a random unused port (usually > 60000) in a table of sorts. Any messages received on this port will then be sent to the originating computer, as long as that entry remains in the table. The entry will be removed after a specified time of inactivity. For most routers, this is about 5 to 10 minutes. For this reason, every five minutes each client will send a very short PING command to the server who will reply, to keep the channels of communication open. There will be a Server computer that will keep a list of all users currently connected to the SUFTP network. When a client loads, it will contact the Server computer on port 55500 with its intentions to join the network. The Server will save the message’s IP address and public port number. Every time a message is either sent or received, the first word must be SUFTP, or else it will be ignored. When a client wants to initiate a search, they will send a QUERY command to the server containing the search term. The Server will iterate through the list of online users and send them all QUERY commands with the search term and how to contact the requester. Each client will load the shared directories (defined by the user) and will scan each file for a match. If a match is found, the searched client will fire back a response to the requester saying that it has the file, as well as the filename and CRC32 checksum. The requesting client, meanwhile, will wait approximately 20 seconds [for the command line version] for responses from other users. As confirmation messages are received, the checksums will be compared to one another. If it is unique, it will be added to the list as a new entry. If there is a duplicate checksum, that means that the files are absolutely identical and another source will be added to the list. The client will then be given the opportunity to select which file to get, or to cancel. The user will also be asked which file name to use. When a file is chosen, the client will request 100kB of random data. The average upload speed will be calculated. When each test is completed, the client will assign ratings to each other client that has the file. The client will then send a GET command to request the other clients for a certain part of the file. When the amount of data that has been requested from one client is completed, it will be checked whether more data should be requested from that client. If the downloading client is getting data from a computer slower than it could from the finished client, it will send the currently uploading client a STOPAT command with a decent offset, and the faster, inactive client another GET command. Server Commands SUFTP 100 HELLO – The message sent by a client to indicate it wants to join the network. SUFTP 101 BYE – The message sent by a client to indicate it is leaving the network. SUFTP 150 PING – The message sent by a client to keep the connection alive. If 2 in a row are missed, the client is dropped. SUFTP 151 PONG – The message sent by the server in response to a ping. SUFTP 200 QUERY text – The message sent by a client when it wants to search for a file. SUFTP 201 QUERY text addr port – The message sent by the server to online clients when it receives a query. SUFTP 999 BADSYN – Error message sent from server denoting a bad syntax error. Client Commands (Client-To-Client Communications Only) SUFTP 500 SPEEDTEST START – The message sent to initiate a speed analyzer. SUFTP 501 SPEEDTEST ACK – The message sent by a client requesting the next chunk of data in a speed analyzer. SUFTP 550 GET filename offset amount – The message sent by a client requesting a certain amount of data, in bytes. The amount should be evenly divisible by 4 096 bytes (4kB). SUFTP 551 STOPAT filename offset – The message sent by a client telling this one to stop sending the file at a certain byte, offset, from the beginning of the file. Offset should be divisible by 4 096 bytes (4kB).