sicslowpan: Fixed too aggresive fragmentation
This commit is contained in:
parent
2cf7d98cad
commit
677c078302
5 changed files with 35 additions and 13 deletions
|
@ -220,13 +220,12 @@
|
|||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
#endif /* SICSLOWPAN_CONF_FRAG */
|
||||
|
||||
/* SICSLOWPAN_CONF_MAC_MAX_PAYLOAD specifies the maximum size of
|
||||
packets before they get fragmented. The default is 127 bytes (the
|
||||
maximum size of a 802.15.4 frame) - 25 bytes (for the 802.15.4 MAC
|
||||
layer header). This can be increased for systems with larger packet
|
||||
sizes. */
|
||||
/* SICSLOWPAN_CONF_MAC_MAX_PAYLOAD is the maximum available size for
|
||||
frame headers, link layer security-related overhead, as well as
|
||||
6LoWPAN payload. By default, SICSLOWPAN_CONF_MAC_MAX_PAYLOAD is
|
||||
127 bytes (MTU of 802.15.4) - 2 bytes (Footer of 802.15.4). */
|
||||
#ifndef SICSLOWPAN_CONF_MAC_MAX_PAYLOAD
|
||||
#define SICSLOWPAN_CONF_MAC_MAX_PAYLOAD (127 - 25)
|
||||
#define SICSLOWPAN_CONF_MAC_MAX_PAYLOAD (127 - 2)
|
||||
#endif /* SICSLOWPAN_CONF_MAC_MAX_PAYLOAD */
|
||||
|
||||
/* SICSLOWPAN_CONF_COMPRESSION_THRESHOLD sets a lower threshold for
|
||||
|
|
|
@ -155,11 +155,13 @@ void uip_log(char *msg);
|
|||
/** @} */
|
||||
|
||||
|
||||
/** \brief Size of the 802.15.4 payload (127byte - 25 for MAC header) */
|
||||
/** \brief Maximum available size for frame headers,
|
||||
link layer security-related overhead, as well as
|
||||
6LoWPAN payload. */
|
||||
#ifdef SICSLOWPAN_CONF_MAC_MAX_PAYLOAD
|
||||
#define MAC_MAX_PAYLOAD SICSLOWPAN_CONF_MAC_MAX_PAYLOAD
|
||||
#else /* SICSLOWPAN_CONF_MAC_MAX_PAYLOAD */
|
||||
#define MAC_MAX_PAYLOAD 102
|
||||
#define MAC_MAX_PAYLOAD (127 - 2)
|
||||
#endif /* SICSLOWPAN_CONF_MAC_MAX_PAYLOAD */
|
||||
|
||||
|
||||
|
@ -1361,6 +1363,7 @@ static uint8_t
|
|||
output(const uip_lladdr_t *localdest)
|
||||
{
|
||||
int framer_hdrlen;
|
||||
int max_payload;
|
||||
|
||||
/* The MAC address of the destination of the packet */
|
||||
linkaddr_t dest;
|
||||
|
@ -1443,8 +1446,9 @@ output(const uip_lladdr_t *localdest)
|
|||
#else /* USE_FRAMER_HDRLEN */
|
||||
framer_hdrlen = 21;
|
||||
#endif /* USE_FRAMER_HDRLEN */
|
||||
max_payload = MAC_MAX_PAYLOAD - framer_hdrlen - NETSTACK_LLSEC.get_overhead();
|
||||
|
||||
if((int)uip_len - (int)uncomp_hdr_len > (int)MAC_MAX_PAYLOAD - framer_hdrlen - (int)packetbuf_hdr_len) {
|
||||
if((int)uip_len - (int)uncomp_hdr_len > max_payload - (int)packetbuf_hdr_len) {
|
||||
#if SICSLOWPAN_CONF_FRAG
|
||||
struct queuebuf *q;
|
||||
/*
|
||||
|
@ -1477,7 +1481,7 @@ output(const uip_lladdr_t *localdest)
|
|||
|
||||
/* Copy payload and send */
|
||||
packetbuf_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN;
|
||||
packetbuf_payload_len = (MAC_MAX_PAYLOAD - framer_hdrlen - packetbuf_hdr_len) & 0xfffffff8;
|
||||
packetbuf_payload_len = (max_payload - packetbuf_hdr_len) & 0xfffffff8;
|
||||
PRINTFO("(len %d, tag %d)\n", packetbuf_payload_len, my_tag);
|
||||
memcpy(packetbuf_ptr + packetbuf_hdr_len,
|
||||
(uint8_t *)UIP_IP_BUF + uncomp_hdr_len, packetbuf_payload_len);
|
||||
|
@ -1513,7 +1517,7 @@ output(const uip_lladdr_t *localdest)
|
|||
/* uip_htons((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len); */
|
||||
SET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_DISPATCH_SIZE,
|
||||
((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len));
|
||||
packetbuf_payload_len = (MAC_MAX_PAYLOAD - framer_hdrlen - packetbuf_hdr_len) & 0xfffffff8;
|
||||
packetbuf_payload_len = (max_payload - packetbuf_hdr_len) & 0xfffffff8;
|
||||
while(processed_ip_out_len < uip_len) {
|
||||
PRINTFO("sicslowpan output: fragment ");
|
||||
PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET] = processed_ip_out_len >> 3;
|
||||
|
|
|
@ -85,6 +85,9 @@ struct llsec_driver {
|
|||
* filters out injected or replayed frames.
|
||||
*/
|
||||
void (* input)(void);
|
||||
|
||||
/** Returns the security-related overhead per frame in bytes */
|
||||
uint8_t (* get_overhead)(void);
|
||||
};
|
||||
|
||||
#endif /* LLSEC_H_ */
|
||||
|
|
|
@ -65,6 +65,8 @@
|
|||
0x0C , 0x0D , 0x0E , 0x0F }
|
||||
#endif /* NONCORESEC_CONF_KEY */
|
||||
|
||||
#define SECURITY_HEADER_LENGTH 5
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
|
@ -192,6 +194,12 @@ input(void)
|
|||
NETSTACK_NETWORK.input();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint8_t
|
||||
get_overhead(void)
|
||||
{
|
||||
return SECURITY_HEADER_LENGTH + LLSEC802154_MIC_LENGTH;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
bootstrap(llsec_on_bootstrapped_t on_bootstrapped)
|
||||
{
|
||||
|
@ -205,7 +213,8 @@ const struct llsec_driver noncoresec_driver = {
|
|||
bootstrap,
|
||||
send,
|
||||
on_frame_created,
|
||||
input
|
||||
input,
|
||||
get_overhead
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -73,12 +73,19 @@ input(void)
|
|||
NETSTACK_NETWORK.input();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint8_t
|
||||
get_overhead(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct llsec_driver nullsec_driver = {
|
||||
"nullsec",
|
||||
bootstrap,
|
||||
send,
|
||||
on_frame_created,
|
||||
input
|
||||
input,
|
||||
get_overhead
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue