scapy.layers.sixlowpan

6LoWPAN Protocol Stack

此实现遵循以下文档:

  • 通过IEEE 802.15.4网络传输IPv6数据包

  • 低功耗有损网络(6LoWPAN)中IPv6数据报的压缩格式:draft-ietf-6lowpan-hc-15

  • RFC 4291

Application

应用协议

Transport

UDP

TCP

Network

IPv6

LoWPAN

数据链路层

IEEE 802.15.4 MAC

Physical

IEEE 802.15.4物理层

注意:

  • 仅支持IPv6

  • LoWPAN位于网络和数据链路层之间的中间

Internet控制消息协议v6(ICMPv6)用于控制消息传递.

完整的IPv6和LoWPAN格式之间的适配由6LoWPAN孤岛边缘的路由器执行.

LoWPAN支持寻址; 链路层地址和IPv6地址之间的直接映射用于实现压缩.

Known Issues:
  • 未实现的上下文信息

  • 下一个报头压缩技术

  • 未实现的LoWPAN广播

class scapy.layers.sixlowpan.BitVarSizeField(name, default, calculate_length=None)

Bases: scapy.fields.BitField

addfield(pkt, s, val)
getfield(pkt, s)
length_f
class scapy.layers.sixlowpan.IP6FieldLenField(name, default, size, length_of=None)

Bases: scapy.fields.IP6Field

addfield(pkt, s, val)

将内部值添加到字符串

getfield(pkt, s)
length_of
class scapy.layers.sixlowpan.LoWPANFragmentationFirst

Bases: scapy.packet.Packet

aliastypes
fields_desc
LoWPANFragmentationFirst字段

reserved

BitField (5位)

24

datagramSize

BitField (11位)

0

datagramTag

XShortField

0

class scapy.layers.sixlowpan.LoWPANFragmentationSubsequent

Bases: scapy.packet.Packet

aliastypes
fields_desc
LoWPANFragmentation后续字段

reserved

BitField (5位)

28

datagramSize

BitField (11位)

0

datagramTag

XShortField

<RandShort>

datagramOffset

ByteField

0

class scapy.layers.sixlowpan.LoWPANMesh

Bases: scapy.packet.Packet

aliastypes
fields_desc
LoWPANMesh字段

reserved

BitField (2 bits)

2

_v

BitEnumField (1位)

0

_f

BitEnumField (1位)

0

_hopsLeft

BitField (4位)

0

_sourceAddr

SixLoWPANAddrField

0

_destinyAddr

SixLoWPANAddrField

0

guess_payload_class(payload)
payload_guess

可能的子层: LoWPANFragmentationFirstLoWPANFragmentationSubsequent

class scapy.layers.sixlowpan.LoWPANUncompressedIPv6

Bases: scapy.packet.Packet

aliastypes
default_payload_class(pay)
fields_desc
LoWPANUncompressedIPv6字段

_type

BitField (8位)

0

class scapy.layers.sixlowpan.LoWPAN_HC1(_pkt=None, *args, **kwargs)

Bases: scapy.packet.Raw

aliastypes
fields_desc
LoWPAN_HC1字段

load

StrField

b''

class scapy.layers.sixlowpan.LoWPAN_IPHC

Bases: scapy.packet.Packet

6LoWPAN IPv6标头压缩数据包

It follows the implementation of draft-ietf-6lowpan-hc-15.

aliastypes
compressDestinyAddr(ipv6)
compressSourceAddr(ipv6)
decompressDestinyAddr(packet)
decompressSourceAddr(packet)
do_build()
do_build_payload()
fields_desc
LoWPAN_IPHC字段

_reserved

BitField (3位)

3

tf

BitField (2位)

0

nh

BitEnumField (1位)

0

hlim

BitField (2位)

0

cid

BitEnumField (1位)

0

sac

BitEnumField (1位)

0

sam

BitEnumField (2位)

0

m

BitEnumField (1位)

0

dac

BitEnumField (1位)

0

dam

BitEnumField (2位)

0

_contextIdentifierExtension

ByteField (Cond)

0

tc_ecn

BitVarSizeField (0位)

0

tc_dscp

BitVarSizeField (0位)

0

_padd

BitVarSizeField (0位)

0

flowlabel

BitVarSizeField (0位)

0

_nhField

ByteField (Cond)

0

_hopLimit

ByteField (Cond)

0

sourceAddr

IP6FieldLenField

'::'

destinyAddr

IP6FieldLenField

'::'

header_compression

FlagsField (Cond)(8位)

<Flag 0 ()>

udpSourcePort

BitFieldLenField (条件)(16位)

0

udpDestinyPort

BitFieldLenField (条件)(16位)

0

udpChecksum

XShortField (Cond)

0

guess_payload_class(payload)
post_dissect(data)

剖析压缩到此IPHC数据包中的IPv6包.

数据包有效载荷需要解压缩,并且根据参数,应完成几次转换.

class scapy.layers.sixlowpan.SixLoWPAN

Bases: scapy.packet.Packet

aliastypes
classmethod dispatch_hook(_pkt=b'', *args, **kargs)

根据有效载荷的内容,我们应该解释的帧类型

payload_guess

可能的子层: LoWPANFragmentationFirstLoWPANFragmentationSubsequentLoWPANMeshLoWPAN_IPHC

class scapy.layers.sixlowpan.SixLoWPANAddrField(name, default, length_of=None, fmt='H', count_of=None, adjust=<function FieldLenField.<lambda>>, fld=None)

Bases: scapy.fields.FieldLenField

特殊字段,用于存储6LoWPAN地址

6LoWPAN地址的长度取决于其他参数. 此特殊字段允许保存它们,并对其进行编码/解码,无论它们具有哪些编码参数.

addfield(pkt, s, val)

将内部值添加到字符串

getfield(pkt, s)
i2repr(pkt, x)
scapy.layers.sixlowpan.destiny_addr_mode(pkt)

此函数取决于参数,返回目标地址要使用的位数.

关键字参数:pkt –数据包对象实例

scapy.layers.sixlowpan.flowlabel_len(pkt)

此函数取决于参数,返回将由流量类的填充使用的位数.

关键字参数:pkt –数据包对象实例

scapy.layers.sixlowpan.nhc_port(pkt)
scapy.layers.sixlowpan.pad_trafficclass(pkt)

此函数取决于参数,返回将由流量类的填充使用的位数.

关键字参数:pkt –数据包对象实例

scapy.layers.sixlowpan.sixlowpan_defragment(packet_list)
scapy.layers.sixlowpan.sixlowpan_fragment(packet, datagram_tag=1)

将数据包分成不同的链接,以传输6lowpan数据包. 用法示例:

>>> ipv6 = ..... (very big packet)
>>> pkts = sixlowpan_fragment(ipv6, datagram_tag=0x17)
>>> send = [Dot15d4()/Dot15d4Data()/x for x in pkts]
>>> wireshark(send)
scapy.layers.sixlowpan.source_addr_mode2(pkt)

source_addr_mode

该函数取决于参数,返回源地址要使用的位数.

关键字参数:pkt –数据包对象实例