Как использовать библиотеку DHT dht-example.c для распределенных хеш-таблиц
Я хочу использовать библиотеку BitTorrent DHT в качестве распределенных хеш-таблиц изнутри C-программы. Поэтому я скачал и скомпилировал его на своей машине - работал без нареканий. Теперь у меня есть исполняемый dht-пример, который выводит:
Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address]...
port [address port]...
Что я могу сделать с этим примером? Как играть с DHT: подключать распределенные машины, заполнять или читать хеш-таблицы с него?
Большое спасибо Ахим
1 ответ
is a minimalistic example provided in the mentioned DHT library.
After running
make
for compilatation you are supposed to run
./example-dht 6882 67.215.246.10 6881
. This will open a listening UDP socket on local port 6882 for talking to the DHT network.
But before your new peer is able to connect to the network, it needs at least one connected peer from which it can get more peers. This is where the third and fourth parameter/argument comes into action. It is the IP address and port combination of a known good node on the network, in this case
router.bittorrent.com
. This process is called bootstraping.
The program does not accept instructions from standard input, but instead via kernel signals , and . Use
kill -L
to list signal numbers on your machine and then command
ps aux | grep example-dht
while is running to obtain the process ID of
example-dht
.
For starting a search for peers of the infohash, hardcoded in
dht-example.c
, issue the command , where is the number of the
SIGUSR1
signal and is the process ID of . Observe the standard output of the program.
For dumping other nodes in our bucket and bucket 0, issue the command , where is the number of the
SIGUSR2
signal and is the process ID of . Observe the standard output of the program.
For stopping
dht-exmample
, issue the command
kill -XX YYYYY
where
XX
is the number of the
SIGINT
signal and
YYYYY
is the process ID of . Observe the standard output of the
dht-example
program.