IPv4 - Internet Protocol version 4¶
pcapkit.protocols.internet.ipv4
contains
IPv4
only,
which implements extractor for Internet Protocol
version 4 (IPv4) [*], whose structure is described
as below:
Octets |
Bits |
Name |
Description |
---|---|---|---|
0 |
0 |
|
Version ( |
0 |
4 |
|
Internal Header Length (IHL) |
1 |
8 |
|
Differentiated Services Code Point (DSCP) |
1 |
14 |
|
Explicit Congestion Notification (ECN) |
2 |
16 |
|
Total Length |
4 |
32 |
|
Identification |
6 |
48 |
Reserved Bit (must be |
|
6 |
49 |
|
Don’t Fragment (DF) |
6 |
50 |
|
More Fragments (MF) |
6 |
51 |
|
Fragment Offset |
8 |
64 |
|
Time To Live (TTL) |
9 |
72 |
|
Protocol (Transport Layer) |
10 |
80 |
|
Header Checksum |
12 |
96 |
|
Source IP Address |
16 |
128 |
|
Destination IP Address |
20 |
160 |
|
IP Options (if IHL > |
- class pcapkit.protocols.internet.ipv4.IPv4(file=None, length=None, **kwargs)[source]¶
-
This class implements Internet Protocol version 4.
This class currently supports parsing of the following IPv4 options, which are directly mapped to the
pcapkit.const.ipv4.option_number.OptionNumber
enumeration:Option Code
Option Parser
Option Constructor
- property name: Literal['Internet Protocol version 4']¶
Name of corresponding protocol.
- property src: IPv4Address¶
Source IP address.
- property dst: IPv4Address¶
Destination IP address.
- classmethod register_option(code, meth)[source]¶
Register an option parser.
- Parameters:
code (
OptionNumber
) – IPv4 option code.meth (
str
|tuple
[Callable
[[Option
,OrderedMultiDict
[OptionNumber
,Option
]],Option
],Callable
[[OptionNumber
,Optional
[Option
],Any
],Option
]]) – Method name or callable to parse and/or construct the option.
- Return type:
- read(length=None, **kwargs)[source]¶
Read Internet Protocol version 4 (IPv4).
Structure of IPv4 header [RFC 791]:
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| IHL |Type of Service| Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identification |Flags| Fragment Offset | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Time to Live | Protocol | Header Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- make(tos_pre=<ToSPrecedence.Routine: 0>, tos_pre_default=None, tos_pre_namespace=None, tos_pre_reversed=False, tos_del=<ToSDelay.NORMAL: 0>, tos_del_default=None, tos_del_namespace=None, tos_del_reversed=False, tos_thr=<ToSThroughput.NORMAL: 0>, tos_thr_default=None, tos_thr_namespace=None, tos_thr_reversed=False, tos_rel=<ToSReliability.NORMAL: 0>, tos_rel_default=None, tos_rel_namespace=None, tos_rel_reversed=False, tos_ecn=<ToSECN.Not_ECT: 0>, tos_ecn_default=None, tos_ecn_namespace=None, tos_ecn_reversed=False, id=0, df=False, mf=False, offset=0, ttl=0, protocol=<TransType.UDP: 17>, protocol_default=None, protocol_namespace=None, protocol_reversed=False, checksum=b'\\x00\\x00', src='127.0.0.1', dst='0.0.0.0', options=None, payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
tos_pre (
ToSPrecedence
|IntEnum
|IntEnum
|int
|str
) – Precedence of the packet.tos_pre_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace oftos_pre
.tos_pre_reversed (
bool
) – If the namespace oftos_pre
is reversed.tos_del (
ToSDelay
|IntEnum
|IntEnum
|int
|str
) – Delay of the packet.tos_del_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace oftos_del
.tos_del_reversed (
bool
) – If the namespace oftos_del
is reversed.tos_thr (
ToSThroughput
|IntEnum
|IntEnum
|int
|str
) – Throughput of the packet.tos_thr_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace oftos_thr
.tos_thr_reversed (
bool
) – If the namespace oftos_thr
is reversed.tos_rel (
ToSReliability
|IntEnum
|IntEnum
|int
|str
) – Reliability of the packet.tos_rel_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace oftos_rel
.tos_rel_reversed (
bool
) – If the namespace oftos_rel
is reversed.tos_ecn (
ToSECN
|IntEnum
|IntEnum
|int
|str
) – ECN of the packet.tos_ecn_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace oftos_ecn
.tos_ecn_reversed (
bool
) – If the namespace oftos_ecn
is reversed.id (
int
) – Identification of the packet.df (
bool
) – Don’t fragment flag.mf (
bool
) – More fragments flag.offset (
int
) – Fragment offset.protocol (
TransType
|IntEnum
|IntEnum
|int
|str
) – Payload protocol of the packet.protocol_default (
Optional
[int
]) – Default value ofprotocol
.protocol_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace ofprotocol
.protocol_reversed (
bool
) – If the namespace ofprotocol
is reversed.checksum (
bytes
) – Checksum of the packet.src (
IPv4Address
|str
|int
|bytes
) – Source address of the packet.dst (
IPv4Address
|str
|int
|bytes
) – Destination address of the packet.options (
Union
[list
[Option
|tuple
[OptionNumber
,dict
[str
,Any
]] |bytes
],OrderedMultiDict
[OptionNumber
,Option
],None
]) – Options of the packet.payload (
bytes
|ProtocolBase
|Schema
) – Payload of the packet.**kwargs (
Any
) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- _read_ipv4_options(length)[source]¶
Read IPv4 option list.
- Parameters:
length (
int
) – length of options- Return type:
- Returns:
Extracted IPv4 options.
- Raises:
ProtocolError – If the threshold is NOT matching.
- _read_opt_unassigned(schema, *, options)[source]¶
Read IPv4 unassigned options.
Structure of IPv4 unassigned options [RFC 791]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | type | length | option data ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
UnassignedOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is LESS THAN3
.
- _read_opt_eool(schema, *, options)[source]¶
Read IPv4 End of Option List (
EOOL
) option.Structure of IPv4 End of Option List (
EOOL
) option [RFC 719]:+--------+ |00000000| +--------+ Type=0
- Parameters:
schema (
EOOLOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- _read_opt_nop(schema, *, options)[source]¶
Read IPv4 No Operation (
NOP
) option.Structure of IPv4 No Operation (
NOP
) option [RFC 719]:+--------+ |00000001| +--------+ Type=1
- Parameters:
schema (
NOPOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- _read_opt_sec(schema, *, options)[source]¶
Read IPv4 Security (
SEC
) option.Structure of IPv4 Security (
SEC
) option [RFC 1108]:+------------+------------+------------+-------------//----------+ | 10000010 | XXXXXXXX | SSSSSSSS | AAAAAAA[1] AAAAAAA0 | | | | | [0] | +------------+------------+------------+-------------//----------+ TYPE = 130 LENGTH CLASSIFICATION PROTECTION LEVEL AUTHORITY FLAGS
- Parameters:
schema (
SECOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is LESS THAN3
.
- _read_opt_lsr(schema, *, options)[source]¶
Read IPv4 Loose Source Route (
LSR
) option.Structure of IPv4 Loose Source Route (
LSR
) option [RFC 791]:+--------+--------+--------+---------//--------+ |10000011| length | pointer| route data | +--------+--------+--------+---------//--------+
- Parameters:
schema (
LSROption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If option is malformed.
- _read_opt_ts(schema, *, options)[source]¶
Read IPv4 Time Stamp (
TS
) option.Structure of IPv4 Time Stamp (
TS
) option [RFC 791]:+--------+--------+--------+--------+ |01000100| length | pointer|oflw|flg| +--------+--------+--------+--------+ | internet address | +--------+--------+--------+--------+ | timestamp | +--------+--------+--------+--------+ | . | . .
- Parameters:
schema (
TSOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If the option is malformed.
- _read_opt_e_sec(schema, *, options)[source]¶
Read IPv4 Extended Security (
E-SEC
) option.Structure of IPv4 Extended Security (
E-SEC
) option [RFC 1108]:+------------+------------+------------+-------//-------+ | 10000101 | 000LLLLL | AAAAAAAA | add sec info | +------------+------------+------------+-------//-------+ TYPE = 133 LENGTH ADDITIONAL ADDITIONAL SECURITY INFO SECURITY FORMAT CODE INFO
- Parameters:
schema (
ESECOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is LESS THAN3
.
- _read_opt_rr(schema, *, options)[source]¶
Read IPv4 Record Route (
RR
) option.Structure of IPv4 Record Route (
RR
) option [RFC 791]:+--------+--------+--------+---------//--------+ |00000111| length | pointer| route data | +--------+--------+--------+---------//--------+ Type=7
- Parameters:
schema (
RROption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If option is malformed.
- _read_opt_sid(schema, *, options)[source]¶
Read IPv4 Stream ID (
SID
) option.Structure of IPv4 Stream ID (
SID
) option [RFC 791][RFC 6814]:+--------+--------+--------+--------+ |10001000|00000010| Stream ID | +--------+--------+--------+--------+ Type=136 Length=4
- Parameters:
schema (
SIDOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is NOT4
.
- _read_opt_ssr(schema, *, options)[source]¶
Read IPv4 Strict Source Route (
SSR
) option.Structure of IPv4 Strict Source Route (
SSR
) option [RFC 791]:+--------+--------+--------+---------//--------+ |10001001| length | pointer| route data | +--------+--------+--------+---------//--------+ Type=137
- Parameters:
schema (
SSROption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If option is malformed.
- _read_opt_mtup(schema, *, options)[source]¶
Read IPv4 MTU Probe (
MTUP
) option.Structure of IPv4 MTU Probe (
MTUP
) option [RFC 1063][RFC 1191]:+--------+--------+--------+--------+ |00001011|00000100| 2 octet value | +--------+--------+--------+--------+
- Parameters:
schema (
MTUPOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is NOT4
.
- _read_opt_mtur(schema, *, options)[source]¶
Read IPv4 MTU Reply (
MTUR
) option.Structure of IPv4 MTU Reply (
MTUR
) option [RFC 1063][RFC 1191]:+--------+--------+--------+--------+ |00001100|00000100| 2 octet value | +--------+--------+--------+--------+
- Parameters:
schema (
MTUROption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is NOT4
.
- _read_opt_tr(schema, *, options)[source]¶
Read IPv4 Traceroute (
TR
) option.Structure of IPv4 Traceroute (
TR
) option [RFC 1393][RFC 6814]:0 8 16 24 +-+-+-+-+-+-+-+-+---------------+---------------+---------------+ |F| C | Number | Length | ID Number | +-+-+-+-+-+-+-+-+---------------+---------------+---------------+ | Outbound Hop Count | Return Hop Count | +---------------+---------------+---------------+---------------+ | Originator IP Address | +---------------+---------------+---------------+---------------+
- Parameters:
schema (
TROption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is NOT12
.
- _read_opt_rtralt(schema, *, options)[source]¶
Read IPv4 Router Alert (
RTRALT
) option.Structure of IPv4 Router Alert (
RTRALT
) option [RFC 2113]:+--------+--------+--------+--------+ |10010100|00000100| 2 octet value | +--------+--------+--------+--------+
- Parameters:
schema (
RTRALTOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
length
is NOT4
.
- _read_opt_qs(schema, *, options)[source]¶
Read IPv4 Quick Start (
QS
) option.Structure of IPv4 Quick Start (
QS
) option [RFC 4782]:A Quick-Start Request
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option | Length=8 | Func. | Rate | QS TTL | | | | 0000 |Request| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | QS Nonce | R | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Report of Approved Rate
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option | Length=8 | Func. | Rate | Not Used | | | | 1000 | Report| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | QS Nonce | R | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
QSOption
) – parsed option schemaoptions (
OrderedMultiDict
[OptionNumber
,Option
]) – extracted IPv4 options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If the option is malformed.
- _make_opt_unassigned(kind, option=None, *, data, **kwargs)[source]¶
Make IPv4 unassigned options.
- Parameters:
kind (
OptionNumber
) – option type codeoption (
Optional
[UnassignedOption
]) – option datadata (
bytes
) – option payload**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_eool(kind, option=None, **kwargs)[source]¶
Make IPv4 End of Option List (
EOOL
) option.- Parameters:
kind (
OptionNumber
) – option type codeoption (
Optional
[EOOLOption
]) – option data**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_nop(kind, option=None, **kwargs)[source]¶
Make IPv4 No Operation (
NOP
) option.- Parameters:
kind (
OptionNumber
) – option type code**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_sec(kind, option=None, *, level=<ClassificationLevel.Unclassified: 171>, level_default=None, level_namespace=None, level_reversed=False, authorities=None, **kwargs)[source]¶
Make IPv4 Security (
SEC
) option.- Parameters:
kind (
OptionNumber
) – option type codesec – security option
**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_lsr(kind, option=None, *, counts=10, route=None, **kwargs)[source]¶
Make IPv4 Loose Source and Record Route (
LSR
) option.- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_ts(kind, option=None, *, counts=5, overflow=0, timestamp=None, **kwargs)[source]¶
Make IPv4 Timestamp (
TS
) option.- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_e_sec(kind, option=None, *, format=0, info=None, **kwargs)[source]¶
Make IPv4 Extended Security (
E-SEC
) option.- Parameters:
kind (
OptionNumber
) – option type codeoption (
Optional
[ESECOption
]) – option dataformat (
int
) – additional security information format code**kwargs (
Any
) – arbitrary keyword argumentsReturns – Constructured option schema.
- Return type:
- _make_opt_rr(kind, option=None, *, counts=10, route=None, **kwargs)[source]¶
Make IPv4 Record Route (
RR
) option.- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_ssr(kind, option=None, *, counts=10, route=None, **kwargs)[source]¶
Make IPv4 Strict Source Route (
SSR
) option.- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_mtup(kind, option=None, *, mtu=0, **kwargs)[source]¶
Make IPv4 MTU Probe (
MTUP
) option.- Parameters:
kind (
OptionNumber
) – option type codeoption (
Optional
[MTUPOption
]) – option datamtu (
int
) – MTU value**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_mtur(kind, option=None, *, mtu=0, **kwargs)[source]¶
Make IPv4 MTU Reply (
MTUR
) option.- Parameters:
kind (
OptionNumber
) – option type codeoption (
Optional
[MTUROption
]) – option datamtu (
int
) – MTU value**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_tr(kind, option=None, *, id=0, out=0, ret=0, origin='127.0.0.1', **kwargs)[source]¶
Make IPv4 Traceroute (
TR
) option.- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_rtralt(kind, option=None, *, alert=<RouterAlert.Aggregated_Reservation_Nesting_Level_0: 1>, alert_default=None, alert_namespace=None, alert_reversed=False, **kwargs)[source]¶
Make IPv4 Router Alert (
RTRALT
) option.- Parameters:
kind (
OptionNumber
) – option type codeoption (
Optional
[RTRALTOption
]) – option dataalert (
RouterAlert
|IntEnum
|IntEnum
|int
|str
) – router alert typealert_default (
Optional
[int
]) – default value for router alert typealert_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – namespace for router alert typealert_reversed (
bool
) – whether router alert type is reversed**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_qs(kind, option=None, *, func=<QSFunction.Quick_Start_Request: 0>, func_default=None, func_namespace=None, func_reversed=False, rate=0, ttl=0, nonce=0, **kwargs)[source]¶
Make IPv4 Quick-Start (
QS
) option.- Parameters:
code – option type value
opt – option data
func (
QSFunction
|IntEnum
|IntEnum
|str
|int
) – QS function typefunc_default (
Optional
[int
]) – default value for QS function typefunc_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – namespace for QS function typefunc_reversed (
bool
) – reversed flag for QS function typerate (
int
) – rate (in kbps)nonce (
int
) – nonce value**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
Header Schemas¶
- class pcapkit.protocols.schema.internet.ipv4.IPv4(dict_=None, **kwargs)[source]¶
Bases:
Schema
Header schema for IPv4 packet.
- vihl: VerIHLField = <BitField vihl>¶
Version and header length.
- tos: ToSField = <BitField tos>¶
Type of service.
- length: int = <UInt16Field length>¶
Total length.
- id: int = <UInt16Field id>¶
Identification.
- flags: Flags = <BitField flags>¶
Flags and fragment offset.
- ttl: int = <UInt8Field ttl>¶
Time to live.
- proto: Enum_TransType = <EnumField proto>¶
Protocol.
- chksum: bytes = <BytesField chksum>¶
Header checksum.
- src: IPv4Address = <IPv4AddressField src>¶
Source address.
- dst: IPv4Address = <IPv4AddressField dst>¶
Destination address.
- options: list[Option] = <OptionField options>¶
Options.
- padding: bytes = <PaddingField padding>¶
Padding.
- payload: bytes = <PayloadField payload>¶
Payload.
- class pcapkit.protocols.schema.internet.ipv4.Option(dict_=None, **kwargs)[source]¶
Bases:
EnumSchema
[OptionNumber
]Header schema for IPv4 options.
- type: Enum_OptionNumber = <EnumField type>¶
Option type.
- length: int = <ConditionalField length>¶
Option length.
- class pcapkit.protocols.schema.internet.ipv4.UnassignedOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 unassigned options.
- data: bytes = <BytesField data>¶
Option data.
- class pcapkit.protocols.schema.internet.ipv4.EOOLOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 end of option list (
EOOL
) option.
- class pcapkit.protocols.schema.internet.ipv4.NOPOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 no operation (
NOP
) option.
- class pcapkit.protocols.schema.internet.ipv4.SECOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 security (
SEC
) option.- level: Enum_ClassificationLevel = <EnumField level>¶
Classification level.
- data: bytes = <ConditionalField data>¶
Protection authority flags.
- class pcapkit.protocols.schema.internet.ipv4.LSROption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 loose source route (
LSR
) option.- pointer: int = <UInt8Field pointer>¶
Pointer.
- route: list[IPv4Address] = <ListField route>¶
Route.
- remainder: bytes = <PaddingField remainder>¶
Remaining data buffer0.
- class pcapkit.protocols.schema.internet.ipv4.TSOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 timestamp (
TS
) option.- pointer: int = <UInt8Field pointer>¶
Pointer.
- flags: TSFlags = <BitField flags>¶
Overflow and flags.
- ts_data: list[int] = <ListField ts_data>¶
Timestamps and internet addresses.
- remainder: bytes = <PaddingField remainder>¶
Remaining data buffer.
- class pcapkit.protocols.schema.internet.ipv4.ESECOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 extended security (
ESEC
) option.- format: int = <UInt8Field format>¶
Additional security information format code.
- info: bytes = <ConditionalField info>¶
Additional security information.
- class pcapkit.protocols.schema.internet.ipv4.RROption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 record route (
RR
) option.- pointer: int = <UInt8Field pointer>¶
Pointer.
- route: list[IPv4Address] = <ListField route>¶
Route.
- remainder: bytes = <PaddingField remainder>¶
Remaining data buffer0.
- class pcapkit.protocols.schema.internet.ipv4.SIDOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 stream identifier (
SID
) option.- sid: int = <UInt32Field sid>¶
Stream identifier.
- class pcapkit.protocols.schema.internet.ipv4.SSROption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 strict source route (
SSR
) option.- pointer: int = <UInt8Field pointer>¶
Pointer.
- route: list[IPv4Address] = <ListField route>¶
Route.
- remainder: bytes = <PaddingField remainder>¶
Remaining data buffer0.
- class pcapkit.protocols.schema.internet.ipv4.MTUPOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 MTU probe (
MTUP
) option.- mtu: int = <UInt16Field mtu>¶
MTU.
- class pcapkit.protocols.schema.internet.ipv4.MTUROption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 MTU reply (
MTUR
) option.- mtu: int = <UInt16Field mtu>¶
MTU.
- class pcapkit.protocols.schema.internet.ipv4.TROption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 traceroute (
TR
) option.- id: int = <UInt16Field id>¶
ID number.
- out: int = <UInt16Field out>¶
Outbound hop count.
- ret: int = <UInt16Field ret>¶
Return hop count.
- origin: IPv4Address = <IPv4AddressField origin>¶
Originator IP address.
- class pcapkit.protocols.schema.internet.ipv4.RTRALTOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Header schema for IPv4 router alert (
RTRALT
) option.- alert: Enum_RouterAlert = <EnumField alert>¶
Router alert value.
- class pcapkit.protocols.schema.internet.ipv4._QSOption(dict_=None, **kwargs)[source]¶
Bases:
Schema
Header schema for IPv4 quick start (
QS
) options in generic representation.- flags: QSTestFlags = <ForwardMatchField flags>¶
Flags.
- data: QuickStartRequestOption | QuickStartReportOption = <SwitchField data>¶
QS data.
- class pcapkit.protocols.schema.internet.ipv4.QSOption(dict_=None, **kwargs)[source]¶
Bases:
Option
,EnumSchema
[QSFunction
]Header schema for IPV4 quick start (
QS
) options.- flags: QuickStartFlags = <BitField flags>¶
Flags.
- class pcapkit.protocols.schema.internet.ipv4.QuickStartRequestOption(dict_=None, **kwargs)[source]¶
Bases:
QSOption
Header schema for IPV4 quick start request options.
- ttl: int = <UInt8Field ttl>¶
QS time-to-live (TTL).
- nonce: QSNonce = <BitField nonce>¶
QS nonce.
- class pcapkit.protocols.schema.internet.ipv4.QuickStartReportOption(dict_=None, **kwargs)[source]¶
Bases:
QSOption
Header schema for IPV4 quick start report of approved rate options.
- nonce: QSNonce = <BitField nonce>¶
QS nonce.
Type Stubs¶
- class pcapkit.protocols.schema.internet.ipv4.VerIHLField[source]¶
Bases:
TypedDict
Version and header length field.
- class pcapkit.protocols.schema.internet.ipv4.ToSField¶
Bases:
TypedDict
Type of service field.
- class pcapkit.protocols.schema.internet.ipv4.Flags[source]¶
Bases:
TypedDict
Flags and fragment offset field.
- class pcapkit.protocols.schema.internet.ipv4.TSFlags[source]¶
Bases:
TypedDict
Timestamp flags field.
- class pcapkit.protocols.schema.internet.ipv4.QuickStartFlags[source]¶
Bases:
TypedDict
Quick-Start flags.
Auxiliary Functions¶
- pcapkit.protocols.schema.internet.ipv4.quick_start_data_selector(pkt)[source]¶
Selector function for
_QSOption.data
field.- Parameters:
- Return type:
- Returns:
If
func
is0
, returns aSchemaField
wrappedQuickStartRequestOption
instance.If
func
is8
, returns aSchemaField
wrappedQuickStartReportOption
instance.
Data Models¶
- class pcapkit.protocols.data.internet.ipv4.IPv4(*args: VT, **kwargs: VT)[source]¶
Bases:
Protocol
Data model for IPv4 packet.
- version: Literal[4]¶
Version.
- hdr_len: int¶
Internet header length.
- tos: ToSField¶
Type of services.
- len: int¶
Total length.
- id: int¶
Identification.
- flags: Flags¶
Flags.
- offset: int¶
Fragment offset.
- ttl: timedelta¶
Time to live.
- protocol: TransType¶
Protocol.
- checksum: bytes¶
Header checksum.
- src: IPv4Address¶
Source address.
- dst: IPv4Address¶
Destination address.
- class pcapkit.protocols.data.internet.ipv4.ToSField(*args: Any, **kwargs: Any)[source]¶
Bases:
Data
Data model for IPv4 ToS fields.
Important
Due to the preserved keyword conflict, please use
from_dict()
to create an instance of this data model.- pre: ToSPrecedence¶
Precedence.
- thr: ToSThroughput¶
Throughput.
- rel: ToSReliability¶
Reliability.
- ecn: ToSECN¶
Explicit congestion notification (ECN).
- class pcapkit.protocols.data.internet.ipv4.Flags(*args: VT, **kwargs: VT)[source]¶
Bases:
Data
Data model for IPv4 Flags.
- df: bool¶
Don’t fragment.
- mf: bool¶
More fragments.
- class pcapkit.protocols.data.internet.ipv4.Option(dict_=None, **kwargs)[source]¶
Bases:
Data
Data model for IPv4 options.
- code: OptionNumber¶
Option code.
- length: int¶
Option length.
- type: OptionType¶
Option type.
- class pcapkit.protocols.data.internet.ipv4.OptionType(*args: Any, **kwargs: Any)[source]¶
Bases:
Data
Data model for IPv4 option type data.
- class: OptionClass¶
Option class.
- change: bool¶
Change flag.
- number: int¶
Number.
- class pcapkit.protocols.data.internet.ipv4.UnassignedOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 unassigned option.
- data: bytes¶
Option data.
- class pcapkit.protocols.data.internet.ipv4.EOOLOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 End of Option List (
EOOL
) option.
- class pcapkit.protocols.data.internet.ipv4.NOPOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 No Operation (
NOP
) option.
- class pcapkit.protocols.data.internet.ipv4.SECOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Security (
SEC
) option.- level: ClassificationLevel¶
Classification level.
- flags: tuple[ProtectionAuthority, ...]¶
Protection authority flags.
- class pcapkit.protocols.data.internet.ipv4.LSROption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Loose Source Route (
LSR
) option.- pointer: int¶
Pointer.
- route: tuple[IPv4Address, ...]¶
Route.
- class pcapkit.protocols.data.internet.ipv4.TSOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Time Stamp (
TS
) option.- pointer: int¶
Pointer.
- overflow: int¶
Overflow.
- flag: TSFlag¶
Flag.
- timestamp: tuple[timedelta | int, ...] | OrderedMultiDict[IPv4Address, timedelta | int]¶
Timestamp data.
- class pcapkit.protocols.data.internet.ipv4.ESECOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Extended Security (
ESEC
) option.- format: int¶
Additional security information format code.
- info: bytes¶
Additional security information.
- class pcapkit.protocols.data.internet.ipv4.RROption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Record Route (
RR
) option.- pointer: int¶
Pointer.
- route: Optional[tuple[IPv4Address, ...]]¶
Route.
- class pcapkit.protocols.data.internet.ipv4.SIDOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Stream ID (
SID
) option.- sid: int¶
Stream ID.
- class pcapkit.protocols.data.internet.ipv4.SSROption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Strict Source Route (
SSR
) option.- pointer: int¶
Pointer.
- route: Optional[tuple[IPv4Address, ...]]¶
Route.
- class pcapkit.protocols.data.internet.ipv4.MTUPOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 MTU Probe (
MTUP
) option.- mtu: int¶
MTU.
- class pcapkit.protocols.data.internet.ipv4.MTUROption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 MTU Reply (
MTUR
) option.- mtu: int¶
MTU.
- class pcapkit.protocols.data.internet.ipv4.TROption(*args: Any, **kwargs: Any)[source]¶
Bases:
Option
Data model for IPv4 Traceroute (
TR
) option.Important
Due to the preserved keyword conflict, please use
from_dict()
to create an instance of this data model.- id: int¶
ID number.
- outbound: int¶
Outbound hop count.
- class pcapkit.protocols.data.internet.ipv4.RTRALTOption(*args: VT, **kwargs: VT)[source]¶
Bases:
Option
Data model for IPv4 Router Alert (
RTRALT
) option.- alert: RouterAlert¶
Router alert.
- class pcapkit.protocols.data.internet.ipv4.QSOption(dict_=None, **kwargs)[source]¶
Bases:
Option
Data model for IPv4 Quick Start (
QS
) option.- func: QSFunction¶
QS function.
- rate: int¶
Rate request/report.
Footnotes