Matthew Gamble's Blog
← Back to reflections
Building a Better Mousetrap with Claude

ai

Building a Better Mousetrap with Claude

M
Matthew Gamble
10 min read
"I've been reading VoIP traces for more than 25 years."

I've been reading VoIP traces for more than 25 years. I can grok MGCP, SIP, SCCP and a few other protocols best left in the past about as naturally as a newspaper, which is either a marketable skill or a cry for help depending on who you ask. When I started working with Ribbon gear, I was one of the few people I knew who deliberately avoided Ribbon's official log analysis tool, because I run on a Mac and it doesn't. Instead I'd open the raw diagnostic export in a text editor and follow the SIP by hand. On a quiet box with a handful of calls, that's perfectly workable. On a busy SBC it's a special kind of torture, because the messages for the call you care about are buried between dozens belonging to everyone else, and you spend more time skipping over other people's calls than reading your own.

For those not familiar with the official route, you pull a diagnostic export from the SBC's WebUI and feed it to LX, which turns thousands of interleaved log lines into a call ladder a human can follow. LX is a .NET WinForms desktop application. It won't run until you've installed the SQL Server CE runtime, which the included installer link doesn't work for anymore. If you're on a Mac, the official path is to spin up a Windows VM, install a database engine Microsoft stopped caring about years ago, and only then start troubleshooting. My path was the text editor and a lot of scrolling.

After enough years of that, I built a replacement. LadderLens is a browser-based SIP call flow visualizer for diagnostic logs from Ribbon SBC SWe 11 and later. Drop a log file on the page and you get an interactive SVG ladder diagram of the ingress and egress legs of every call in it. There's no server and no upload. Your logs never leave your machine, which matters when those logs are full of customer phone numbers. The whole thing is open source under the MIT licence, and the production bundle is about 55 KB of JavaScript.

Why not just read the raw logs?

I did, for years, so I can tell you exactly why. A single SIP message in a Ribbon diagnostic log doesn't sit neatly on one line. It's embedded in log context, wrapped in session state machine output and transport layer chatter, and often duplicated by SMM (Session Message Manipulation) copies of the same message. On the SBC SWe, a single SIP message can be chunked across two or three separate log entries using multipart MSGIDs, so you're reassembling it in your head before you can even read the headers. Every other active session on the box is interleaved through all of it. Following one call means holding CIDs, Call-IDs and session types in working memory while scrolling past thousands of lines that have nothing to do with you.

Then there's the scale problem. I've seen a single call pull in more than 600 log messages, because the SBC reuses CID slots and a naive grouping drags in OPTIONS keepalive sessions from hours earlier. Nobody should be reading that by hand at 2am during an outage, no matter how many years of traces they have behind them.

The hardest problem wasn't SIP

Parsing SIP is a solved problem. Understanding when a Ribbon SBC decides what a call is turned out to be the real fight.

The SBC identifies calls internally using a "CID", and it ties both legs of a call together with it. You'd expect every message in a call to carry that call's CID. They don't. The SBC assigns the CID after it finishes processing the initial INVITE, so the INVITE itself and the 100 Trying that follows it get logged with the stale CID from whatever session last used that slot. As far as I can tell this behaviour isn't documented anywhere, and it took several long debugging sessions against real logs to figure out why the first messages of every call kept vanishing into unrelated groups.

LadderLens fixes this with a four-phase correlator. The first pass builds a map of SIP Call-ID to CID from every message that carries both. The second pass uses that map to assign CIDs to orphaned messages. After grouping everything by CID, a final pass rescues INVITE-related messages that landed in the wrong group by tracking the SIP Call-ID dialog across CID boundaries. The B2BUA nature of the SBC adds its own wrinkle, since the ingress and egress legs have completely different SIP Call-IDs. LadderLens links them through the shared CID and the session type (InviteServer for ingress, InviteClient for egress), with each leg tracking its own dialog independently.

CID reuse was the next problem to fall. A CID used for a real call at 8pm may have been used for an OPTIONS keepalive at 2pm, and grouping on CID alone pulls in hundreds of irrelevant messages spanning hours. The fix was to filter what gets displayed down to each leg's own SIP Call-ID dialog, and to calculate call timing from those leg messages only. That got rid of the contamination without throwing away anything that belonged to the call.

