From f3dfd885ccaa7b94fe2937580b27358473b2ad48 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Mon, 24 Jun 2013 00:40:33 -0400 Subject: [PATCH] Updated readme and DHT.h --- README.md | 11 +++++++++-- core/DHT.h | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 708a3591..f0b92d66 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,13 @@ Proposal of a free as in freedom skype replacement: "friends" list: A list containing the node_ids of all our "friends" or clients we want to connect to. Also contains the ip addresses + port + node_ids + timestamp(of last ping like in the client list) of the 8 clients closest (mathematically see bittorrent doc) to each "friend" + + Two pinged lists: + -One for storing a list of ips along with their ping_ids and a timestamp for the ping requests + -One for storing a list of ips along with their ping_ids and a timestamp for the get nodes requests + Entries in the pinged lists expire after 5 seconds. + If one of the lists becomes full, the expire rate reduces itself one second or the new ping takes the place of the oldest one. + Entries in client list and "friends" list expire after 300 seconds without ping response. Each client stores a maximum of 32 entries in its client list. @@ -79,7 +86,7 @@ Proposal of a free as in freedom skype replacement: When a client receives a response: -Ping response - -If the node was previously pinged with a matching ping_id + -If the node was previously pinged with a matching ping_id (check in the corresponding pinged list.) -If the node is in the client list the matching client's timestamp is set to current time. -If the node is in the "friends" list the matching client's timestamp is set to current time for every occurrence. -If the node is not in the client list: @@ -94,7 +101,7 @@ Proposal of a free as in freedom skype replacement: -If not, nothing happens. -Send nodes - -If the ping_id matches what we sent previously: + -If the ping_id matches what we sent previously (check in the corresponding pinged list.): -Each node in the response is pinged. diff --git a/core/DHT.h b/core/DHT.h index 90036525..f1d2e5ae 100644 --- a/core/DHT.h +++ b/core/DHT.h @@ -53,6 +53,13 @@ typedef struct }Friend; +typedef struct +{ + IP_Port ip_port; + uint32_t ping_id; + uint32_t timestamp; + +}Pinged; //Add a new friend to the friends list @@ -92,6 +99,9 @@ void bootstrap(IP_Port ip_port); //Global variables +//Our client id +char self_client_id[32]; + //Our UDP socket. //We only use one so it's much easier to have it as a global variable int sock; @@ -99,4 +109,11 @@ int sock; Client_data client_list[32]; //Let's start with a static array for testing. -Friend friends_list[256] \ No newline at end of file +Friend friends_list[256]; +uint16_t num_friends; + +//The list of ip ports along with the ping_id of what we sent them and a timestamp +//TODO: make this more efficient looping up to 128 times is a bit... +Pinged pings[128]; + +Pinged send_nodes[64]; \ No newline at end of file