Skip to content

realization of the peer-to-peer file loader using grpc

License

Notifications You must be signed in to change notification settings

elizarpif/grpctorrent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Torrent

Requirements

Peer-to-peer file loader realizes the next requirements:

  • Information about the file to upload stored in a defined handler: it stores information about division of the file into samll fragments
  • Each client reports data about small fragments to the central server. The client have already downloaded all fragments and it suggests to take them to other clients
  • The client contacts to server for get a list of the available clients who are owners of the interest file
  • The client contacts to other clients by each fragment
  • After collecting all the pieces, the client collects the file and reports that the file has been downloaded and is available

Realization

api

API description at the grpc paradigm

tracker

The central server. It stores information about peers

peer

The "torrent"-client

Work example | Пример работы

  • launch the server
cd tracker
go build .
./tracker
  • launch the first client (it will upload the file)
cd peer
go build .
./peer -http=8002 -grpc=9002
  • launch the second client (it will upload file from the first client)
cd peer
go build .
./peer -http=8000 -grpc=9000
  • upload file to the server
curl -d "{\"name\":\"/home/space/5 sem/networks/grpctorrent/peer/some.txt\"}" -X POST http://localhost:8002/upload | jq
  • ask information about the file
curl http://localhost:8002/files/some.txt | jq
{
  "name": "some.txt",
  "piece_length": "1",
  "pieces": "24",
  "length": "24",
  "hash": "9702842ac5824617babda6a32791ac2f"
}
  • download the file
curl -d "{\"hash\":\"9702842ac5824617babda6a32791ac2f\"}" -X POST http://localhost:8000/download | jq
{
  "name": "some.txt",
  "piece_length": "1",
  "pieces": "24",
  "length": "24",
  "hash": "9702842ac5824617babda6a32791ac2f"
}
  • get the list of the all files on the tracker-server
curl http://localhost:8000/files | jq
{
  "count": "1",
  "files": [
    {
      "name": "some.txt",
      "piece_length": "1",
      "pieces": "24",
      "length": "24",
      "hash": "9702842ac5824617babda6a32791ac2f"
    }
  ]
}

About

realization of the peer-to-peer file loader using grpc

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages