https://github.com/somekay/erlang-dht
A very simple example of implementing a structured P2P network (DHT) in Erlang.
https://github.com/somekay/erlang-dht
Last synced: about 1 year ago
JSON representation
A very simple example of implementing a structured P2P network (DHT) in Erlang.
- Host: GitHub
- URL: https://github.com/somekay/erlang-dht
- Owner: SomeKay
- Created: 2009-04-21T15:39:19.000Z (about 17 years ago)
- Default Branch: master
- Last Pushed: 2009-04-21T15:55:52.000Z (about 17 years ago)
- Last Synced: 2025-04-04T18:11:18.560Z (about 1 year ago)
- Language: Erlang
- Homepage:
- Size: 73.2 KB
- Stars: 33
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
Structured P2P network simulation in Erlang
Author: Kristian Poslek
_________________________________________________________________
This is a very simple structured P2P network simulation in Erlang
that's based on processes as peers and a self-organizing network.
_________________________________________________________________
Usage instructions
==================
Add the first peer
Name = peer:add(name).
Example: John = peer:add(john).
Add any other peer
Name = peer:add(name, Sponsor).
where Sponsor is another peer already in the network.
Example: Mary = peer:add(mary, John).
Remove a peer
Name!stop.
where Name is the peer that should be removed.
Example: John!stop.
Display the status of a peer
Name!status.
where Name is the peer that's status should be displayed.
Example: John!status.
Display the whole ring
Name!showRing.
where Name is the peer that should be the starting point of the ring.
Example: John!showRing.
Add a resource
Name!{put, resource}.
where Name is the peer that's inserting a new resource into the network;
the resource is going to be placed in the correct range of the ring.
Example: John!{put, secretdocument}.
Get a resource
Name!{get, resource}.
where Name is the peer that's getting a resource.
Example: John!{get, secretdocument}.
Input test data
test:addItems(Name).
where Name is the peer that should be adding the test data into the network.
Ecample: test:addItems(John).
Test scenario
=============
This little test scenario is designed to show how the network organizes itself
when someone enters or exits.
Enter these commands into the erl shell one after another.
John = peer:add(john).
Mary = peer:add(mary, John).
Ann = peer:add(ann, Mary).
Gordan = peer:add(gordan, John).
Mary!showRing.
Mary!{put, testdocument}.
Mary!showRing.
test:addItems(John).
Ann!showRing.
John!stop.
Ann!showRing.
NewJohn = peer:add(john, Mary).
Ann!showRing.