One component, two files, and nothing that checks they agree
Naming a network component consistently in a troubleshooting CLI took two hand-maintained lists, a TODO that is still in the tree, and no validation that either matches reality.
The CLI in question fetches logs and pulls captures for a mobile core. Both halves need the
same answer to one question: what is this component called. The answer lives in two separate files — nat_table.lua for
captures, sources.go for logs — and the tool works only while they agree.
Why a NAT table exists at all
internal/common/nat_table.lua maps an address to a logical name, and most components appear
in it twice:
local nat_table = {
["<public addr>"] = "site-b-partner-b-proxy-1",
["<private addr>"] = "site-b-partner-b-proxy-1",
...
}
The comment at the top says why, and it is the whole justification for the file: there is NAT between the GTP proxies and the packet gateways, so the same party appears in a capture under different addresses depending on which side of the translation the capture was taken. Read a pcap from the gateway and a peer is one address; read the same conversation from the proxy and it is another. The table collapses both onto one name (two keys, one value), so the tool's output reads the same either way.
The fifth line of the file is a TODO — -- TODO Automate generation of this file. It has been there
since the file was written, and the entries are still added by hand.
The log side
internal/logfetch/sources.go is 120 lines and does the same job for logs, in a different
shape (constants, not a map). A constant per host (five in one site, three in another, one in a third), then one
entry per component naming a host and a container, then an alias map so the names people
actually type resolve to the right source:
var Aliases = SourceAliasMap{
"epc": HSS,
"hss": HSS,
"pgw13": PGW13,
"pgw-ota": PGW13,
}
Three of those four aliases exist because the same box is called three things (by three
teams).
pgw-ota and pgw13 are one gateway; epc and hss are one log stream. Adding the alias
was cheaper than correcting everyone.
The failure mode
Nothing checks that the two files agree (no test, no lint, no shared source), and a component
added to one and missed in the other does not fail — it half-works. Logs fetch fine and the capture shows a bare address, or the
capture reads correctly and logfetch <name> reports no such source. Neither looks like a
bug at the moment it bites; it looks like the component is fine.
The releases are mostly this, one partner at a time. December 2024 added four local-breakout proxies to both files in a single commit (CW-1702, the right way to do it). Version 5.1.0 (19 March 2025) was the consolidation — "all the current components added to sources", and the NAT table given "entries of all the components we have as on date", which is an admission that until then it did not. Then 5.1.2 expanded one partner's components in a European region, and 5.2.1 added more local-breakout components plus one in Asia-Pacific.
Following one subscriber through four protocols
The other half of the same release train is misc/filter-pcap.sh (CW-2171, 145 lines,
version 5.1.1), which answers a narrower question: show me everything for this IMSI. The difficulty is that the
IMSI is not in most of the frames. It appears in the message that establishes a transaction,
and the rest of that transaction is identified by something else entirely.
So the script makes one tshark pass over the merged capture, filtered on e212.imsi, and
pulls five correlation fields out of the frames that do carry it:
tshark -r "$TMP_MERGED" -Y "e212.imsi == \"$IMSI\"" \
-T fields -e diameter.hopbyhopid -e tcap.otid -e tcap.dtid \
-e gtpv2.seq -e gtp.seq_number -E separator='|'
Those values then become a Wireshark display filter (one || chain), which matches the frames
the IMSI filter missed. One wrinkle is worth the line it takes: tcap.otid prints bare hex
while tcap.tid compares colon-separated bytes, so format_tcap_id reinserts a colon every
two digits (sed 's/../&:/g; s/:$//'). Without that one substitution the TCAP half of the
filter matches nothing at all, silently.