Skip to content

Commit

Permalink
Add csma statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentderu committed Apr 18, 2014
1 parent c68779c commit 9562c9c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/net/mac/csma.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ LIST(neighbor_list);
static void packet_sent(void *ptr, int status, int num_transmissions);
static void transmit_packet_list(void *ptr);

int packet_overflow;
int neighbor_overflow;

/*---------------------------------------------------------------------------*/
int
csma_allocated_packets(void)
{
return MAX_QUEUED_PACKETS - memb_count(&packet_memb);
}
/*---------------------------------------------------------------------------*/
int
csma_allocated_neighbors(void)
{
return CSMA_MAX_NEIGHBOR_QUEUES - memb_count(&neighbor_memb);
}
/*---------------------------------------------------------------------------*/
static struct neighbor_queue *
neighbor_queue_from_addr(const linkaddr_t *addr)
Expand Down Expand Up @@ -404,8 +419,10 @@ send_packet(mac_callback_t sent, void *ptr)
PRINTF("csma: Neighbor queue full\n");
}
PRINTF("csma: could not allocate packet, dropping packet\n");
packet_overflow++;
} else {
PRINTF("csma: could not allocate neighbor, dropping packet\n");
neighbor_overflow++;
}
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1);
}
Expand Down Expand Up @@ -443,6 +460,7 @@ init(void)
memb_init(&packet_memb);
memb_init(&metadata_memb);
memb_init(&neighbor_memb);
packet_overflow = 0;
}
/*---------------------------------------------------------------------------*/
const struct mac_driver csma_driver = {
Expand Down
6 changes: 6 additions & 0 deletions core/net/mac/csma.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ extern const struct mac_driver csma_driver;

const struct mac_driver *csma_init(const struct mac_driver *r);

extern int csma_allocated_packets(void);
extern int csma_allocated_neighbors(void);

extern int packet_overflow;
extern int neighbor_overflow;

#endif /* CSMA_H_ */

0 comments on commit 9562c9c

Please sign in to comment.