[PATCH series][6LoWPAN][net-next]
Subsystems (4)
PATCH 1/1 [PATCH series][6LoWPAN][net-next]
Hello all,
The following patch series adds both major feature and minor fixes. Please find detailed description in each of the patches.
Just to summarize current development status:
By using MAC and PHY layers support from
"http://sourceforge.net/projects/linux-zigbee"
project now it's possible to run generic network applications (ssh, iperf) over ieee802.15.4 network.
iperf shows about ~40Kbits/sec for TCP
With best regards,
Alexander
PATCH 3/6 set proper netdev flags
This patch fixes settings for device initialization which makes possible to use NDISC and TCP.
--- net/ieee802154/6lowpan.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
net/ieee802154/6lowpan.c +1 -2
@@ -973,13 +973,12 @@ static void lowpan_setup(struct net_device *dev) dev->addr_len =IEEE802154_ADDR_LEN ;memset (dev->broadcast,0xff ,IEEE802154_ADDR_LEN ); dev->type =ARPHRD_IEEE802154 ; - dev->features =NETIF_F_NO_CSUM ;/* Frame Control + Sequence Number + Address fields + Security Header */ dev->hard_header_len =2 +1 +20 +14 ; dev->needed_tailroom =2 ;/* FCS */ dev->mtu =1281 ; dev->tx_queue_len =0 ; - dev->flags =IFF_NOARP |IFF_BROADCAST ; + dev->flags =IFF_BROADCAST |IFF_MULTICAST ; dev->watchdog_timeo =0 ; dev->netdev_ops = &lowpan_netdev_ops;
Signature · 1 line
1.7.2.5
PATCH 1/6 add fragmentation support
In reply to a message not in the archiveThis patch adds support for frame fragmentation.
--- include/net/ieee802154.h | 6 + net/ieee802154/6lowpan.c | 260 +++++++++++++++++++++++++++++++++++++++++++++- net/ieee802154/6lowpan.h | 18 +++ 3 files changed, 280 insertions(+), 4 deletions(-)
include/net/ieee802154.h +6 -0
@@ -21,11 +21,14 @@* Maxim Gorbachyov <[email protected]> * Maxim Osipov <[email protected]> * Dmitry Eremin-Solenikov <[email protected]> +* Alexander Smirnov <[email protected]> */ #ifndef NET_IEEE802154_H #define NET_IEEE802154_H +#define IEEE802154_MTU 127 +#define IEEE802154_FC_TYPE_BEACON 0x0/* Frame is beacon */ #define IEEE802154_FC_TYPE_DATA 0x1/* Frame is data */ #define IEEE802154_FC_TYPE_ACK 0x2/* Frame is acknowledgment */
@@ -56,6 +59,9 @@ (((x) &IEEE802154_FC_DAMODE_MASK ) >>IEEE802154_FC_DAMODE_SHIFT ) +/* MAC footer size */ +#define IEEE802154_MFR_SIZE 2/* 2 octets */ +/* MAC's Command Frames Identifiers */ #define IEEE802154_CMD_ASSOCIATION_REQ 0x01#define IEEE802154_CMD_ASSOCIATION_RESP 0x02
net/ieee802154/6lowpan.c +256 -4
318 lines not on this page · raw message
net/ieee802154/6lowpan.h +18 -0
@@ -159,6 +159,24 @@#define LOWPAN_DISPATCH_FRAG1 0xc0/* 11000xxx */ #define LOWPAN_DISPATCH_FRAGN 0xe0/* 11100xxx */ +#define LOWPAN_DISPATCH_MASK 0xf8/* 11111000 */ + +#define LOWPAN_FRAG_TIMEOUT (HZ * 60)/* time-out 60 sec */ + +#define LOWPAN_FRAG1_HEAD_SIZE 0x4 +#define LOWPAN_FRAGN_HEAD_SIZE 0x5 + +/* +* According IEEE802.15.4 standard: +* - MTU is 127 octets +* - maximum MHR size is 37 octets +* - MFR size is 2 octets +* +* so minimal payload size that we may guarantee is: +* MTU - MHR - MFR = 88 octets +*/ +#define LOWPAN_FRAG_SIZE 88 +/* * Values of fields within the IPHC encoding first byte * (C stands for compressed and I for inline)
Signature · 8 lines
1.7.2.5 ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1
PATCH 2/6 disable debugging by default
In reply to a message not in the archiveThis patch disables debug output enabled by default.
--- net/ieee802154/6lowpan.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
net/ieee802154/6lowpan.c +0 -2
@@ -50,8 +50,6 @@* SUCH DAMAGE. */ -#define DEBUG -#include <linux/bitops.h> #include <linux/if_arp.h> #include <linux/module.h>
Signature · 8 lines
1.7.2.5 ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1
PATCH 5/6 UDP header decompression
In reply to Alexander SmirnovThis patch provides possibility to decompress UDP headers. Derived from Contiki OS.
--- net/ieee802154/6lowpan.c | 61 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 60 insertions(+), 1 deletions(-)
net/ieee802154/6lowpan.c +60 -1
@@ -311,6 +311,62 @@ static u16 lowpan_fetch_skb_u16(struct sk_buff *skb)return ret; } +static int +lowpan_uncompress_udp_header (struct sk_buff *skb) +{ +struct udphdr *uh =udp_hdr (skb); +u8 tmp; + + tmp =lowpan_fetch_skb_u8 (skb); + +if ((tmp &LOWPAN_NHC_UDP_MASK ) ==LOWPAN_NHC_UDP_ID ) { +pr_debug ("(%s): UDP header uncompression\n" , __func__); +switch (tmp &LOWPAN_NHC_UDP_CS_P_11 ) { +case LOWPAN_NHC_UDP_CS_P_00 : +memcpy (&uh->source, &skb->data[0 ],2 ); +memcpy (&uh->dest, &skb->data[2 ],2 ); +skb_pull (skb,4 ); +break ; +case LOWPAN_NHC_UDP_CS_P_01 : +memcpy (&uh->source, &skb->data[0 ],2 ); + uh->dest = + skb->data[2 ] +LOWPAN_NHC_UDP_8BIT_PORT ; +skb_pull (skb,3 ); +break ; +case LOWPAN_NHC_UDP_CS_P_10 : + uh->source = skb->data[0 ] +LOWPAN_NHC_UDP_8BIT_PORT ; +memcpy (&uh->dest, &skb->data[1 ],2 ); +skb_pull (skb,3 ); +break ; +case LOWPAN_NHC_UDP_CS_P_11 : + uh->source = +LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0 ] >>4 ); + uh->dest = +LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0 ] &0x0f ); +skb_pull (skb,1 ); +break ; +default : +pr_debug ("(%s) ERROR: unknown UDP format\n" , __func__); + goto err; +break ; + } + +pr_debug ("(%s): uncompressed UDP ports: src = %d, dst = %d\n" , + __func__, uh->source, uh->dest); + +/* copy checksum */ +memcpy (&uh->check, &skb->data[0 ],2 ); +skb_pull (skb,2 ); + }else { +pr_debug ("(%s): ERROR: unsupported NH format\n" , __func__); + goto err; + } + +return 0 ; +err: +return -EINVAL ; +} + static int lowpan_header_create(struct sk_buff *skb, struct net_device *dev, unsigned short type, const void *_daddr,
@@ -842,7 +898,10 @@ lowpan_process_data(struct sk_buff *skb) goto drop; } -/* TODO: UDP header parse */ +/* UDP data uncompression */ +if (iphc0 &LOWPAN_IPHC_NH_C ) +if (lowpan_uncompress_udp_header (skb)) + goto drop;/* Not fragmented package */ hdr.payload_len =htons (skb->len);
Signature · 1 line
1.7.2.5
PATCH 6/6 update documentation
In reply to Alexander SmirnovThis patch adds chapter to documentation which describes how to use 6lowpan technology.
--- Documentation/networking/ieee802154.txt | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
Documentation/networking/ieee802154.txt +27 -0
@@ -78,3 +78,30 @@ in software. This is currently WIP. See header include/net/mac802154.h and several drivers in drivers/ieee802154/. +6LoWPAN Linux implementation +============================ + +The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80 +octets of actual MAC payload once security is turned on, on a wireless link +with a link throughput of 250 kbps or less. The 6LoWPAN adaptation format +[RFC4944] was specified to carry IPv6 datagrams over such constrained links, +taking into account limited bandwidth, memory, or energy resources that are +expected in applications such as wireless Sensor Networks. [RFC4944] defines +a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header +to support the IPv6 minimum MTU requirement [RFC2460], and stateless header +compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the +relatively large IPv6 and UDP headers down to (in the best case) several bytes. + +In Semptember 2011 the standard update was published - [RFC6282]. +It deprecates HC1 and HC2 compression and defines IPHC encoding format which is +used in this Linux implementation. + +All the code related to 6lowpan you may find in files: net/ieee802154/6lowpan.* + +To setup 6lowpan interface you need (busybox release > 1.17.0): +1. Add IEEE802.15.4 interface and initialize PANid; +2. Add 6lowpan interface by command like: + # ip link add link wpan0 name lowpan0 type lowpan +3. Set MAC (if needs): + # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be +4. Bring up 'lowpan0' interface
Signature · 1 line
1.7.2.5
PATCH 4/6 UDP header compression
In reply to a message not in the archiveThis patch adds support for UDP header compression. Derived from Contiki OS.
--- net/ieee802154/6lowpan.c | 51 ++++++++++++++++++++++++++++++++++++++++++--- net/ieee802154/6lowpan.h | 5 ++++ 2 files changed, 52 insertions(+), 4 deletions(-)
net/ieee802154/6lowpan.c +47 -4
@@ -246,6 +246,50 @@ lowpan_uncompress_addr(struct sk_buff *skb, struct in6_addr *ipaddr,return 0 ; } +static void +lowpan_compress_udp_header (u8 **hc06_ptr,struct sk_buff *skb) +{ +struct udphdr *uh =udp_hdr (skb); + +pr_debug ("(%s): UDP header compression\n" , __func__); + +if (((uh->source &LOWPAN_NHC_UDP_4BIT_MASK ) == +LOWPAN_NHC_UDP_4BIT_PORT ) && + ((uh->dest &LOWPAN_NHC_UDP_4BIT_MASK ) == +LOWPAN_NHC_UDP_4BIT_PORT )) { +pr_debug ("(%s): both ports compression to 4 bits\n" , __func__); + **hc06_ptr =LOWPAN_NHC_UDP_CS_P_11 ; + **(hc06_ptr +1 ) =/* subtraction is faster */ + (u8)((uh->dest -LOWPAN_NHC_UDP_4BIT_PORT ) + + ((uh->source &LOWPAN_NHC_UDP_4BIT_PORT ) <<4 )); + *hc06_ptr +=2 ; + }else if ((uh->dest &LOWPAN_NHC_UDP_8BIT_MASK ) == +LOWPAN_NHC_UDP_8BIT_PORT ) { +pr_debug ("(%s): remove 8 bits of dest\n" , __func__); + **hc06_ptr =LOWPAN_NHC_UDP_CS_P_01 ; +memcpy (*hc06_ptr +1 , &uh->source,2 ); + **(hc06_ptr +3 ) = (u8)(uh->dest -LOWPAN_NHC_UDP_8BIT_PORT ); + *hc06_ptr +=4 ; + }else if ((uh->source &LOWPAN_NHC_UDP_8BIT_MASK ) == +LOWPAN_NHC_UDP_8BIT_PORT ) { +pr_debug ("(%s): remove 8 bits of source\n" , __func__); + **hc06_ptr =LOWPAN_NHC_UDP_CS_P_10 ; +memcpy (*hc06_ptr +1 , &uh->dest,2 ); + **(hc06_ptr +3 ) = (u8)(uh->source -LOWPAN_NHC_UDP_8BIT_PORT ); + *hc06_ptr +=4 ; + }else { +pr_debug ("(%s): can't compress header\n" , __func__); + **hc06_ptr =LOWPAN_NHC_UDP_CS_P_00 ; +memcpy (*hc06_ptr +1 , &uh->source,2 ); +memcpy (*hc06_ptr +3 , &uh->dest,2 ); + *hc06_ptr +=5 ; + } + +/* checksum is always inline */ +memcpy (*hc06_ptr, &uh->check,2 ); + *hc06_ptr +=2 ; +} +static u8 lowpan_fetch_skb_u8 (struct sk_buff *skb) {u8 ret;
@@ -365,8 +409,6 @@ static int lowpan_header_create(struct sk_buff *skb,if (hdr->nexthdr ==UIP_PROTO_UDP ) iphc0 |=LOWPAN_IPHC_NH_C ; -/* TODO: next header compression */ -if ((iphc0 &LOWPAN_IPHC_NH_C ) ==0 ) { *hc06_ptr = hdr->nexthdr; hc06_ptr +=1 ;
@@ -454,8 +496,9 @@ static int lowpan_header_create(struct sk_buff *skb, } } -/* TODO: UDP header compression */ -/* TODO: Next Header compression */ +/* UDP header compression */ +if (hdr->nexthdr ==UIP_PROTO_UDP ) +lowpan_compress_udp_header (&hc06_ptr, skb); head[0 ] = iphc0; head[1 ] = iphc1;
net/ieee802154/6lowpan.h +5 -0
@@ -219,6 +219,11 @@#define LOWPAN_NHC_UDP_CHECKSUMC 0x04#define LOWPAN_NHC_UDP_CHECKSUMI 0x00 +#define LOWPAN_NHC_UDP_4BIT_PORT 0xF0B0 +#define LOWPAN_NHC_UDP_4BIT_MASK 0xFFF0 +#define LOWPAN_NHC_UDP_8BIT_PORT 0xF000 +#define LOWPAN_NHC_UDP_8BIT_MASK 0xFF00 +/* values for port compression, _with checksum_ ie bit 5 set to 0 */ #define LOWPAN_NHC_UDP_CS_P_00 0xF0/* all inline */ #define LOWPAN_NHC_UDP_CS_P_01 0xF1/* source 16bit inline,
Signature · 8 lines
1.7.2.5 ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1
From: Alexander Smirnov <[email protected]>
Date: Thu, 10 Nov 2011 20:32:58 +0300
Quoted 5 lines
Hello all,
The following patch series adds both major feature and minor fixes. Please find detailed description in each of the patches.
Quoted 7 lines
Just to summarize current development status:
By using MAC and PHY layers support from
"http://sourceforge.net/projects/linux-zigbee"
project now it's possible to run generic network applications (ssh, iperf) over ieee802.15.4 network.iperf shows about ~40Kbits/sec for TCP
All applied, thanks.
In future patch submissions, please layout your Subject lines correctly.
Everything that is inside of brackes "[]" will be removed before the subject line is placed at the top of the commit message. So as-is, your commits would lack any kind of indication of where the code changes were occuring since the "6LowPAN" part was removed.
In fact, you didn't mention 6LowPAN at all in the subject line of some of your commits. This is unacceptable. There must always be a subject prefix of the form "${SUBSYSTEM}: " so that what ends up in the commit message lets readers know the general area where the change was made.
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
Dear David, thank you!
Best regards,
Alexander
2011/11/14 David Miller <davem-fT/PcQaiUtIeIZ0/[email protected]>:
Quoted 26 lines
From: Alexander Smirnov <[email protected]>
Date: Thu, 10 Nov 2011 20:32:58 +0300Quoted 5 lines
Hello all,
The following patch series adds both major feature and minor fixes. Please find detailed description in each of the patches.
Quoted 7 lines
Just to summarize current development status:
By using MAC and PHY layers support from "http://sourceforge.net/projects/linux-zigbee"
project now it's possible to run generic network applications (ssh, iperf) over ieee802.15.4 network.iperf shows about ~40Kbits/sec for TCP
All applied, thanks.
In future patch submissions, please layout your Subject lines correctly.
Everything that is inside of brackes "[]" will be removed before the subject line is placed at the top of the commit message. So as-is, your commits would lack any kind of indication of where the code changes were occuring since the "6LowPAN" part was removed.
Quoted 6 lines
In fact, you didn't mention 6LowPAN at all in the subject line of some of your commits. This is unacceptable. There must always be a subject prefix of the form "${SUBSYSTEM}: " so that what ends up in the commit message lets readers know the general area where the change was made.
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1