---
name: "packet.internet.ipv4"
section: "3"
platform: "linux"
package: "nfstest"
version: "3.2-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/packet.internet.ipv4"
---

# packet.internet.ipv4(3)

IPv4 module

## NAME

packet.internet.ipv4 - IPv4 module

## DESCRIPTION

Decode IP version 4 layer.

## CLASSES

### class Flags(baseobj.BaseObj)

```
Flags object
```

**Methods defined here:** ---------------------

**\_\_init\_\_(self, data)** Constructor which takes a single byte as input

### class IPv4(baseobj.BaseObj)

```
IPv4 object
Usage:
    from packet.internet.ipv4 import IPv4
    x = IPv4(pktt)
Object definition:
IPv4(
    version         = int,
    IHL             = int, # Internet Header Length (in 32bit words)
    header_size     = int, # IHL in actual bytes
    DSCP            = int, # Differentiated Services Code Point
    ECN             = int, # Explicit Congestion Notification
    total_size      = int, # Total length
    id              = int, # Identification
    flags = Flags(         # Flags:
        DF = int,          #   Don't Fragment
        MF = int,          #   More Fragments
    )
    fragment_offset = int, # Fragment offset (in 8-byte blocks)
    TTL             = int, # Time to Live
    protocol        = int, # Protocol of next layer (RFC790)
    checksum        = int, # Header checksum
    src             = "%d.%d.%d.%d", # source IP address
    dst             = "%d.%d.%d.%d", # destination IP address
    options = string, # IP options if available
    psize = int       # Payload data size
    data = string,    # Raw data of payload if protocol
                      # is not supported
)
```

**Methods defined here:** ---------------------

**\_\_init\_\_(self, pktt)** Constructor

Initialize object's private data.

- **pktt:**

  Packet trace object (packet.pktt.Pktt) so this layer has access to the parent layers.

**\_\_str\_\_(self)** String representation of object

The representation depends on the verbose level set by debug\_repr(). If set to 0 the generic object representation is returned. If set to 1 the representation of the object is condensed:\
     '192.168.0.20 -\> 192.168.0.61 '

If set to 2 the representation of the object also includes the protocol and length of payload:\
     '192.168.0.20 -\> 192.168.0.61, protocol: 17(UDP), len: 84'

## SEE ALSO

**[baseobj(3)](/baseobj/3.md),** **[packet.transport.tcp(3)](/packet.transport.tcp/3.md),** **[packet.transport.udp(3)](/packet.transport.udp/3.md),** **[packet.utils(3)](/packet.utils/3.md)**

## BUGS

No known bugs.

## AUTHOR

Jorge Mora (mora@netapp.com)
