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[]) {
|
int main(int argc, char const *argv[]) {
|
||||||
|
|
||||||
// We create the neighbourhood table
|
while(CONTINUE){
|
||||||
// We create the message table
|
|
||||||
// We create our own message.
|
|
||||||
|
|
||||||
// Listen for incoming packets
|
// We create the neighbourhood table
|
||||||
listen_for_packets();
|
// We create the message table
|
||||||
// For every packet recivied, we fork,
|
// We create our own message.
|
||||||
// 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();
|
|
||||||
|
|
||||||
|
// 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
|
time_t delay = time(NULL) + 20;
|
||||||
// thread, being run every 20 seconds.
|
while(! (delay < time(NULL)){
|
||||||
// Every 20 sec, if we have less than 5 neighbours, we ask for more peers
|
// Theses functions are there for general book-keeping,and run in there own
|
||||||
// by sending out a TLV neighbour Request at a random peer.
|
// thread, being run every 20 seconds.
|
||||||
t_ask_for_more_peers();
|
// Every 20 sec, if we have less than 5 neighbours, we ask for more peers
|
||||||
// Every 20 sec, we also check for a peer that didn't emit a new message for
|
// by sending out a TLV neighbour Request at a random peer.
|
||||||
// the past 70 sec, if he's temporary, we delete him from the neighbourhood.
|
t_ask_for_more_peers();
|
||||||
t_update_neighbours();
|
// Every 20 sec, we also check for a peer that didn't emit a new message for
|
||||||
// We send out a TLV Network hash to get an ideal of the network state.
|
// the past 70 sec, if he's temporary, we delete him from the neighbourhood.
|
||||||
t_get_network_state();
|
t_update_neighbours();
|
||||||
|
// We send out a TLV Network hash to get an ideal of the network state.
|
||||||
|
t_get_network_state();
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user