When the database is wrong, the network still remembers
After a serious outage, packet captures can be the last reliable record of what happened. How to rebuild lost messaging records from PCAP files without making things worse.
Outages don't only stop traffic. Sometimes they leave gaps in the records you bill and report from. If the network traffic was being captured, those PCAP files may be the most complete record left.
Parse the protocols, not just the packets
Python is a good fit for this work. Scapy gives low-level control over packets. PyShark wraps Wireshark's tshark, so you get Wireshark's protocol dissectors, including SMPP and SIP, without writing your own parsers.
Correlate requests and responses
A single packet rarely tells the whole story:
- In SMPP, a
submit_smrequest and itssubmit_sm_respshare asequence_numberwithin a session. Together they tell you what was sent and whether it was accepted. - In SIP, a
MESSAGErequest and its response share aCall-IDandCSeq.
Match them up before reconstructing anything. A request without a response is a different record from one that was accepted.
Assign every record to its owner
In a multitenant system, a rebuilt record is useless until you know which account and tenant it belongs to. Map connection details such as the bound system ID, source address or IP back to the account configuration.
Never write straight into production
This is the most important rule. Recovered data is a reconstruction, not the truth:
- Stage every rebuilt record in a separate table or database.
- Validate against what you still trust: remove duplicates of records that already exist, check counts against traffic graphs, and spot-check a sample by hand.
- Review the totals with the people who own billing or reporting.
- Import in controlled batches that can be identified and rolled back.
An API in front of the process, for example with FastAPI, makes each step visible and repeatable instead of a pile of one-off scripts.
Prepare before you need it
The time to check your capture setup is now: which links are captured, how long files are kept, and whether they include the protocols you'd need. Recovery is only possible if the data was recorded in the first place.
Dealing with this in your own system? We do this work for a living. The first call is free.
Book a call