added support for usage of the transmission count attirbute in uipbuf
This commit is contained in:
parent
941ddf35b8
commit
1356994795
@ -33,7 +33,10 @@ udp_rx_callback(struct simple_udp_connection *c,
|
||||
uint16_t datalen)
|
||||
{
|
||||
unsigned count = *(unsigned *)data;
|
||||
LOG_INFO("Received response %u from ", count);
|
||||
/* If tagging of traffic class is enabled tc will print number of
|
||||
transmission - otherwise it will be 0 */
|
||||
LOG_INFO("Received response %u (tc:%d) from ", count,
|
||||
uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS));
|
||||
LOG_INFO_6ADDR(sender_addr);
|
||||
LOG_INFO_("\n");
|
||||
}
|
||||
@ -61,6 +64,12 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
||||
LOG_INFO("Sending request %u to ", count);
|
||||
LOG_INFO_6ADDR(&dag->dag_id);
|
||||
LOG_INFO_("\n");
|
||||
/* Set the number of transmissions to use for this packet -
|
||||
this can be used to create more reliable transmissions or
|
||||
less reliable than the default. Works end-to-end if
|
||||
UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS is set to 1.
|
||||
*/
|
||||
uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, 1 + count % 5);
|
||||
simple_udp_sendto(&udp_conn, &count, sizeof(count), &dag->dag_id);
|
||||
count++;
|
||||
}
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "net/ipv6/tcpip.h"
|
||||
#include "net/ipv6/uip.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#include "net/ipv6/uipbuf.h"
|
||||
#include "net/ipv6/sicslowpan.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/packetbuf.h"
|
||||
@ -1504,17 +1505,6 @@ output(const linkaddr_t *localdest)
|
||||
set_packet_attrs();
|
||||
}
|
||||
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
{
|
||||
uint8_t traffic_class = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4);
|
||||
if(traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_BIT) {
|
||||
uint8_t max_mac_transmissions = traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_MASK;
|
||||
/* propagate the MAC transmission limit to lower layers */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, max_mac_transmissions);
|
||||
}
|
||||
}
|
||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
||||
|
||||
/*
|
||||
* The destination address will be tagged to each outbound
|
||||
* packet. If the argument localdest is NULL, we are sending a
|
||||
@ -1528,6 +1518,10 @@ output(const linkaddr_t *localdest)
|
||||
|
||||
LOG_INFO("output: sending packet len %d\n", uip_len);
|
||||
|
||||
/* copy over the retransmission count from uipbuf attributes */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
|
||||
uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS));
|
||||
|
||||
/* Try to compress the headers */
|
||||
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6
|
||||
compress_hdr_ipv6(&dest);
|
||||
|
@ -121,6 +121,19 @@ uint8_t
|
||||
tcpip_output(const uip_lladdr_t *a)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Tag Traffic Class if we are using TC for variable retrans */
|
||||
#if UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||
if(uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS) !=
|
||||
UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
|
||||
LOG_INFO("Tagging TC with retrans: %d\n", uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS));
|
||||
/* Encapsulate the MAC transmission limit in the Traffic Class field */
|
||||
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
|
||||
UIP_IP_BUF->tcflow =
|
||||
uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS) << 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(netstack_process_ip_callback(NETSTACK_IP_OUTPUT, (const linkaddr_t *)a) ==
|
||||
NETSTACK_IP_PROCESS) {
|
||||
ret = NETSTACK_NETWORK.output((const linkaddr_t *) a);
|
||||
@ -167,6 +180,19 @@ packet_input(void)
|
||||
{
|
||||
if(uip_len > 0) {
|
||||
check_for_tcp_syn();
|
||||
|
||||
#if UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||
{
|
||||
uint8_t traffic_class = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4);
|
||||
if(traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_BIT) {
|
||||
uint8_t max_mac_transmissions = traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_MASK;
|
||||
uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, max_mac_transmissions);
|
||||
LOG_INFO("Received packet tagged with TC retrans: %d (%x)",
|
||||
max_mac_transmissions, traffic_class);
|
||||
}
|
||||
}
|
||||
#endif /* UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS */
|
||||
|
||||
uip_input();
|
||||
if(uip_len > 0) {
|
||||
tcpip_ipv6_output();
|
||||
|
@ -80,6 +80,7 @@
|
||||
|
||||
|
||||
#include "net/ipv6/uipopt.h"
|
||||
#include "net/ipv6/uipbuf.h"
|
||||
|
||||
/* For memcmp */
|
||||
#include <string.h>
|
||||
@ -820,18 +821,6 @@ CCIF void uip_send(const void *data, int len);
|
||||
*/
|
||||
#define uip_mss() (uip_conn->mss)
|
||||
|
||||
/**
|
||||
* Set the maximal number of MAC transmissions.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
#define uip_set_max_mac_transmissions(conn, value) ((conn)->max_mac_transmissions = (value))
|
||||
#else
|
||||
#define uip_set_max_mac_transmissions(conn, value)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Set up a new UDP connection.
|
||||
*
|
||||
@ -1328,10 +1317,12 @@ extern uint16_t uip_urglen, uip_surglen;
|
||||
#define uip_clear_buf() { \
|
||||
uip_len = 0; \
|
||||
uip_ext_len = 0; \
|
||||
uipbuf_clear_attr();\
|
||||
}
|
||||
#else /*NETSTACK_CONF_WITH_IPV6*/
|
||||
#define uip_clear_buf() { \
|
||||
uip_len = 0; \
|
||||
uipbuf_clear_attr();\
|
||||
}
|
||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||
|
||||
@ -1365,10 +1356,6 @@ struct uip_conn {
|
||||
uint8_t timer; /**< The retransmission timer. */
|
||||
uint8_t nrtx; /**< The number of retransmissions for the last
|
||||
segment sent. */
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */
|
||||
#endif
|
||||
|
||||
uip_tcp_appstate_t appstate; /** The application state. */
|
||||
};
|
||||
|
||||
@ -1405,10 +1392,6 @@ struct uip_udp_conn {
|
||||
uint16_t lport; /**< The local port number in network byte order. */
|
||||
uint16_t rport; /**< The remote port number in network byte order. */
|
||||
uint8_t ttl; /**< Default time-to-live. */
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */
|
||||
#endif
|
||||
|
||||
/** The application state. */
|
||||
uip_udp_appstate_t appstate;
|
||||
};
|
||||
|
@ -508,9 +508,6 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
||||
conn->rto = UIP_RTO;
|
||||
conn->sa = 0;
|
||||
conn->sv = 16; /* Initial value of the RTT variance. */
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED;
|
||||
#endif
|
||||
conn->lport = uip_htons(lastport);
|
||||
conn->rport = rport;
|
||||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||
@ -584,9 +581,6 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
||||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||
}
|
||||
conn->ttl = uip_ds6_if.cur_hop_limit;
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED;
|
||||
#endif
|
||||
|
||||
return conn;
|
||||
}
|
||||
@ -1578,14 +1572,6 @@ uip_process(uint8_t flag)
|
||||
|
||||
UIP_IP_BUF->vtc = 0x60;
|
||||
UIP_IP_BUF->tcflow = 0x00;
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
if(uip_udp_conn->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
|
||||
/* Encapsulate the MAC transmission limit in the Traffic Class field */
|
||||
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
|
||||
UIP_IP_BUF->tcflow = uip_udp_conn->max_mac_transmissions << 4;
|
||||
}
|
||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
||||
|
||||
UIP_IP_BUF->ttl = uip_udp_conn->ttl;
|
||||
UIP_IP_BUF->proto = UIP_PROTO_UDP;
|
||||
|
||||
@ -2292,13 +2278,6 @@ uip_process(uint8_t flag)
|
||||
|
||||
UIP_IP_BUF->vtc = 0x60;
|
||||
UIP_IP_BUF->tcflow = 0x00;
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
if(uip_connr->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
|
||||
/* Encapsulate the MAC transmission limit in the Traffic Class field */
|
||||
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
|
||||
UIP_IP_BUF->tcflow = uip_connr->max_mac_transmissions << 4;
|
||||
}
|
||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
||||
|
||||
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr);
|
||||
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
||||
|
@ -518,22 +518,6 @@ void uip_log(char *msg);
|
||||
|
||||
#define UIP_DEFAULT_PREFIX_LEN 64
|
||||
|
||||
/**
|
||||
* Enables selection of maximal MAC-layer transmission count at application layer
|
||||
*/
|
||||
#ifdef UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS
|
||||
#define UIP_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS
|
||||
#else
|
||||
#define UIP_WITH_VARIABLE_RETRANSMISSIONS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is the default value of MAC-layer transmissons for uIPv6
|
||||
*
|
||||
* It means that the limit is selected by the MAC protocol instead of uIPv6.
|
||||
*/
|
||||
#define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0
|
||||
|
||||
/**
|
||||
* The MAC-layer transmissons limit is encapslated in "Traffic Class" field
|
||||
*
|
||||
@ -547,6 +531,19 @@ void uip_log(char *msg);
|
||||
*/
|
||||
#define UIP_TC_MAC_TRANSMISSION_COUNTER_MASK 0x3F
|
||||
|
||||
#ifdef UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||
#define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||
#else
|
||||
#define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is the default value of MAC-layer transmissons for uIPv6
|
||||
*
|
||||
* It means that the limit is selected by the MAC protocol instead of uIPv6.
|
||||
*/
|
||||
#define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0
|
||||
|
||||
/** @} */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
@ -506,15 +506,11 @@ csma_output_packet(mac_callback_t sent, void *ptr)
|
||||
if(q->buf != NULL) {
|
||||
struct qbuf_metadata *metadata = (struct qbuf_metadata *)q->ptr;
|
||||
/* Neighbor and packet successfully allocated */
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
metadata->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
|
||||
if(metadata->max_transmissions == 0) {
|
||||
/* If not set by the application, use the default CSMA value */
|
||||
metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1;
|
||||
}
|
||||
#else
|
||||
metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1;
|
||||
#endif
|
||||
metadata->sent = sent;
|
||||
metadata->cptr = ptr;
|
||||
list_add(n->packet_queue, q);
|
||||
|
@ -1007,9 +1007,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||
#endif
|
||||
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
|
||||
#endif
|
||||
if(max_transmissions == 0) {
|
||||
/* If not set by the application, use the default TSCH value */
|
||||
max_transmissions = TSCH_MAC_MAX_FRAME_RETRIES + 1;
|
||||
|
@ -217,9 +217,7 @@ enum {
|
||||
PACKETBUF_ATTR_LINK_QUALITY,
|
||||
PACKETBUF_ATTR_RSSI,
|
||||
PACKETBUF_ATTR_TIMESTAMP,
|
||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
||||
PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
|
||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
||||
PACKETBUF_ATTR_MAC_SEQNO,
|
||||
PACKETBUF_ATTR_MAC_ACK,
|
||||
PACKETBUF_ATTR_MAC_METADATA,
|
||||
|
Loading…
Reference in New Issue
Block a user