lmnet authoring skill

lmnet is a statically-linked Linux network diagnostics CLI and LMScript host that unifies iputils ping and tracepath, iperf3, rtnetlink routing and link inspection, procfs socket and SNMP counter dumps, RFC 1035 DNS queries, UDP/ICMP traceroute, parallel TCP port scanning, and raw TCP socket scripting.

Purpose

Use lmnet to inspect Linux network interfaces, 64-bit RX/TX link counters, routing tables, policy rules, ARP/NDP neighbor caches, active TCP/UDP/Unix sockets with PID attribution, kernel protocol counters, DNS records, and open TCP ports from either JSON-emitting CLI commands or compiled _lmcode_ scripts.

When to use it

Choose lmnet on Linux x86_64 or arm64 when a workflow needs host-level network topology, rtnetlink state, socket process attribution, iperf3 throughput testing, TCP port reachability checks, or raw TCP byte exchanges. Use lmcurl for HTTP, HTTPS, and LDAPv3 application requests, lmssl for TLS certificate and cipher inspection, lmproxy for HTTP/HTTPS proxy interception, or lmshark for deep packet capture.

Install

Install the lmctl toolchain with npm install -g @lmctl-ai/lmctl@latest. When an LMScript program declares cli="lmnet" and install="github:lmctl-ai/lmnet@latest", the runtime resolves the statically-linked Linux x86_64 or arm64 executable. Because lmnet directly queries Linux rtnetlink, /proc/net, and iputils internals, it is supported on Linux only.

lmscript --version
lmnet --version
lmnet --lmcode-schema
lmnet --lmcode-signatures

Commands

lmnet supports host introspection and bytecode execution flags, embedded iputils and iperf3 engines, and structured JSON diagnostic subcommands.

# Host schema, signatures, and bytecode execution
lmnet --lmcode-schema
lmnet --lmcode-schema --json
lmnet --lmcode-signatures
lmnet --lmcode build/program.dslb
lmnet --dry-run --lmcode build/program.dslb

# Embedded upstream engines
lmnet ping -c 3 127.0.0.1
lmnet tracepath 127.0.0.1
lmnet iperf3 -s -1 -p 15201
lmnet iperf3 -c 127.0.0.1 -p 15201 -t 1

# DNS and RFC 1035 UDP dig queries (JSON output)
lmnet dns localhost
lmnet dig example.com A @1.1.1.1

# Linux libc and rtnetlink topology dumps (JSON output)
lmnet ifaddrs
lmnet link
lmnet route
lmnet rule
lmnet neigh

# Kernel /proc/net counters and socket tables (JSON output)
lmnet counters
lmnet sockets
lmnet sockets tcp --listen
lmnet sockets --summary

# Traceroute, TCP connect port scanner, and TCP stdio bridge
lmnet trace 1.1.1.1 16
lmnet scan 127.0.0.1 --ports 22,80,443,8000-8010 --timeout 500 --concurrency 32
lmnet pipe 127.0.0.1 8080
lmnet pipe --listen 18080

Inputs and outputs

In CLI mode, ping, tracepath, and iperf3 preserve their upstream text and flag formats, pipe streams raw binary bytes between stdin/stdout and a TCP socket, and dns, dig, ifaddrs, link, route, rule, neigh, counters, sockets, trace, and scan emit single-document JSON arrays or objects on stdout. In _lmcode_ mode, lmnet exposes context net: Net and println(string) (which writes diagnostics to stderr) alongside the 226 standard lmcode_std_v3 signatures, emitting a single terminal SDK invocation JSON frame on stdout.

Safety rules

Observe platform, privilege, and timeout boundaries when authoring lmnet commands and scripts:

Worked examples

The first example inspects loopback interfaces, rtnetlink link statistics, routing tables, socket summaries, and an ephemeral loopback TCP echo listener in LMScript:

p = _lmcode_ cli="lmnet" install="github:lmctl-ai/lmnet@latest";
let links = net.links();
let found_lo = false;
for (i in range(0, links.len())) {
  let l = links.at(i);
  if (l.name() == "lo" && l.loopback() && l.up()) {
    found_lo = true;
  }
}
assert_eq(found_lo, true);

let sum = net.socket_summary("tcp");
assert(sum.total() >= 0);

let srv = net.tcp_listen(29182);
assert_eq(net.check("127.0.0.1", 29182), true);
let peer = srv.accept();
peer.close();
lmcode_return_put("links", links.len());
end _lmcode_
res = run_lmcode(p);
require(res.ok, json_stringify(res));

The second example exposes Linux DNS and link diagnostics through the standard lmcode_std_v3 REST and stateless CLI interfaces:

p = _lmcode_ cli="lmnet" install="github:lmctl-ai/lmnet@latest";
@"--dev"
fn opt_dev(x: RestExchange) -> void implements CliOption {
  x.set("dev", x.query("dev"));
}

@"link-state"
fn cmd_link_state(x: RestExchange) -> void implements CliCommand {
  let target = x.get("dev");
  let links = net.links();
  let out = "missing";
  for (i in range(0, links.len())) {
    let l = links.at(i);
    if (l.name() == target) {
      out = l.name() + ":" + str(l.loopback()) + ":" + str(l.up());
    }
  }
  x.send(out);
}

@"/dns/:host"
fn get_dns(x: RestExchange) -> void implements RestGet {
  let addrs = net.dns_lookup(x.param("host"));
  x.json("{\"count\":" + str(addrs.len()) + "}");
}

rest_config("session", "global");
assert_eq(rest_cli(str_split("--dev=lo link-state", " ")), "lo:true:true");
assert_eq(rest_cli(str_split("/dns/localhost", " ")), "{\"count\":1}");
end _lmcode_

Errors and exit codes

lmnet uses consistent exit codes across CLI subcommands and _lmcode_ bytecode execution:

How to verify

Verify the installed lmnet binary by checking its version, embedded schema JSON, canonical signatures, and structured JSON output from loopback introspection commands:

lmnet --version
lmnet --lmcode-schema --json > /tmp/lmnet-schema.json
lmnet --lmcode-signatures > /tmp/lmnet-sigs.txt
lmnet link
lmnet sockets --summary

In a source checkout, run ./test.sh to verify static linkage (not a dynamic executable under ldd), signature parity with the 226-signature lmcode_std_v3 catalog, and all CLI and LMScript integration tests.