Example #1
0
void hello_send(void *arg)
{
	RREP *rrep;
	u8_t flags = 0;
	struct in_addr dest;
	struct timeval now;
	long time_diff;
	
	gettimeofday(&now, NULL);

	if(timeval_diff(&now, &this_host.last_forward_time) > ACTIVE_ROUTE_TIMEOUT)
	{
		hello_stop();
		return;
	}

	time_diff = timeval_diff(&now, &this_host.last_broadcast_time);

	if(time_diff >= HELLO_INTERVAL)
	{
		rrep = rrep_create(flags, 0, 0, this_host.dev.ipaddr, this_host.seqno, this_host.dev.ipaddr, ALLOWED_HELLO_LOSS * HELLO_INTERVAL);

	/////////No ext	
	
		dest.s_addr = AODV_BROADCAST;
		aodv_socket_send((AODV_msg *)rrep, dest, RREP_SIZE, 1, &this_host.dev);

		timer_set_timeout(&hello_timer, HELLO_INTERVAL);
	}
	else
	{
		timer_set_timeout(&hello_timer, HELLO_INTERVAL - time_diff);
	}
}
Example #2
0
void hello_send(void *arg) {
  RREP *rrep;
  AODV_ext *ext = NULL;
  u_int8_t flags = 0;
  u_int64_t time_expired;
  rt_table_t *entry;
  int msg_size = RREP_SIZE;

  time_expired = get_currtime() - this_host->bcast_time;

  /* This check will ensure we don't send unnecessary hello msgs, in case
     we have sent other bcast msgs within HELLO_INTERVAL */
  if (time_expired >= HELLO_INTERVAL) {
    
#ifdef DEBUG_HELLO
    log(LOG_DEBUG, 0, "SEND_BCAST: sending Hello to %s", 
	ip_to_str(AODV_BROADCAST));   
#endif
    rrep = rrep_create(flags, 0, 0, this_host->ipaddr, this_host->seqno, 
		       this_host->ipaddr, ALLOWED_HELLO_LOSS*HELLO_INTERVAL);
    
    /* Assemble a RREP extension which contain our neighbor set... */
    if(unidir_hack) {
      u_int32_t neigh;
      int i;
      
      ext = (AODV_ext *)((char *)rrep + RREP_SIZE);
      ext->type = RREP_HELLO_NEIGHBOR_SET_EXT;
      ext->length = 0;
      for(i = 0; i < RT_TABLESIZE; i++) {
	entry = routing_table[i];
	while(entry != NULL) {
	  /* If an entry has an active hello timer, we asume that we are
	     receiving hello messages from that node... */
	  if(entry->hello_timer_id != 0) {
#ifdef DEBUG_HELLO
	    log(LOG_INFO, 0, "hello_send: Adding %s to hello neighbor set ext",
		ip_to_str(entry->dest));
#endif
	    neigh = htonl(entry->dest);
	    memcpy(AODV_EXT_NEXT(ext), &neigh, 4);
	    ext->length += 4;
	  }
	  entry = entry->next;
	}
      }
      if(ext->length)
	msg_size = RREP_SIZE + AODV_EXT_SIZE(ext);    
    }
    
    aodv_socket_send((AODV_msg *)rrep, AODV_BROADCAST, msg_size, 1);
    
    timer_new(HELLO_INTERVAL, hello_send, NULL);
  }
  else {
    timer_new((HELLO_INTERVAL - time_expired), hello_send, NULL);
  }
}