Browse docson_network_send
On this page
Lifecycle event

on_network_send

Runs for each captured packet leaving this PC, and for forwarded packets leaving through the selected interface (the interface that carries the default route when capturing all interfaces), while network capture is active.

Syntax

Atlas Script
event on_network_send() { }

Return value

See the remarks for the returned value and runtime behavior.

Remarks

Runs for each captured packet leaving this PC, and for forwarded packets leaving through the selected interface (the interface that carries the default route when capturing all interfaces), while network capture is active. Use packet.* to inspect or edit it, and packet.drop() to block it.

Examples

Log outgoing packets to one port.atlas
var logged = 0;

event on_start() {
    if (!network.capture("udp and udp.DstPort == 9000")) {
        system.log("Network capture could not start");
    }
}

event on_network_send() {
    if (logged < 20) {
        logged += 1;
        system.log(string.format("{}:{} -> {}:{}, {} payload bytes",
            packet.src_ip, packet.src_port, packet.dst_ip, packet.dst_port, packet.payload_length));
    }
}

event on_stop() {
    system.log(string.format("Sent {} matching packets", network.sent));
}
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.