IPv6 - Internet Protocol version 6#

pcapkit.protocols.internet.ipv6 contains IPv6 only, which implements extractor for Internet Protocol version 6 (IPv6) [*], whose structure is described as below:

Octets

Bits

Name

Description

0

0

ip.version

Version (6)

0

4

ip.class

Traffic Class

1

12

ip.label

Flow Label

4

32

ip.payload

Payload Length (header excludes)

6

48

ip.next

Next Header

7

56

ip.limit

Hop Limit

8

64

ip.src

Source Address

24

192

ip.dst

Destination Address

class pcapkit.protocols.internet.ipv6.IPv6(file=None, length=None, **kwargs)[source]#

Bases: IP[IPv6, IPv6]

This class implements Internet Protocol version 6.

property name: Literal['Internet Protocol version 6']#

Name of corresponding protocol.

property length: Literal[40]#

Header length of corresponding protocol.

property protocol: TransType#

Name of next layer protocol.

property src: IPv6Address#

Source IP address.

property dst: IPv6Address#

Destination IP address.

property extension_headers: OrderedMultiDict[ExtensionHeader, ProtocolBase]#

IPv6 extension header records.

classmethod id()[source]#

Index ID of the protocol.

Return type:

tuple[Literal['IPv6']]

Returns:

Index ID of the protocol.

read(length=None, *, __packet__=None, **kwargs)[source]#

Read Internet Protocol version 6 (IPv6).

Structure of IPv6 header [RFC 2460]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class |           Flow Label                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Payload Length        |  Next Header  |   Hop Limit   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Source Address                        +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                      Destination Address                      +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • length (Optional[int]) – Length of packet data.

  • __packet__ – Optional packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

IPv6

Returns:

Parsed packet data.

make(traffic_class=0, flow_label=0, next=TransType.UDP, next_default=None, next_namespace=None, next_reversed=False, hop_limit=64, src='::1', dst='::', payload=b'', **kwargs)[source]#

Make (construct) packet data.

Parameters:
Return type:

IPv6

Returns:

Constructed packet data.

classmethod _make_data(data)[source]#

Create key-value pairs from data for protocol construction.

Parameters:

data (IPv6) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

_decode_next_layer(ipv6, proto=None, length=None, *, packet=None)[source]#

Decode next layer extractor.

Parameters:
Return type:

IPv6

Returns:

Current protocol with next layer extracted.

classmethod __index__()[source]#

Numeral registry index of the protocol.

Return type:

TransType

Returns:

Numeral registry index of the protocol in IANA.

Header Schemas#

class pcapkit.protocols.schema.internet.ipv6.IPv6(dict_=None, **kwargs)[source]#

Bases: Schema

Header schema for IPv6 packet.

hextet: IPv6Hextet = <BitField hextet>#

Version, traffic class and flow label.

length: int = <UInt16Field length>#

Payload length.

next: Enum_TransType = <EnumField next>#

Next header.

limit: int = <UInt8Field limit>#

Hop limit.

src: IPv6Address = <IPv6AddressField src>#

Source address.

dst: IPv6Address = <IPv6AddressField dst>#

Destination address.

payload: bytes = <PayloadField payload>#

Payload.

Type Stubs#

class pcapkit.protocols.schema.internet.ipv6.IPv6Hextet#

Bases: TypedDict

Version, traffic class and flow label.

version: int#

Version.

class: int#

Traffic class.

label: int#

Flow label.

Data Models#

class pcapkit.protocols.data.internet.ipv6.IPv6(*args: Any, **kwargs: Any)[source]#

Bases: Protocol

Data model for Internet Protocol version 6.

Important

Due to the preserved keyword conflict, please use from_dict() to create an instance of this data model.

class: int#

Traffic class.

Note

This field is conflict with class keyword. To access this field, directly use getattr() instead.

version: Literal[6]#

Version.

label: int#

Flow label.

payload: int#

Payload length.

next: TransType#

Next header.

limit: int#

Hop limit.

src: IPv6Address#

Source address.

dst: IPv6Address#

Destination address.

fragment: Packet#

Fragmented packet header & payload (from IPv6-Frag header).

protocol: TransType#

Highest header protocol type (extension header excluded).

hdr_len: int#

Header length (including extension headers).

raw_len: int#

Raw payload length (excluding extension headers).

Footnotes