Documentation
¶
Overview ¶
Package imsi decodes an International Mobile Subscriber Identity — the up-to-15-digit identifier stored on a SIM/USIM that uniquely names a cellular subscriber, disclosed in plaintext in a GSM/LTE Identity Response (the message an IMSI-catcher / cell-site simulator forces a handset to send). It is the cellular-subscriber companion to internal/imei (the device identity) — the two together are what an IMSI-catcher harvests — and complements the gsmtap / gtp / diameter cellular decoders.
Wrap-vs-native judgement ¶
Native. The IMSI structure (MCC + MNC + MSIN, per 3GPP TS 23.003 / ITU-T E.212) is a fixed digit-field split, and the MCC→country assignment is public ITU-T E.212 data. Decoding is a table lookup plus a substring split — a runtime dependency on a cellular library is not justified. stdlib only, no new go.mod dep. The MCC→country table and per-MCC MNC length (mcc_table.go) are code-generated from python-stdnum's imsi.dat (an authoritative, machine-readable source) rather than hand-transcribed.
Verifiable / no confidently-wrong output ¶
The MCC (always the first three digits) → country mapping is authoritative and unambiguous. The MNC/MSIN split was verified against the python-stdnum reference library across all 2543 real assigned MNCs of the 215 countries that use a single MNC length — zero mismatches. The 22 countries that assign BOTH 2- and 3-digit MNCs (e.g. USA 310, India 405) cannot be split unambiguously without an operator database; for those the decoder uses the predominant length and FLAGS the result rather than asserting it. IMSI carries no check digit, so validity is structural (length + a known MCC). The operator (MNC→carrier name) lookup is deliberately deferred: that data is large, proprietary and churns constantly (carriers rename / merge), so asserting it would risk confidently-wrong output — the numeric MNC is surfaced instead.
Code generated from python-stdnum's imsi.dat (sourced from the ITU-T E.212 MCC assignments and the Wikipedia MCC/MNC list). DO NOT EDIT BY HAND.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
IMSI string `json:"imsi"`
MCC string `json:"mcc"`
Country string `json:"country,omitempty"`
MNC string `json:"mnc"`
MSIN string `json:"msin"`
// MNCLengthAssumed is true when the MNC length was not
// authoritatively known (an unknown MCC, or a country that uses
// both 2- and 3-digit MNCs) and the split may be wrong.
MNCLengthAssumed bool `json:"mnc_length_assumed"`
Notes []string `json:"notes,omitempty"`
}
Result is the decoded view of an IMSI.