Thread协议基础
General Thread introduction
1.1 家用无线网络的要求
✔低功耗
✔弹性(网状)
✔基于IP
✔开放协议
✔安全和用户友好
✔快速上市
✔现有无线电芯片
关于弹性组网: Resilient (mesh)
- No single point of failure 无单点故障
- Self-healing 自我修复
- Interference robustness 干扰鲁棒性
- Self-extending 自我扩展
- Reliable enough for critical infrastructure 足够可靠,适用于关键基础设施
1.2 What is THREAD ?
- 为家庭及其连接产品提供安全的无线网状网络
- 基于久经考验的现有技术构建
- 在现有 802.15.4 芯片上运行
- 使用 6LoWPAN 和 IPv6 寻址
- UDP Transport
- 新的强制性安全体系结构
- 添加/删除产品简单且安全
- 可扩展到每个网络 250 多个产品
- 设计用于超低功耗操作
- 适用于关键基础设施
1.3 THREAD target applocations
Thread专为家庭中的各种产品而设计
- Appliances
- Access control
- Climate control
- Energy management
- Lighting
- Safety
- Security
Thread networking architecture
2.1 网络拓扑
Many Border Router +
One Thread Leader +
Up to 31 Thread Active Router +
Up to 512 per Active Router End Device =
Thousands of Devices Per Network (16K)
可路由设备:
- Active Router : 当网络的连接性相对有限时,REED 请求领导者使其成为活动路由器。 例如:当现有活动路由器的总数小于 < 16
- Router Eligible End Device (REED) : 在最初通过现有的Active Routers加入网络后,或在网络有足够的连接性时,立即加入网络。
- Leader : 如果它是网络分区中的初始设备,或者当当前的领导者不可用时;
The Border Router :
- Usually is a subset of Router Eligible Device
- Has at least one more different interface than IEEE 802.15.4 (e.g.: Wi-Fi, Ethernet, USB)
- Facilitates IP packet forwarding to and from the Thread network to home LAN or upstream IP infrastructure
- Can be a specialized networking device:
- wireless access point
- home gateway
- Or can be embedded in a consumer product:
- thermostat
- appliance
2.2 flexible network
- Devices join as Router Eligible End Devices or End Devices;
- REED 可以成为一个Router,如果Leader确定需要更好的覆盖范围;
- 所有Router通过Trickle机制和MLE向所有其他路由器保持状态;
- 所有Router通过Trickle机制和MLE维持Border Router的状态;
- Sleeping End Devices route through parent Router
- Router Eligible Devices can also maintain state
- Leader used to make decisions within network;
2.3 No single point of failure 无单点故障
- 不需要识别网络中的专门设备;
- Leader作出决定,但一旦失败,另一个Router将成为Leader
- 网络将在需要时增加Active Routers以改善连接性。
2.4 Low-Power End Devices
- 睡眠设备轮询父母的信息(或远程设备,如果应用程序已配置)
- 睡眠设备不需要与父母设备check in,从而实现低功耗操作
- 父母为睡眠设备保留信息
- 睡眠设备在失去连接时自动切换parent
Thread IP addressing architecture
3.1 IP地址分配
- IP Addresses are assigned at the border between the IP layer and each specific Media Interface below the IP stack(IP地址是在IP层和IP堆栈下面的每个特定媒体接口之间的边界上分配的)
- Multiple IP address can be assigned to the same Media Interface(多个IP地址可以分配给同一个媒体接口)
- The same address can be assigned to the multiple Media Interfaces on the same device or on different devices(同一个地址可以分配给同一个设备上的多个媒体接口,也可以分配给不同设备上的多个媒体接口。)
3.2 IPV6地址符号基础
- An IPv6 address has 16 bytes (128 bits), represented as eight 2-byte groups:
2001:3344:5566:7788:99AA:BBCC:DDEE:0000
- All
0000
groups can be represented as a single0
- 每个group开头的0可以省略
- 所有0组的最长连续集合可表示为2个冒号:
2001:0044:0000:0000:0000:BBCC:00EE:0000
is equivalent to2001:44::BBCC:EE:0
- Addresses 分为 Network Prefix and Network Address 网络前缀和网络地址:
- Representing the length of the network prefix can be done with a
/prefixlen notation
2001:3344:5566:7788:99AA:BBCC:DDEE:FF00/64
3.3 IPV6 ADDRESS CLASSES
- Unicast –Identifies a single Media Interface on a single network host(识别单一网络主机上的单一媒体接口):
- Network Prefix: 64 bits
- Network Address = Interface Identifier (IID): 64 bits
- Multicast–Identifies all network hosts which have assigned a multicast group to one or more Media Interfaces(识别已将multicast group分配给一个或多个媒体接口的所有network hosts)
- Multicast Prefix: 8 bits all 1s (multicast address format FF::)
- Flags: 4 bits
- Scope: 4 bits
- Multicast Group: 112 bits
- Anycast–Identifies a unicast-like address assigned to multiple interfaces where the final destination of packets can be any of the nodes using the address(标识分配给多个接口的类似单播的地址,其中数据包的最终目的地可以是使用该地址的任何节点)
3.4 HOW MANY ADDRESSES DOES A THREAD DEVICE GET?
Once joined to a network, a Thread device will get:
- At least 3 Unicast IPv6 addresses to the Thread Interface:
- Link local address (LL64):
- Mesh local address (ML16, RLOC):
- Mesh local address (ML64, ML-EID):
- Two All Thread Nodes multicast addresses:
- Link local all Thread Nodes(Multicast):
- Realm local all Thread Nodes(Multicast):
- Optional will also get:
- Unique local address (ULA):
- Global unique address (GUA):
3.5 THREAD SCOPES
- SCOPES在使用和转发地址的数据包时指定网络的边界;
- Link Local single-hop within radio range
- Mesh Local multi-hop within the PAN
- Unique Local multi-hop within the PAN and inter-PAN for the same network
- Global internet addressable
UNICAST LINK LOCAL ADDRESS LL64
- 允许在IEEE802.15.4无线电范围内的直接邻居之间进行通信,换句话说,就是那些相距一跳的链接。
- LL64接口标识符被设置为MAC扩展地址($thr get randomaddr),universal/local bit被颠倒。
UNICAST MESH LOCAL ADDRESS ML16
- 到达 Thread 网络中的任何设备,供 Thread 堆栈内部使用。
- RLOC 嵌入了Router ID(分配了leader)和Child ID(分配了路由器)
- 每当 Thread Network 分区拓扑发生变化时,ML16 都会发生变化
UNICAST MESH LOCAL ADDRESS
- 到达 Thread 网络中的任何节点
- 强烈推荐application使用
- Mesh Local Endpoint Identifier (ML-EID)由 Thread Stack 随机生成,并在重启后保持不变
Multicast
Link local all Thread nodes
执行Multicast而不重试数据包,消息包将只被IEEE 802.15.4无线电范围内的邻居接收。
Realm local all Thread nodes
- 数据包可以到达网络的每个节点,只要节点距离请求者最多 2 个“跳”
- 每次到达路由器时,数据包都会被转发 3 次。