Browse docspacket.byte
On this page
API method

packet.byte

Reads one payload byte (0-255) at a payload-relative offset, or null when the offset is past the end of the packet.

Syntax

Atlas Script
packet.byte(offset)

Parameters

offset
Byte offset into the packet. Payload-relative for packet.* methods, and absolute (whole IP packet) for the raw_* variants.

Return value

See the remarks for the returned value and runtime behavior.

Remarks

Reads one payload byte (0-255) at a payload-relative offset, or null when the offset is past the end of the packet.

Examples

Edit one byte in matching packets.atlas
event on_start() {
    if (!network.capture("udp and udp.DstPort == 9000")) {
        system.log("Network capture could not start");
    }
}

event on_network_send() {
    // In this example protocol, payload byte 0 is a message type.
    if (packet.payload_length >= 2 && packet.byte(0) == 0x01) {
        packet.set_byte(1, 0x7F);
    }
}
Reference details are generated from the Atlas Script schema in this documentation source snapshot. Confirm release-specific behavior in the Atlas for Windows build you use.