Cleanup CSMA logging
This commit is contained in:
parent
1dcba2a700
commit
07765f8e70
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE_STR "CSMA"
|
#define LOG_MODULE_STR "
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL MAC_LOG_LEVEL
|
||||||
|
|
||||||
/* Constants of the IEEE 802.15.4 standard */
|
/* Constants of the IEEE 802.15.4 standard */
|
||||||
@ -172,7 +172,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
|
|||||||
|
|
||||||
if(NETSTACK_FRAMER.create() < 0) {
|
if(NETSTACK_FRAMER.create() < 0) {
|
||||||
/* Failed to allocate space for headers */
|
/* Failed to allocate space for headers */
|
||||||
LOG_ERR("csma: send failed, too large header\n");
|
LOG_ERR("send failed, too large header\n");
|
||||||
ret = MAC_TX_ERR_FATAL;
|
ret = MAC_TX_ERR_FATAL;
|
||||||
} else {
|
} else {
|
||||||
#if CSMA_802154_AUTOACK
|
#if CSMA_802154_AUTOACK
|
||||||
@ -244,7 +244,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("csma tx noack\n");
|
LOG_WARN("tx noack\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -290,7 +290,7 @@ transmit_from_queue(void *ptr)
|
|||||||
if(n) {
|
if(n) {
|
||||||
struct packet_queue *q = list_head(n->packet_queue);
|
struct packet_queue *q = list_head(n->packet_queue);
|
||||||
if(q != NULL) {
|
if(q != NULL) {
|
||||||
LOG_INFO("csma: preparing number %d %p, queue len %d\n", n->transmissions, q,
|
LOG_INFO("preparing number %d %p, queue len %d\n", n->transmissions, q,
|
||||||
list_length(n->packet_queue));
|
list_length(n->packet_queue));
|
||||||
/* Send first packet in the neighbor queue */
|
/* Send first packet in the neighbor queue */
|
||||||
queuebuf_to_packetbuf(q->buf);
|
queuebuf_to_packetbuf(q->buf);
|
||||||
@ -314,7 +314,7 @@ schedule_transmission(struct neighbor_queue *n)
|
|||||||
delay = random_rand() % delay;
|
delay = random_rand() % delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("csma: scheduling transmission in %u ticks, NB=%u, BE=%u\n",
|
LOG_INFO("scheduling transmission in %u ticks, NB=%u, BE=%u\n",
|
||||||
(unsigned)delay, n->collisions, backoff_exponent);
|
(unsigned)delay, n->collisions, backoff_exponent);
|
||||||
ctimer_set(&n->transmit_timer, delay, transmit_from_queue, n);
|
ctimer_set(&n->transmit_timer, delay, transmit_from_queue, n);
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ free_packet(struct neighbor_queue *n, struct packet_queue *p, int status)
|
|||||||
queuebuf_free(p->buf);
|
queuebuf_free(p->buf);
|
||||||
memb_free(&metadata_memb, p->ptr);
|
memb_free(&metadata_memb, p->ptr);
|
||||||
memb_free(&packet_memb, p);
|
memb_free(&packet_memb, p);
|
||||||
LOG_INFO("csma: free_queued_packet, queue length %d, free packets %d\n",
|
LOG_INFO("free_queued_packet, queue length %d, free packets %d\n",
|
||||||
list_length(n->packet_queue), memb_numfree(&packet_memb));
|
list_length(n->packet_queue), memb_numfree(&packet_memb));
|
||||||
if(list_head(n->packet_queue) != NULL) {
|
if(list_head(n->packet_queue) != NULL) {
|
||||||
/* There is a next packet. We reset current tx information */
|
/* There is a next packet. We reset current tx information */
|
||||||
@ -361,15 +361,15 @@ tx_done(int status, struct packet_queue *q, struct neighbor_queue *n)
|
|||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case MAC_TX_OK:
|
case MAC_TX_OK:
|
||||||
LOG_INFO("csma: tx ok %d\n", n->transmissions);
|
LOG_INFO("tx ok %d\n", n->transmissions);
|
||||||
break;
|
break;
|
||||||
case MAC_TX_COLLISION:
|
case MAC_TX_COLLISION:
|
||||||
case MAC_TX_NOACK:
|
case MAC_TX_NOACK:
|
||||||
LOG_WARN("csma: drop with status %d after %d transmissions, %d collisions\n",
|
LOG_WARN("drop with status %d after %d transmissions, %d collisions\n",
|
||||||
status, n->transmissions, n->collisions);
|
status, n->transmissions, n->collisions);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_ERR("csma: tx failed %d: %d\n", n->transmissions, status);
|
LOG_ERR("tx failed %d: %d\n", n->transmissions, status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,7 +405,7 @@ collision(struct packet_queue *q, struct neighbor_queue *n,
|
|||||||
if(n->transmissions >= metadata->max_transmissions) {
|
if(n->transmissions >= metadata->max_transmissions) {
|
||||||
tx_done(MAC_TX_COLLISION, q, n);
|
tx_done(MAC_TX_COLLISION, q, n);
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("csma: tx collision %d\n", n->transmissions);
|
LOG_INFO("tx collision %d\n", n->transmissions);
|
||||||
rexmit(q, n);
|
rexmit(q, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,7 +423,7 @@ noack(struct packet_queue *q, struct neighbor_queue *n, int num_transmissions)
|
|||||||
if(n->transmissions >= metadata->max_transmissions) {
|
if(n->transmissions >= metadata->max_transmissions) {
|
||||||
tx_done(MAC_TX_NOACK, q, n);
|
tx_done(MAC_TX_NOACK, q, n);
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("csma: tx noack %d\n", n->transmissions);
|
LOG_INFO("tx noack %d\n", n->transmissions);
|
||||||
rexmit(q, n);
|
rexmit(q, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -457,11 +457,11 @@ packet_sent(void *ptr, int status, int num_transmissions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(q == NULL) {
|
if(q == NULL) {
|
||||||
LOG_WARN("csma: seqno %d not found\n",
|
LOG_WARN("seqno %d not found\n",
|
||||||
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
|
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
|
||||||
return;
|
return;
|
||||||
} else if(q->ptr == NULL) {
|
} else if(q->ptr == NULL) {
|
||||||
LOG_WARN("csma: no metadata\n");
|
LOG_WARN("no metadata\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ csma_output_packet(mac_callback_t sent, void *ptr)
|
|||||||
metadata->cptr = ptr;
|
metadata->cptr = ptr;
|
||||||
list_add(n->packet_queue, q);
|
list_add(n->packet_queue, q);
|
||||||
|
|
||||||
LOG_INFO("csma: send_packet, queue length %d, free packets %d\n",
|
LOG_INFO("send_packet, queue length %d, free packets %d\n",
|
||||||
list_length(n->packet_queue), memb_numfree(&packet_memb));
|
list_length(n->packet_queue), memb_numfree(&packet_memb));
|
||||||
/* If q is the first packet in the neighbor's queue, send asap */
|
/* If q is the first packet in the neighbor's queue, send asap */
|
||||||
if(list_head(n->packet_queue) == q) {
|
if(list_head(n->packet_queue) == q) {
|
||||||
@ -548,10 +548,10 @@ csma_output_packet(mac_callback_t sent, void *ptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memb_free(&metadata_memb, q->ptr);
|
memb_free(&metadata_memb, q->ptr);
|
||||||
LOG_WARN("csma: could not allocate queuebuf, dropping packet\n");
|
LOG_WARN("could not allocate queuebuf, dropping packet\n");
|
||||||
}
|
}
|
||||||
memb_free(&packet_memb, q);
|
memb_free(&packet_memb, q);
|
||||||
LOG_WARN("csma: could not allocate queuebuf, dropping packet\n");
|
LOG_WARN("could not allocate queuebuf, dropping packet\n");
|
||||||
}
|
}
|
||||||
/* The packet allocation failed. Remove and free neighbor entry if empty. */
|
/* The packet allocation failed. Remove and free neighbor entry if empty. */
|
||||||
if(list_length(n->packet_queue) == 0) {
|
if(list_length(n->packet_queue) == 0) {
|
||||||
@ -559,11 +559,11 @@ csma_output_packet(mac_callback_t sent, void *ptr)
|
|||||||
memb_free(&neighbor_memb, n);
|
memb_free(&neighbor_memb, n);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("csma: Neighbor queue full\n");
|
LOG_WARN("Neighbor queue full\n");
|
||||||
}
|
}
|
||||||
LOG_WARN("csma: could not allocate packet, dropping packet\n");
|
LOG_WARN("could not allocate packet, dropping packet\n");
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("csma: could not allocate neighbor, dropping packet\n");
|
LOG_WARN("could not allocate neighbor, dropping packet\n");
|
||||||
}
|
}
|
||||||
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1);
|
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1);
|
||||||
}
|
}
|
||||||
|
@ -70,15 +70,15 @@ input_packet(void)
|
|||||||
#if CSMA_802154_AUTOACK
|
#if CSMA_802154_AUTOACK
|
||||||
if(packetbuf_datalen() == CSMA_ACK_LEN) {
|
if(packetbuf_datalen() == CSMA_ACK_LEN) {
|
||||||
/* Ignore ack packets */
|
/* Ignore ack packets */
|
||||||
LOG_INFO("csma: ignored ack\n");
|
LOG_INFO("ignored ack\n");
|
||||||
} else
|
} else
|
||||||
#endif /* CSMA_802154_AUTOACK */
|
#endif /* CSMA_802154_AUTOACK */
|
||||||
if(NETSTACK_FRAMER.parse() < 0) {
|
if(NETSTACK_FRAMER.parse() < 0) {
|
||||||
LOG_ERR("csma: failed to parse %u\n", packetbuf_datalen());
|
LOG_ERR("failed to parse %u\n", packetbuf_datalen());
|
||||||
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||||
&linkaddr_node_addr) &&
|
&linkaddr_node_addr) &&
|
||||||
!packetbuf_holds_broadcast()) {
|
!packetbuf_holds_broadcast()) {
|
||||||
LOG_WARN("csma: not for us\n");
|
LOG_WARN("not for us\n");
|
||||||
} else {
|
} else {
|
||||||
int duplicate = 0;
|
int duplicate = 0;
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ input_packet(void)
|
|||||||
duplicate = mac_sequence_is_duplicate();
|
duplicate = mac_sequence_is_duplicate();
|
||||||
if(duplicate) {
|
if(duplicate) {
|
||||||
/* Drop the packet. */
|
/* Drop the packet. */
|
||||||
LOG_WARN("csma: drop duplicate link layer packet %u\n",
|
LOG_WARN("drop duplicate link layer packet %u\n",
|
||||||
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
|
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
|
||||||
} else {
|
} else {
|
||||||
mac_sequence_register_seqno();
|
mac_sequence_register_seqno();
|
||||||
|
Loading…
Reference in New Issue
Block a user