Modifications pour faire le message toutes les 20 secondes
This commit is contained in:
parent
2b9e67e627
commit
f625058a3c
55
src/node.c
55
src/node.c
@ -53,33 +53,38 @@ void work_with_tlvs(struct tlvs_list receivied_tlvs){
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
|
||||
// We create the neighbourhood table
|
||||
// We create the message table
|
||||
// We create our own message.
|
||||
while(CONTINUE){
|
||||
|
||||
// Listen for incoming packets
|
||||
listen_for_packets();
|
||||
// For every packet recivied, we fork,
|
||||
// then we make sure it's conform
|
||||
// We then extract the data from it to make it easy to work with
|
||||
check_header();
|
||||
// If the sender is not in the neighbourhood, and we have 15 neighbours, we
|
||||
// ignore the packet. Otherwise, we add him to the neighbourhood, marked as
|
||||
// temporary.
|
||||
update_neighbours();
|
||||
// We then look at the differents TLVs in the packet.
|
||||
work_with_tlvs();
|
||||
// We create the neighbourhood table
|
||||
// We create the message table
|
||||
// We create our own message.
|
||||
|
||||
// Listen for incoming packets
|
||||
listen_for_packets();
|
||||
// For every packet recivied, we fork,
|
||||
// then we make sure it's conform
|
||||
// We then extract the data from it to make it easy to work with
|
||||
check_header();
|
||||
// If the sender is not in the neighbourhood, and we have 15 neighbours, we
|
||||
// ignore the packet. Otherwise, we add him to the neighbourhood, marked as
|
||||
// temporary.
|
||||
update_neighbours();
|
||||
// We then look at the differents TLVs in the packet.
|
||||
work_with_tlvs();
|
||||
|
||||
// Theses functions are there for general book-keeping,and run in there own
|
||||
// thread, being run every 20 seconds.
|
||||
// Every 20 sec, if we have less than 5 neighbours, we ask for more peers
|
||||
// by sending out a TLV neighbour Request at a random peer.
|
||||
t_ask_for_more_peers();
|
||||
// Every 20 sec, we also check for a peer that didn't emit a new message for
|
||||
// the past 70 sec, if he's temporary, we delete him from the neighbourhood.
|
||||
t_update_neighbours();
|
||||
// We send out a TLV Network hash to get an ideal of the network state.
|
||||
t_get_network_state();
|
||||
time_t delay = time(NULL) + 20;
|
||||
while(! (delay < time(NULL)){
|
||||
// Theses functions are there for general book-keeping,and run in there own
|
||||
// thread, being run every 20 seconds.
|
||||
// Every 20 sec, if we have less than 5 neighbours, we ask for more peers
|
||||
// by sending out a TLV neighbour Request at a random peer.
|
||||
t_ask_for_more_peers();
|
||||
// Every 20 sec, we also check for a peer that didn't emit a new message for
|
||||
// the past 70 sec, if he's temporary, we delete him from the neighbourhood.
|
||||
t_update_neighbours();
|
||||
// We send out a TLV Network hash to get an ideal of the network state.
|
||||
t_get_network_state();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user