예제 #1
0
파일: collect.c 프로젝트: kincki/contiki
/*---------------------------------------------------------------------------*/
void
collect_set_sink(struct collect_conn *tc, int should_be_sink)
{
    if(should_be_sink) {
        tc->rtmetric = SINK;
#if !COLLECT_ANNOUNCEMENTS
        neighbor_discovery_start(&tc->neighbor_discovery_conn, tc->rtmetric);
#endif /* !COLLECT_ANNOUNCEMENTS */
    } else {
        tc->rtmetric = RTMETRIC_MAX;
    }
#if COLLECT_ANNOUNCEMENTS
    announcement_set_value(&tc->announcement, tc->rtmetric);
#endif /* COLLECT_ANNOUNCEMENTS */
    update_rtmetric(tc);
}
예제 #2
0
파일: collect.c 프로젝트: kincki/contiki
/*---------------------------------------------------------------------------*/
static void
node_packet_timedout(struct runicast_conn *c, const rimeaddr_t *to,
                     uint8_t transmissions)
{
    struct collect_conn *tc = (struct collect_conn *)
                              ((char *)c - offsetof(struct collect_conn, runicast_conn));

    PRINTF("%d.%d: timedout after %d retransmissions: packet dropped\n",
           rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1], transmissions);

    tc->forwarding = 0;
    neighbor_timedout_etx(neighbor_find(to), transmissions);
    update_rtmetric(tc);

    /* Remove the first packet on the queue, the packet that just timed out. */
    packetqueue_dequeue(&forwarding_queue);

    /* Send the next packet in the queue, if any. */
    send_queued_packet();
}
예제 #3
0
파일: collect.c 프로젝트: kincki/contiki
static void
adv_received(struct neighbor_discovery_conn *c, const rimeaddr_t *from,
             uint16_t rtmetric)
{
    struct collect_conn *tc = (struct collect_conn *)
                              ((char *)c - offsetof(struct collect_conn, neighbor_discovery_conn));
    struct neighbor *n;

    n = neighbor_find(from);

    if(n == NULL) {
        neighbor_add(from, rtmetric, 1);
    } else {
        neighbor_update(n, rtmetric);
        PRINTF("%d.%d: updating neighbor %d.%d, etx %d\n",
               rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1],
               n->addr.u8[RIMEADDR_SIZE-2], n->addr.u8[RIMEADDR_SIZE-1], rtmetric);
    }

    update_rtmetric(tc);
}
예제 #4
0
/*---------------------------------------------------------------------------*/
static void
node_packet_sent(struct runicast_conn *c, const rimeaddr_t *to,
		 uint8_t transmissions)
{
  struct collect_conn *tc = (struct collect_conn *)
    ((char *)c - offsetof(struct collect_conn, runicast_conn));

  PRINTF("%d.%d: sent to %d.%d after %d retransmissions\n",
	 rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
	 to->u8[0], to->u8[1],
	 transmissions);

  
  tc->forwarding = 0;
  neighbor_update_etx(neighbor_find(to), transmissions);
  update_rtmetric(tc);

  /* Remove the first packet on the queue, the packet that was just sent. */
  packetqueue_dequeue(&forwarding_queue);

  /* Send the next packet in the queue, if any. */
  send_queued_packet();
}
예제 #5
0
파일: collect.c 프로젝트: kincki/contiki
static void
received_announcement(struct announcement *a, const rimeaddr_t *from,
                      uint16_t id, uint16_t value)
{
    struct collect_conn *tc = (struct collect_conn *)
                              ((char *)a - offsetof(struct collect_conn, announcement));
    struct neighbor *n;

    n = neighbor_find(from);

    if(n == NULL) {
        neighbor_add(from, value, 1);
        PRINTF("%d.%d: new neighbor %d.%d, etx %d\n",
               rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1],
               from->u8[RIMEADDR_SIZE-2], from->u8[RIMEADDR_SIZE-1], value);
    } else {
        neighbor_update(n, value);
        PRINTF("%d.%d: updating neighbor %d.%d, etx %d\n",
               rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1],
               n->addr.u8[RIMEADDR_SIZE-2], n->addr.u8[RIMEADDR_SIZE-1], value);
    }

    update_rtmetric(tc);
}