IMEI
An IMEI identifies a mobile phone or a modem. It has 15 digits, and the last is a Luhn check digit.
What an IMEI is
Eight digits of Type Allocation Code, which names the model, six digits of serial number and one check digit. The GSM Association gives out the type allocation codes.
The check digit
Start with the digit just left of the check digit and double every second digit going left. Add up the digits of the doubled numbers and the digits that were not doubled. Subtract the total from the next number ending in 0. The difference is the check digit, and a total that already ends in 0 gives 0.
The standard works one through, 26053179311383. The doubled digits give 12, 10, 2, 18, 2, 6 and 6, everything adds up to 53, and 60 - 53 is 7, so the IMEI is 260531793113837.
Valid IMEIs for your tests
$ qadg quick imei --count 5 --seed example 003596798143420 003100690346247 006376566897227 001599923796411 008221722669557
Every IMEI starts with 00, the block the GSM Association gives to test equipment, which may not be sold. So no phone on sale carries one. Codes inside the block are still given to manufacturers, so a value can match a test device somewhere.
What your application should do with a broken one
Refuse an IMEI whose check digit does not match. A changed digit always shows. Of all the swaps of two neighbouring digits, only 0 next to 9 leaves the check digit right, and the program does not count that swap as damage.
Broken ones for your tests
The recipe below makes 100 values and asks for damage in 20% of the rows. Download it and run it as it is, then change the count or the share to fit your tests.
The recipe
# IMEIs for testing, with one broken value asked for in about a fifth of the
# rows.
#
# Every IMEI starts with 00, the block for test equipment, which may not be
# sold. The damage changes a digit or swaps two, and the manifest says your
# application should reject each one. It also lists the damage this build could
# not carry out, with the reason.
#
# qadg generate imei.yaml
#
# writes device.csv, expectation-manifest.json and run-note.json. The same seed
# breaks the same values on every machine.
version: "0.1"
seed: "imei"
locale: en-US
entities:
device:
count: 100
fields:
imei: { generator: imei }
policy:
layers: [L3]
rows: 20%
per_row: exactly_one
output:
format: csv
Run it
Save the recipe, then run this in the same folder. This is what the program printed for it.
$ qadg generate imei.yaml device: 100 rows, 1 column 1 table, 100 rows written 22 defects ordered, 6 applied, manifest in expectation-manifest.json 16 defects could not be applied, and the manifest carries the reason for each one 3 because this run lacks something they need, and the manifest says what for each one 13 because this build has no implementation of them yet
What it damaged
The recipe ordered 22 defects, and this build applied the 6 below. The other 16 are in the manifest as not applied, each with its reason, and the run above counts them by reason.
L3.checksum.off_by_onerejectdevice 18, column imei
009187361482736 → 009187361482737
L3.checksum.transposed_digitsrejectdevice 30, column imei
003832726957429 → 003837226957429
L3.checksum.off_by_onerejectdevice 50, column imei
002939782452038 → 002939782452039
L3.checksum.transposed_digitsrejectdevice 52, column imei
006447547935566 → 004647547935566
L3.checksum.off_by_onerejectdevice 84, column imei
003940455233522 → 003940455233523
L3.checksum.transposed_digitsrejectdevice 87, column imei
002445573704702 → 002445577304702
Sources
- ETSI TS 123 003 version 19.7.0, the published text of 3GPP TS 23.003: clause 6.2.1 and annex B.
- GSMA TS.06, IMEI Allocation and Approval Process, version 28.1: table 1 and clause 9.1.