int bootstrap(call_t *c) {
    struct nodedata *nodedata = get_node_private_data(c);
    struct protocoleData *entitydata = get_entity_private_data(c);

    call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity};
	/* get mac header overhead */
    nodedata->overhead = GET_HEADER_SIZE(&c0);

    broadcast_hello(c, NULL);
    uint64_t at=get_time_now()+time_seconds_to_nanos(2);
    scheduler_add_callback(at, c, init_lbop, NULL);
    at=get_time_now()+time_seconds_to_nanos(3);
    scheduler_add_callback(at, c, broadcast_lmst, NULL);

   return 0;
}
Esempio n. 2
0
uint64_t get_time_next(uint64_t debuut,uint64_t period,uint64_t timeNow)
{
    double peri=time_nanos_to_seconds(period);
    double deb=time_nanos_to_seconds(debuut);
    double ti=time_nanos_to_seconds(timeNow);


    double time_app=ti-deb;
    int nbr=time_app/peri;
    nbr++;

    double debut=peri * nbr + deb;
    uint64_t at=time_seconds_to_nanos(debut) + get_random_time_range(0,period);//*/

    DEBUG;
        //    printf("TA: %lf nbr: %d (+ %lf =)DB: %lf\n",time_app,nbr,time_nanos_to_seconds(entitydata->debut),debut);//*/

    return at;
}
int bootstrap(call_t *c) {
    struct nodedata *nodedata = get_node_private_data(c);
    struct protocoleData *entitydata = get_entity_private_data(c);
	
    call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity};
	/* get mac header overhead */
    nodedata->overhead = GET_HEADER_SIZE(&c0);
	
	int i;
	for(i = 0 ; i < get_node_count() ; i++)
	{
		nodedata->lastIDs[i] = -1;
		nodedata->energiesRem[i] = battery_remaining(c) - 2*getCoutFromDistance(getRange(c), entitydata->alpha, entitydata->c);
	}
	
	broadcast_hello(c, NULL);
    uint64_t at=get_time_now()+time_seconds_to_nanos(2);
    scheduler_add_callback(at, c, broadcast_hello2, NULL);
	
    return 0;
}
Esempio n. 4
0
void get_one_hop(call_t *c, double eps)
{
    uint64_t at=c->node*time_seconds_to_nanos(eps);
    scheduler_add_callback(at, c, init_one_hop, NULL);
}