Added a SICSLOWPAN_CONF_COMPRESSION_THRESHOLD that can be used to set a threshold under which header compression should not be used. Below this threshold, headers are not compressed but sent as full IPv6 packets. This is useful for RDC layers, such as ContikiMAC, which set a lower bound for packet size.
This commit is contained in:
parent
3cb42ceb10
commit
2da65385a0
1 changed files with 24 additions and 16 deletions
|
@ -165,6 +165,16 @@ void uip_log(char *msg);
|
|||
/** \brief Size of the 802.15.4 payload (127byte - 25 for MAC header) */
|
||||
#define MAC_MAX_PAYLOAD 102
|
||||
|
||||
|
||||
/** \brief Some MAC layers need a minimum payload, which is
|
||||
configurable through the SICSLOWPAN_CONF_MIN_MAC_PAYLOAD
|
||||
option. */
|
||||
#ifdef SICSLOWPAN_CONF_COMPRESSION_THRESHOLD
|
||||
#define COMPRESSION_THRESHOLD SICSLOWPAN_CONF_COMPRESSION_THRESHOLD
|
||||
#else
|
||||
#define COMPRESSION_THRESHOLD 0
|
||||
#endif
|
||||
|
||||
/** \name General variables
|
||||
* @{
|
||||
*/
|
||||
|
@ -1204,7 +1214,7 @@ uncompress_hdr_hc1(uint16_t ip_len)
|
|||
#endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC1 */
|
||||
|
||||
|
||||
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** \name IPv6 dispatch "compression" function
|
||||
* @{ */
|
||||
|
@ -1232,9 +1242,6 @@ compress_hdr_ipv6(rimeaddr_t *rime_destaddr)
|
|||
return;
|
||||
}
|
||||
/** @} */
|
||||
#endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6 */
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** \name Input/output functions common to all compression schemes
|
||||
|
@ -1259,7 +1266,6 @@ packet_sent(void *ptr, int status, int transmissions)
|
|||
static void
|
||||
send_packet(rimeaddr_t *dest)
|
||||
{
|
||||
|
||||
/* Set the link layer destination address for the packet as a
|
||||
* packetbuf attribute. The MAC layer can access the destination
|
||||
* address with the function packetbuf_addr(PACKETBUF_ADDR_RECEIVER).
|
||||
|
@ -1279,7 +1285,7 @@ send_packet(rimeaddr_t *dest)
|
|||
watchdog know that we are still alive. */
|
||||
watchdog_periodic();
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** \brief Take an IP packet and format it to be sent on an 802.15.4
|
||||
* network using 6lowpan.
|
||||
* \param localdest The MAC address of the destination
|
||||
|
@ -1295,7 +1301,6 @@ output(uip_lladdr_t *localdest)
|
|||
/* The MAC address of the destination of the packet */
|
||||
rimeaddr_t dest;
|
||||
|
||||
|
||||
/* init */
|
||||
uncomp_hdr_len = 0;
|
||||
rime_hdr_len = 0;
|
||||
|
@ -1335,6 +1340,7 @@ output(uip_lladdr_t *localdest)
|
|||
|
||||
PRINTFO("sicslowpan output: sending packet len %d\n", uip_len);
|
||||
|
||||
if(uip_len >= COMPRESSION_THRESHOLD) {
|
||||
/* Try to compress the headers */
|
||||
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC1
|
||||
compress_hdr_hc1(&dest);
|
||||
|
@ -1345,6 +1351,9 @@ output(uip_lladdr_t *localdest)
|
|||
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC06
|
||||
compress_hdr_hc06(&dest);
|
||||
#endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC06 */
|
||||
} else {
|
||||
compress_hdr_ipv6(&dest);
|
||||
}
|
||||
PRINTFO("sicslowpan output: header of len %d\n", rime_hdr_len);
|
||||
|
||||
if(uip_len - uncomp_hdr_len > MAC_MAX_PAYLOAD - rime_hdr_len) {
|
||||
|
@ -1358,7 +1367,6 @@ output(uip_lladdr_t *localdest)
|
|||
* The following fragments contain only the fragn dispatch.
|
||||
*/
|
||||
|
||||
|
||||
PRINTFO("Fragmentation sending packet len %d\n", uip_len);
|
||||
|
||||
/* Create 1st Fragment */
|
||||
|
|
Loading…
Reference in a new issue