blob: 12434645a05ede3f17c59748fc93612f29116e7e [file] [log] [blame]
<!--
Documentation/_templates/layout.html
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. The
ASF licenses this file to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html>
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>6LoWPAN &mdash; NuttX latest documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../../_static/custom.css" />
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/sphinx_highlight.js"></script>
<script src="../../_static/clipboard.min.js"></script>
<script src="../../_static/copybutton.js"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="SocketCAN Device Drivers" href="socketcan.html" />
<link rel="prev" title="Network Support" href="index.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> NuttX
</a>
<!-- this version selector is quite ugly, should be probably replaced by something
more modern -->
<div class="version-selector">
<select onchange="javascript:location.href = this.value;">
<option value="../../../latest" selected="selected">latest</option>
<option value="../../../10.0.0" >10.0.0</option>
<option value="../../../10.0.1" >10.0.1</option>
<option value="../../../10.1.0" >10.1.0</option>
<option value="../../../10.2.0" >10.2.0</option>
<option value="../../../10.3.0" >10.3.0</option>
<option value="../../../11.0.0" >11.0.0</option>
<option value="../../../12.0.0" >12.0.0</option>
<option value="../../../12.1.0" >12.1.0</option>
<option value="../../../12.2.0" >12.2.0</option>
<option value="../../../12.2.1" >12.2.1</option>
<option value="../../../12.3.0" >12.3.0</option>
<option value="../../../12.4.0" >12.4.0</option>
<option value="../../../12.5.0" >12.5.0</option>
<option value="../../../12.5.1" >12.5.1</option>
<option value="../../../12.6.0" >12.6.0</option>
<option value="../../../12.7.0" >12.7.0</option>
<option value="../../../12.8.0" >12.8.0</option>
<option value="../../../12.9.0" >12.9.0</option>
<option value="../../../12.10.0" >12.10.0</option>
<option value="../../../12.11.0" >12.11.0</option>
</select>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Table of Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../index.html">Home</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contributing/index.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../platforms/index.html">Supported Platforms</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">OS Components</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../binfmt.html">Binary Loader</a></li>
<li class="toctree-l2"><a class="reference internal" href="../drivers/index.html">Device Drivers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../nxflat.html">NXFLAT</a></li>
<li class="toctree-l2"><a class="reference internal" href="../nxgraphics/index.html">NX Graphics Subsystem</a></li>
<li class="toctree-l2"><a class="reference internal" href="../paging.html">On-Demand Paging</a></li>
<li class="toctree-l2"><a class="reference internal" href="../audio/index.html">Audio Subsystem</a></li>
<li class="toctree-l2"><a class="reference internal" href="../filesystem/index.html">NuttX File System</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libs/index.html">NuttX libraries</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Network Support</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">6LoWPAN</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#lowpan-addressing">6LoWPAN Addressing</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ipv6-neighbor-discovery">IPv6 Neighbor Discovery</a></li>
<li class="toctree-l4"><a class="reference internal" href="#optimal-6lowpan-configuration">Optimal 6LoWPAN Configuration</a></li>
<li class="toctree-l4"><a class="reference internal" href="#fragmentation-headers">Fragmentation Headers</a></li>
<li class="toctree-l4"><a class="reference internal" href="#star-configuration">Star Configuration</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="socketcan.html">SocketCAN Device Drivers</a></li>
<li class="toctree-l3"><a class="reference internal" href="pkt.html">“Raw” packet socket support</a></li>
<li class="toctree-l3"><a class="reference internal" href="ipfilter.html">IP Packet Filter</a></li>
<li class="toctree-l3"><a class="reference internal" href="nat.html">Network Address Translation (NAT)</a></li>
<li class="toctree-l3"><a class="reference internal" href="netdev.html">Network Devices</a></li>
<li class="toctree-l3"><a class="reference internal" href="netdriver.html">Network Drivers</a></li>
<li class="toctree-l3"><a class="reference internal" href="netguardsize.html">CONFIG_NET_GUARDSIZE</a></li>
<li class="toctree-l3"><a class="reference internal" href="netlink.html">Netlink Route support</a></li>
<li class="toctree-l3"><a class="reference internal" href="slip.html">SLIP</a></li>
<li class="toctree-l3"><a class="reference internal" href="wqueuedeadlocks.html">Work Queue Deadlocks</a></li>
<li class="toctree-l3"><a class="reference internal" href="tcp_network_perf.html">TCP Network Performance</a></li>
<li class="toctree-l3"><a class="reference internal" href="delay_act_and_tcp_perf.html">Delayed ACK and TCP Performance</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../mm/index.html">Memory Management</a></li>
<li class="toctree-l2"><a class="reference internal" href="../syscall.html">Syscall Layer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tools/index.html"><code class="docutils literal notranslate"><span class="pre">/tools</span></code> Host Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="../arch/index.html">Architecture-Specific Code</a></li>
<li class="toctree-l2"><a class="reference internal" href="../boards.html">Boards Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cmake.html">CMake Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../openamp.html">OpenAMP Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../video.html">Video Subsystem</a></li>
<li class="toctree-l2"><a class="reference internal" href="../crypto.html">Crypto API Subsystem</a></li>
<li class="toctree-l2"><a class="reference internal" href="../wireless.html">Wireless Subsystem</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../applications/index.html">Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation Details</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../reference/index.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../guides/index.html">Guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../logos/index.html">NuttX Logos</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">NuttX</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">OS Components</a></li>
<li class="breadcrumb-item"><a href="index.html">Network Support</a></li>
<li class="breadcrumb-item active">6LoWPAN</li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/components/net/sixlowpan.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="lowpan">
<h1>6LoWPAN<a class="headerlink" href="#lowpan" title="Permalink to this heading"></a></h1>
<section id="lowpan-addressing">
<h2>6LoWPAN Addressing<a class="headerlink" href="#lowpan-addressing" title="Permalink to this heading"></a></h2>
<p>The current 6LoWPAN implementation uses only link local, MAC-based
addressing addressing (as discussed in more detail below). Thus if you know
the node addressing, then you know the IPv6 address (and vice-versa).</p>
<p>As a configuration option, the 6LoWPAN implementation will use either the
node’s 2-byte short address or 8-byte extended address as the MAC address
that the IPv6 address is based on. This is determined by the configuration
setting <code class="docutils literal notranslate"><span class="pre">CONFIG_NET_6LOWPAN_EXTENDEDADDR</span></code>. By default, the 2-byte short
address is used for the IEEE802.15.4 MAC device’s link layer address. If
this option is selected, then an 8-byte extended address will be used,
instead.</p>
<p>All nodes operating on a network have unique, 8-byte extended address,
that was assigned before the network is configured. 6LoWPAN will use
either the extended address for direct communication within the PAN or
the short 2-byte address. The short 2-byte address, however, is allocated
by the PAN coordinator when the device associated. If short addresses are
used, the network cannot be brought up until is is associated.</p>
<p>Node addressing is modified through IOCTL calls from application logic.
The network must be in the DOWN state when ever the node addressing is
modified. The modified node addresses will have no effect on the reported
IPv6 address until the network is brought to the UP state. The new IPv6
MAC-based addresses are only instantiated when the network transitions
from the DOWN to UP state.</p>
</section>
<section id="ipv6-neighbor-discovery">
<h2>IPv6 Neighbor Discovery<a class="headerlink" href="#ipv6-neighbor-discovery" title="Permalink to this heading"></a></h2>
<p>IPv6 Neighbor Discovery is not supported. The current ICMPv6 and neighbor-
related logic only works with Ethernet MAC. For 6LoWPAN, a new more
conservative IPv6 neighbor discovery is provided by RFC 6775 which is not
currently supported. With IPv6 neighbor discovery, any IPv6 address may be
associated with any short or extended address. In fact, that is the whole
purpose of the neighbor discover logic: It plays the same role as ARP in
IPv4; it ultimately just manages a neighbor table that, like the arp table,
provides the mapping between IP addresses and node addresses.</p>
<p>The NuttX, Contiki-based 6LoWPAN implementation circumvents the need for
the neighbor discovery logic by using only MAC-based addressing, i.e., the
lower two or eight bytes of the IP address are the node address.</p>
<p>Most of the 6LoWPAN compression algorithms exploit this kind of addressing
to compress the IPv6 address to nothing but a single bit indicating that the
IP address derives from the node address. In this use case, IPv6 neighbor
discover is not useful: If we want to use IPv6 neighbor discovery, we could
dispense with the all MAC based addressing. But if we want to retain the
more compact MAC-based addressing, then we don’t need IPv6 neighbor discovery.</p>
<p>However, it would still be nice to have enough in place to support ping6.
Full neighbor support would be necessary if we wanted to route 6LoWPAN frames
outside of the WPAN.</p>
</section>
<section id="optimal-6lowpan-configuration">
<h2>Optimal 6LoWPAN Configuration<a class="headerlink" href="#optimal-6lowpan-configuration" title="Permalink to this heading"></a></h2>
<ol class="arabic">
<li><p>Link local IP addresses:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>128 112 96 80 64 48 32 16
fe80 0000 0000 0000 xxxx xxxx xxxx xxxx
</pre></div>
</div>
</li>
<li><p>MAC-based IP addresses:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>128 112 96 80 64 48 32 16
---- ---- ---- ---- ---- ---- ---- ----
AAAA xxxx xxxx xxxx xxxx 00ff fe00 MMMM 2-byte short address IEEE 48-bit MAC
AAAA 0000 0000 0000 NNNN NNNN NNNN NNNN 8-byte extended address IEEE EUI-64
</pre></div>
</div>
<p>Where MMM is the 2-byte short address XORed 0x0200. For example, the MAC
address of 0xabcd would be 0xa9cd. And NNNN NNNN NNNN NNNN is the 8-byte
extended address address XOR 02000 0000 0000 0000.</p>
<p>For link-local address, AAAA is 0xfe80</p>
</li>
<li><p>MAC based link-local addresses:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>128 112 96 80 64 48 32 16
---- ---- ---- ---- ---- ---- ---- ----
fe80 0000 0000 0000 0000 00ff fe00 MMMM 2-byte short address IEEE 48-bit MAC
fe80 0000 0000 0000 NNNN NNNN NNNN NNNN 8-byte extended address IEEE EUI-64
</pre></div>
</div>
</li>
<li><p>To be compressible, port numbers must be in the range 0xf0b0-0xf0bf,
hexadecimal. That is 61616-61631 decimal.</p></li>
<li><p>IOBs: Must be big enough to hold one IEEE802.15.4 frame (typically 127).
There must be enough IOBs to decompose the largest IPv6 packet
(<code class="docutils literal notranslate"><span class="pre">CONFIG_NET_6LOWPAN_PKTSIZE</span></code>, default 1294, plus per frame overhead).</p></li>
</ol>
</section>
<section id="fragmentation-headers">
<h2>Fragmentation Headers<a class="headerlink" href="#fragmentation-headers" title="Permalink to this heading"></a></h2>
<p>A fragment header is placed at the beginning of the outgoing packet just
after the MAC header when the payload is too large to fit in a single IEEE
802.15.4 frame. The fragment header contains three fields: Datagram size,
datagram tag and datagram offset.</p>
<ol class="arabic simple">
<li><p>Datagram size describes the total (un-fragmented) payload.</p></li>
<li><p>Datagram tag identifies the set of fragments and is used to match
fragments of the same payload.</p></li>
<li><p>Datagram offset identifies the fragment’s offset within the un-
fragmented payload (in units of 8 bytes).</p></li>
</ol>
<p>The length of the fragment header length is four bytes for the first header
(FRAG1) and five bytes for all subsequent headers (FRAGN). For example,
this is a HC1 compressed first frame of a packet:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>41 88 2a cefa 3412 cdab ### 9-byte MAC header
c50e 000b ### 4-byte FRAG1 header
42 ### SIXLOWPAN_DISPATCH_HC1
fb ### SIXLOWPAN_HC1_HC_UDP_HC1_ENCODING
e0 ### SIXLOWPAN_HC1_HC_UDP_UDP_ENCODING
00 ### SIXLOWPAN_HC1_HC_UDP_TTL
10 ### SIXLOWPAN_HC1_HC_UDP_PORTS
0000 ### SIXLOWPAN_HC1_HC_UDP_CHKSUM
104 byte Payload follows:
4f4e452064617920 48656e6e792d7065 6e6e792077617320 7069636b696e6720
757020636f726e20 696e207468652063 6f726e7961726420 7768656e2d2d7768
61636b212d2d736f 6d657468696e6720 6869742068657220 75706f6e20746865
20686561642e2027
</pre></div>
</div>
<p>This is the second frame of the same transfer:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>41 88 2b cefa 3412 cdab ### 9-byte MAC header
e50e 000b 0d ### 5 byte FRAGN header
42 ### SIXLOWPAN_DISPATCH_HC1
fb ### SIXLOWPAN_HC1_HC_UDP_HC1_ENCODING
e0 ### SIXLOWPAN_HC1_HC_UDP_UDP_ENCODING
00 ### SIXLOWPAN_HC1_HC_UDP_TTL
10 ### SIXLOWPAN_HC1_HC_UDP_PORTS
0000 ### SIXLOWPAN_HC1_HC_UDP_CHKSUM
104 byte Payload follows:
476f6f646e657373 2067726163696f75 73206d6521272073 6169642048656e6e
792d70656e6e793b 202774686520736b 79277320612d676f 696e6720746f2066
616c6c3b2049206d 75737420676f2061 6e642074656c6c20 746865206b696e67
2e270a0a536f2073
</pre></div>
</div>
<p>The payload length is encoded in the LS 11-bits of the first 16-bit value:
In this example the payload size is 0x050e or 1,294. The tag is 0x000b. In
the second frame, the fifth byte contains the offset 0x0d which is 13 &lt;&lt; 3 =
104 bytes, the size of the payload on the first packet.</p>
</section>
<section id="star-configuration">
<h2>Star Configuration<a class="headerlink" href="#star-configuration" title="Permalink to this heading"></a></h2>
<p>The 6LoWPAN stack can be specially configured as member in a star topology;
either as a endpoint on the star os the star hub. The endpoint is
created with the following settings in the configuration file:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CONFIG_NET_STAR=y
CONFIG_NET_STARPOINT=y
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">CONFIG_NET_STARPOINT</span></code> selection informs the endpoint 6LoWPAN stack that
it must send all frames to the hub of the star, rather than directly to the
recipient. The star hub is assumed to be the coordinator.</p>
<p>The star hub configuration, on the other hand, uses these setting:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CONFIG_NET_STAR=y
CONFIG_NET_STARHUB=y
CONFIG_NET_IPFORWARD=y
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">CONFIG_NET_IPFORWARD</span></code> selection informs the hub that if it receives any
packets that are not destined for the hub, it should forward those packets
appropriately. This affects the behavior of IPv6 packet reception logic but
does not change the behavior of the 6LoWPAN stack.</p>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="index.html" class="btn btn-neutral float-left" title="Network Support" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="socketcan.html" class="btn btn-neutral float-right" title="SocketCAN Device Drivers" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023, The Apache Software Foundation.</p>
</div>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>