help needed: computer networks project on linux using c and c++ (gcc and g++) I have a computer networks project this semester and specification is below.If any one knows where can i find sample code related to this ,please reply .Thanx I more thing the project is to be done on linux using c and c++ (gcc and g++). Phase 1:
Direct, resume supported, multi-part file downloading over Hypertext transfer protocol (HTTP)
Once a node sends out a query and finds results, it will then ask the user to select the result to download. This result, as described in the QueryHit Gnutella descriptor contains the following fields. # of hits Port IP Address Speed Result Set node identifier
Ignore the other fields and concentrate on port/IP for now. In this phase we assume that we know what file we want. All we need is to download it from the other nodes that have it. Once a node receives a QueryHit descriptor, it may initiate the direct download of one of the files described by the descriptor’s result set. Files are downloaded out of the Gnutella network (i.e. direct connection between the nodes). File data is never transferred over the Gnutella network.
The file download protocol is the HTTP. The node initiating the download sends a query string of the following form to the target node (the following message format is simplified for this phase, we will include file index later – so make your code changeable): GET /get/<file name>/ HTTP/1.0\r\n
Connection: Keep-Alive \r\n
Range: bytes=[start]-[finish]\r\n
User-Agent: Gnutella \r\n
\r\n
For example if we want to download 233kb of ‘mysong.mp3’ from 202.23.555.32:7777, the message will be: GET /get/mysong.mp3/ HTTP/1.0\r\n
Connection: Keep-Alive \r\n
Range: bytes=0-238592\r\n
User-Agent: Gnutella \r\n
\r\n
The target node will then reply: HTTP 200 OK\r\n
Server: Gnutella\r\n
Content-type: application/binary \r\n
Content-Length: 0238592 \r\n
\r\n …
The file content should follow this message on the specified range. The requesting node should be able to get the same file from multiple hosts simultaneously by specifying the range differently. Also, since this is no more a client server architecture, a node can simultaneously be downloading a file and uploading to others. A vibrant network like Gnutella is completely asynchronous so you should have a good hand on multi-threaded/multi-process programming as well as network communication.
The last specification of this phase is that the size of a message on HTTP/TCP is limited. You cannot and should not send the whole file at once. You need to divide the required chunk of files into more manageable chunks and send them one by one. Since the acknowledgements are being handled by TCP bellow HTTP, you don’t need to worry about that. But you should make sure that on the reciever’s end, the chunk is rebuilt properly and then all chunks are rebuilt properly to create the final file.
Last edited by irtiqa; October 23rd, 2008 at 10:53 AM.
|