Add per neighbor packet throttle
This commit is contained in:
parent
91d84a3086
commit
7cbd59df03
|
@ -108,6 +108,13 @@ struct neighbor_queue {
|
|||
#define CSMA_MAX_NEIGHBOR_QUEUES 2
|
||||
#endif /* CSMA_CONF_MAX_NEIGHBOR_QUEUES */
|
||||
|
||||
/* The maximum number of pending packet per neighbor */
|
||||
#ifdef CSMA_CONF_MAX_PACKET_PER_NEIGHBOR
|
||||
#define CSMA_MAX_PACKET_PER_NEIGHBOR CSMA_CONF_MAX_PACKET_PER_NEIGHBOR
|
||||
#else
|
||||
#define CSMA_MAX_PACKET_PER_NEIGHBOR MAX_QUEUED_PACKETS
|
||||
#endif /* CSMA_CONF_MAX_PACKET_PER_NEIGHBOR */
|
||||
|
||||
#define MAX_QUEUED_PACKETS QUEUEBUF_NUM
|
||||
MEMB(neighbor_memb, struct neighbor_queue, CSMA_MAX_NEIGHBOR_QUEUES);
|
||||
MEMB(packet_memb, struct rdc_buf_list, MAX_QUEUED_PACKETS);
|
||||
|
@ -348,6 +355,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||
|
||||
if(n != NULL) {
|
||||
/* Add packet to the neighbor's queue */
|
||||
if(list_length(n->queued_packet_list) < CSMA_MAX_PACKET_PER_NEIGHBOR) {
|
||||
q = memb_alloc(&packet_memb);
|
||||
if(q != NULL) {
|
||||
q->ptr = memb_alloc(&metadata_memb);
|
||||
|
@ -392,6 +400,9 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||
list_remove(neighbor_list, n);
|
||||
memb_free(&neighbor_memb, n);
|
||||
}
|
||||
} else {
|
||||
PRINTF("csma: Neighbor queue full\n");
|
||||
}
|
||||
PRINTF("csma: could not allocate packet, dropping packet\n");
|
||||
} else {
|
||||
PRINTF("csma: could not allocate neighbor, dropping packet\n");
|
||||
|
|
Loading…
Reference in a new issue