Message ordering had its own surprise waiting. The SBC will sometimes log the 100 Trying it generated before the INVITE that caused it. A simple timestamp sort gets that wrong, and a naive fix (always put requests first) gets it wrong in a nastier way, with a BYE sorting itself ahead of provisional responses from an earlier transaction. LadderLens uses CSeq-aware tiebreaking so a request sorts ahead of its own 1xx responses and leaves other transactions alone.

The bug that was hiding everything

My favourite discovery was also the dumbest. Ribbon right-justifies sequence numbers in its log lines, so the whitespace after the timestamp bracket varies depending on how many digits the sequence number has. My original regex assumed a single space. For a while, thousands of log lines were being silently dropped, which meant missing session contexts, which meant broken correlation, which meant I spent a good chunk of time debugging correlator logic that was working fine on the data it actually received. One \s+ later, half my "correlation bugs" disappeared. You'd think 25 years of staring at log files would have taught me not to trust their formatting, and you'd be wrong.

Where Claude came in

I built LadderLens with Claude Code, and the way the work went is the reason this post has the title it does. Two decades of reading traces meant the SIP itself was never going to be the bottleneck. I know what a healthy call looks like and I can spot a broken one at a glance. What slowed things down was the undocumented stuff, where the only source of truth is a real log file from a real SBC and a lot of patience. Working against diagnostic exports from a lab Ribbon SBC, the loop was simple: run the parser, find the place where reality disagreed with our assumptions, and work out why. I brought the instinct for what looked wrong in a ladder, and Claude brought a tireless willingness to dig through hundreds of lines of interleaved session output looking for the one message that didn't belong. That's the same job I used to do with a text editor, at a pace I never could.

The result is roughly 4,000 lines of TypeScript across 31 source files, with about 950 lines of tests backing it up. There are no frameworks and no runtime dependencies. Parsing runs in a Web Worker with streaming progress, so the UI stays responsive on log files north of 200 MB. The 85 automated tests cover the parser, the correlator, the findings engine and the exporters, which means the next weird log format I hit won't quietly break the last one I fixed.

Nothing to install

I'll admit to being a little giddy about this part. When I started in VoIP, a tool like this would have meant a native application per platform, an installer, probably a licence key, and a support matrix nobody wanted to maintain. Today a browser will happily stream-parse a 200 MB file in a background thread, render a few thousand SVG elements, and export a PNG, all without a single byte touching a server. You open a URL and it just works, on a Mac, a Linux laptop, a Windows box or (if you're truly desperate) a phone. Watching that happen still feels a bit like magic. The younger me, back when we were pioneering this stuff and decoding calls by squinting at raw packet captures, would have killed for it.

What it does that LX doesn't

Replacing the ladder diagram was the goal, since that's the main reason anyone still opens LX. Once the correlation was solid, a few extras were cheap to add. The findings engine flags error responses, timeouts, retransmissions, codec mismatches and number rewrites automatically, so the problem in a failed call often shows up before you've clicked a single arrow. And yes, for a tool built with Claude, there isn't a shred of AI in it. The findings engine runs on good old-fashioned deterministic rules, which in 2026 makes it practically artisanal software, and it gives the same answer every time you ask. Remote peers get identified by IP range (Microsoft Teams Direct Routing ranges are built in) with a fallback to User-Agent and Server headers from received messages, skipping the useless generic "SIP/2.0" Server headers some carriers stamp on their 100 Trying. Every diagram exports as SVG, PNG, a standalone HTML report, JSON or Markdown, and there's built-in PII redaction so you can send a trace to a vendor without handing over your customers' phone numbers.

LXLadderLens
Platform.NET/WinForms desktop app (no Mac)Any modern browser
InstallationDownload plus SQL Server CE runtimeOpen a URL
Log processingLocalLocal
Ladder diagramGDI+ renderedInteractive SVG, click to inspect
Automated findingsNoErrors, timeouts, retransmissions, codec mismatches
Built-in redactionNoYes
SourceClosed, obfuscatedOpen (MIT)

If you work with Ribbon SBCs, give LadderLens a try on your next trace. It handles logs from SWe 11 onward (maybe older, I don't have a way to test), and I fully expect someone's production SBC to produce a log line I've never seen. When that happens, open an issue on GitHub (with the redaction turned on, please) and I'll take a look. Pull requests are even better.

Ribbon, if you're reading, documenting when and how CIDs get assigned would save everyone a lot of grief. An open spec for the diagnostic log format would be better still. Until then, I've retired my text editor from SIP duty, and the tool that replaced it weighs less than the average hero image on your corporate website.

Comments (0)

Sign in to join the discussion

Loading comments...