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: pcapkit.protocols.internet.ip.IP

This class implements Internet Protocol version 6.

classmethod __index__()[source]

Numeral registry index of the protocol.

Returns

Numeral registry index of the protocol in IANA.

Return type

pcapkit.const.reg.transtype.TransType

__length_hint__()[source]

Return an estimated length for the object.

Return type

Literal[40]

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

Decode next layer extractor.

Parameters
  • ipv6 (DataType_IPv6) – info buffer

  • proto (str) – next layer protocol name

  • length (int) – valid (not padding) length

Returns

current protocol with next layer extracted

Return type

DataType_IPv6

_read_ip_addr()[source]

Read IP address.

Returns

Parsed IP address.

Return type

ipaddress.IPv6Address

_read_ip_hextet()[source]

Read first four hextets of IPv6.

Returns

Parsed hextets data, including version number, traffic class and flow label.

Return type

Tuple[int, int, int]

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

Literal[‘IPv6’]

make(**kwargs)[source]

Make (construct) packet data.

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

read(length=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.

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Parsed packet data.

Return type

DataType_IPv6

property length

Header length of corresponding protocol.

Return type

int

property name

Name of corresponding protocol.

Return type

Literal[‘Internet Protocol version 6’]

property protocol

Name of next layer protocol.

Return type

pcapkit.const.reg.transtype.TransType

Data Structure

Important

Following classes are only for documentation purpose. They do NOT exist in the pcapkit module.

class pcapkit.protocols.internet.ipv6.DataType_IPv6
Bases

TypedDict

Structure of IPv6 header [RFC 2460].

version: Literal[6]

Version.

class: int

Traffic class.

label: int

Flow label.

payload: int

Payload length.

next: pcapkit.const.reg.transtype.TransType

Next header.

limit: int

Hop limit.

src: ipaddress.IPv6Address

Source address.

dst: ipaddress.IPv6Address

Destination address.

packet: bytes

Raw packet data.


*

https://en.wikipedia.org/wiki/IPv6_packet