Private LTE with LimeSDR and srsRAN – Part 3 (SIM Cards)

|

Introduction

If you managed to land here without seeing part one and part two in my series on setting up my own private LTE network, you may want to check those out first.

Continuing from where we left off, having setup our hardware in a manor that hopefully wont injure any of the devices involved. The next step involves procuring and programming some SIM cards for our mobile devices.

This post therefore covers the few SIM card options I considered and how to program the ones I ultimately chose. Along with a whistle-stop tour of some of the plethora of acronyms that can be found in the mobile network standards. This may may be useful if programming a different type of SIM to the one I selected.

SIM Card Programming

In order for our private network to function we need some SIM cards for which we know the security keys.

The easiest way to acquire some SIMS with known security keys is to purchase some blank programmable ones and set the required details ourselves.

There are a number of suppliers providing blank cards for private networks.

My previous employer made use of sysmocom SIM cards, which allow changing of the various security keys and are programmable via open-source projects such as pySim. While I believe them to be an excellent choice I decided they were a little out of my price range, at least until I managed to get things working.

I stumbled across a company called OYEITIMES, who’s products can be easily found on suppliers such as AliExpress (search for OYEITIMES LTE SIM Programmer).

I purchased a package of 5 blank SIM cards, along with a USB Smart Card programmer and the required proprietary software. While I was trying to avoid a proprietary tool I should only need to program the SIM card(s) once, providing I don’t loose the details.

Connecting the provided reader, inserting a SIM and selecting “Read Card” in the provided application yielded the following:

Result of Reading a Fresh SIM Card

The key parameters required by srsRAN are the IMSI, KI and OP/OPC code. Given that these are already set my first thought was I won’t touch the card and just use them as is. This didn’t go quite to plan forcing me to understand a little bit about what I was looking at and generate a realistic configuration.

Opening the application without reading a card leads to a blank slate. From here I hoped to fill in each of the required fields. However it turns out this isn’t a good approach either as the tool seems to need to know the card type to allow some fields to be entered. The type field being populated when a card is read. I therefore ended up updating the result of the first read and saving it, allowing additional cards to be programmed with ease.

The first decision to be made is to select a value for the MCC (mobile country code) and MNC (mobile network code) fields. These parameters act as an identifier for the mobile network and will be provided to srsRAN later when describing the network for it to serve. Additionally they’re going to be programmed into the SIM card, allowing the mobile device to select the network to connect to. The MCC code 999 is reserved for private networks, so we’ll use that. With that MCC code it seems any two or three digit MNC code would be acceptable, although 99 or 999 is recommended. Before I knew this I selected 69 so will be using that here.

The first field to generate a value for in the GUI is the ICCID. The ICCID number should be a unique 19 digit identifier for the SIM card itself and would typically be printed on the card by its manufacturer. Here we can can generate any ICCID we like, but may as well follow the established format which is as follows:

FieldDescriptionExample
Major Industry IdentifierAlways 89 for telecommunication purposes89
Country Code2 or 3 digit country code as defined by by ITU-T recommendation E.164.44
Issuer Identifier1 to 4 digits. Usually the MNC code.69
Individual Account IdentifierVariable account identification number.000000000001
Check DigitCalculated from the other digits using the Luhn algorithm. This appears to be automatically calculated by the SIM programmer for us.4
ICCID Format Details with Example Values

The ICCID selected for my first SIM card is therefore 894469000000000001.

For any subsequent SIMS I’ll simply increment the individual account identifier.

Enter your generated ICCID in the ICCID field under common parameters:

ICCID Entry

Next we need to generate an IMSI (international mobile subscriber identity) number. This 15 digit number is used to uniquely identifier each user of a cellular network. Again this number follows a fixed format:

FieldDescriptionExample
MCCMobile Country Code999
MNCMobile Network Code69
Individual Account IdentifierAccount identifier (usually the same as the one in the ICCID)0000000001
IMSI Format Details with Example Values

The IMSI selected for my first SIM is therefore 999690000000001.

Note that I’ve used the same account identifier as used in the ICCID, but have chopped off the first two digits, reducing it from 12 to 10, such that it fits within the 15 digit limit.

Enter your generated IMSI into the IMSI15 field field under LTE/WCDMA parameters:

IMSI Entry

Next we need to generate the KI field (subscriber key), which is known only by the subscriber and network and used to authenticate the device on the network.

We also need to generate either an OP (operator code) or OPC (operator code derived) field. The operator code is the same for all SIMS from a given provider. If recovered it’s possible that a bad actor may use it to spoof any SIM on the operators network. Therefore the OPC key is usually used. The OPC code is formed via a combination of the operator key and the subscriber key via a one-way cryptographic function. If the OPC code was to be recovered from a SIM card, only that single SIM card may be spoofed.

In the case of our test sims, we will follow the approach of the operators….almost. We can simply generate random 128-bit numbers for both Ki and OPC. As well as being programmed into the SIM these will be provided to srsRAN.

Use any method you like to generate these, I used the following:

xxd -p -l 16 /dev/urandom

Entering my freshly generated values into the KI and OPC code fields as follows:

KI and OPC Entry

Next we’ll take a slight detour and look at the ACC and AD fields. For all the fields that follow I’ve largely been referring to the 3GPP specification concerning USIM cards 3GPP TS 31.102.

The ACC (access control class) field places regular users into a group or access class numbered 0-9. There are also groups numbered 11 to 15 which a user may also be a member of. Access classes are used to manage access to the network. For example during an emergency network registration by classes 0-9 may be disabled, while access by emergency workers who are in class 11 to 15 may continue. This SIM appears to be in access class 2 which is fine for our use.

The AD (administrative data) field contains two fixed pieces of information. The operating mode of the client. That is to say whether they’re a regular subscriber of the network or some sort of type approval / maintenance user. It also contains a field that specifies the length of the MNC (mobile network code). In our case, this needs to be set to two. These fields were already set correctly on my SIM and can be confirmed as follows:

Administrative Data Field Confirmation

Next we can address all the random looking fields with PLMN in their name. PLMN stands for public land mobile network….because too many acronyms is never a bad thing right? A PLMN is defined by a MCC / MNC pair.

Taking each of the fields in turn:

FieldDescription
PLMNwActUser controlled list of preferred PLMNs in priority order, including the access technology 2G/3G/4G/5G etc.
OPLMNwActOperator controlled version of the field above.
HPLMNwActHome PLMN including access technology specifies the network the subscriber’s identity belongs to as a MCC / MNC pair with access technology specified.
EHPLMNEquivalent home PLMN list. PLMNs in this list are treated as equivalent to the home network, in the sense that if selected the device doesn’t consider itself to be roaming. It was suggested online that an example use for this field is where operators merge and therefore each can include the other’s PLMN in the list, although I haven’t managed to locate my source for this.
FPLMNList of forbidden PLMNs which the device shouldn’t attempt to register on automatically. This could be used to list all of the local public mobile networks which should be avoided.

A neat featured in the tool is the ability to auto-complete these fields for us.

If the “…” button is selected for each of the fields aligned with the “Auto” button, followed by “Clear All” in the dialog box the fields can be populated by pressing. the “Auto” button. Causing the tool to extract the PLMN from the IMEI and complete all the fields for us. When there are multiple radio access technologies available I believe it provides an entry for 2G/3G/4G, which will suit just fine.

For example:

Clearing Each PLMN List

Having cleared all the fields and pressed the “Auto” button we end up with something similar to the following:

Automatically Populated PLMN Fields

We could leave the entries in the FPLMN list, but was may as well clear that list as well.

The HPPLMN (higher priority PLMN) field specifies the search period. The interval between searches for a higher priority PLMN than the currently selected one. It doesn’t really apply in this case as no network is going to accept us but our own. I’ve left mine set as is at 50, which according to the 3GPP spec linked above is the maximum value of 240 hours. Although it may be interpreted in different ways depending on the radio technology, so that may not apply universally.

The GID1 and GID2 fields (group identifier) can be used to supply some form of identifier for grouping SIMS….for a particular application according to the spec. We’ll leave these blank as they currently are.

The SMSP (short message service parameters) provides details required for the device to send SMS (text) messages. This field can safely be cleared.

The MSISDN (mobile station international subscriber directory number) field contains the subscriber’s phone number including the country code. While its not required here I found that ModemManager on Linux attempts to read it and complains when it fails. Therefore I’ve opted to make up a number, in my case 447000000000.

The SPN (service provider name) field contains the name of the service provider and some rules on when the name should be displayed, in preference to a name returned by the network. It seems that here the name can be set but not the rules. I’ve entered my network name “TestNET”.

The final field ECC (emergency call codes) lists the information related to emergency services contacts, names and categories. We’ll leave this blank or clear it if it isn’t.

Right now the SIM config should be looking similar to this:

LTE Fields Completed

Having got this far we can simply click the “Same with LTE” button to have the GSM parameters updated to match their LTE counterparts, resulting in the following:

GSM Fields Copied from LTE Fields Completing SIM Preparation

The last thing to do then is to select “Save Data” and save the parameters for the card, allowing it to be reproduced easily in the future, or additional cards with similar parameters to be produced, followed by selecting “Write Card” to actually program our first SIM:

Saving and Writing Completed SIM Card

That felt like it took a very long time….spoilers….it did.

In part four we’ll be looking at configuring srsRAN, including providing it with details of the SIM we just programmed. Before starting the software and therefore launching our network. Finally connecting a mobile device….to the internet if all goes well.

Was this article helpful?
YesNo
, , , ,

19 responses to “Private LTE with LimeSDR and srsRAN – Part 3 (SIM Cards)”

  1.  avatar
    Anonymous

    Hello. Thanks for your good instruction.
    I bought the pack “OYEITIMES Smart Card Reader+5PCS 2FF/3FF/4FF Programmable SIM Card Blank LTE, WCDMA GSM USIM Cards + 3.9.31 Ver. Software” from this link:
    https://www.aliexpress.us/item/3256806030625143.html
    are you khow does it support VoLTE?

    1. Phil Greenland avatar
      Phil Greenland

      Hey,

      I’ve haven’t used VoLTE myself, I didn’t think it was natively supported by srsRAN’s EPC implementation.

      The screenshots on the listing you linked appear to show a VoLTE tab which is missing from the earlier version of the software I was using.
      It’s looking more likely than the setup I have.

      The seller may be able to confirm if the sims and programming software support it?

      Thanks,

      Phil

      1.  avatar
        Anonymous

        Thanks for your reply. I use open5gs core to impliment VoLTE.
        yes, VoLTE tab is in software but it is inactive for me and can not import data on it. I was contacted to OYEI saler but not get any reply.

        1. Phil Greenland avatar
          Phil Greenland

          I see from memory OYEI sell a few variants of their SIMs.

          If you scroll down on their main store front: https://www.aliexpress.com/store/3655099

          The 5G SIM specifically mentions VoLTE/5G.
          The 4G SIM (that I and possibly you have) doesn’t.

          The 4G listing they link: https://www.aliexpress.com/item/32969012061.html
          The 5G listing they link: https://www.aliexpress.com/item/4000299088559.html

          For some reason the 5G cards are significantly more expensive than the 4G.

          Hope that helps.

          Thanks,

          Phil

          1.  avatar
            Anonymous

            Thank you very much for your advice

    2. Fred avatar
      Fred

      I bought the 5G pack. It comes with OYEISIMWrite v4.2.11, which has some additional tabs “VolTE/ISIM”, “Java”, “PKCS#15/AC” . I would believe the VOLTE support is only dependent on your version of OYEISIMWrite, but maybe there is something different in the SIM cards too.

      The card reader is very standard and can be used by the pc/sc stack directly (pcsc_scan for instance).
      I would bet the they follow a standard for programming, so I tried to look for a opensource equivalent for OYEISIMWrite, but it seems it does not exist. Maybe I’m wrong.

      1. Trogper avatar
        Trogper

        I think the VoLTE tab represents configuration options regarding the “ISIM” (IMS Subscriber Identity Module) specification, which is not mandatory for LTE. Therefore if a SIM card is not marked as “VoLTE”, it probably does not include ISIM options/files. That is not to say you can not use VoLTE with the SIM card – phone can also obtain these options for example via software update.

        https://stackoverflow.com/questions/35146047/what-is-the-difference-between-isim-and-usim

  2. Trogper avatar
    Trogper

    I have found out that the software is just rebranded GRSIMWrite, which is freely available from Gialer on their smacarte.com website. They even distribute much newer version – 4.4.6
    https://smacarte.com/wp/grsimwrite_download/

  3. pysim (s)hell avatar
    pysim (s)hell

    If you buy the Sysmocom cards (https://shop.sysmocom.de/sysmoISIM-SJA5-SIM-USIM-ISIM-Card-10-pack-with-ADM-keys/sysmoISIM-SJA5-9FV-10p-adm) then you also need to set the APN on phone manually to “srsapn” (default setting in epc.conf, change as needed, but they need to match to get full internet access) – see https://docs.srsran.com/projects/4g/en/latest/app_notes/source/cots_ue/source/index.html

    GRSIMWrite does not work with Sysmocom cards, if you want to write the APN to SIM (so that it doesn’t need to be set on phone manually), use pySim (it’s PITA to use).

    I think the sequence to program APN/SPN in pySim shell was:

    verify_adm your_ADM1_PIN
    select /ADF.USIM/EF.SPN
    update_binary 0073727361706effffffffffffffffffff

    PLMN field do not seem to be required, I could copy them from the Gialersim card.

  4. Cahit avatar

    Why don’t you try using the new concept of embedded SIM, which is virtual not physical, and doesn’t require you to buy anything extra?
    Apple phones after version 14 are using ESIM.

    1. Phil Greenland avatar
      Phil Greenland

      It would be good to experiment with eSIMs. Generating and loading a profile onto them didn’t appear to be straightforward last time I checked. Like regular sims the management interface was largely manufacturer defined. Using an Android or iPhone with an integrated eSIM would solve the SIM management side of things. Next comes generating a profile for the eSIM. There are a few test profiles available with published keys. but no open source tools for generating custom profiles (Google didn’t turn up anything useful when I checked a moment ago). When using a phone there’s also the issue with connecting it to a simulator when it doesn’t have an antenna connection. To the best of my knowledge (not an RF expert), there’s no unlicensed spectrum available for LTE where I am, so transmitting over the air isn’t an option.

  5. Roy avatar
    Roy

    Hello, thank you for this very detailed guide on the sim card section. it would really help if you could provide me the exact aliexpress link for the sim card reader, there are many versions and i would be afraid that i had purchased the incorrect one with the wrong sim cards, thank you a lot

    1. Phil Greenland avatar
      Phil Greenland

      Hey Roy,

      I tried to avoid posting a link as I expected it would go out of date at some point. To my knowledge the card readers are pretty much standard smart card readers. There’s nothing too special about them. The SIM cards themselves need to align with their programming software, so being provided with both at the same time would be what I’m looking for.

      The product in my AliExpress order links to this product now: https://www.aliexpress.com/item/33042823324.html which would be everything you need, reader + cards + software.

      Hope that helps,

      Phil

  6. Faraz avatar
    Faraz

    First thanks for your good document that share.
    I have installed open5gs, kamailio, srsenb and use OYeiTimes 4G-VoLTE simcard . My simcard well connect to internet. My problem is to enable volte on my phone (samsung F11 and nokia 3.2) to test VoLTE. My phones support Volte but can not enable volte on it for my private network.
    Can anyone help me how can enable my private Volte on these phone?

  7. Casey avatar
    Casey

    Does the type of SIM make a difference? I’m using these,
    https://www.amazon.com/dp/B07F5DVZR2?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1
    but I’m getting an Authentication Failure (MAC failure) which would indicate the private keys don’t match between the SIM and the database file (user_db.csv). But they do! Since there’s no way to query the SIM card’s K & OPC values, it’s hard to understand what’s going on. I’m using the same programmer,
    https://www.amazon.com/dp/B089FJGDFG?ref=ppx_yo2ov_dt_b_fed_asin_title
    and it’s propriety software. Also tried PySim

    1. Phil Greenland avatar
      Phil Greenland

      Hey Casey,

      Those SIMS look just about as anonymous as the ones I bought I’m afraid, hard to tell I suspect until you try them. Something to note that I think is largely universal across SIMS. The programming interface for the private data is proprietary. For example pySIM has a list of supported cards on their Wiki: https://osmocom.org/projects/pysim/wiki For generic SIMS they’re limited to reading the standard fields. The library works well with sysmocom’s sysmoISIM and friends though. I’ve got the exact same programmer and OYEITIMES software as you but bought as a bundle with a set of SIMS. Given the proprietary nature of the comminications, I’d suspect that if the software can read / write the keys on your SIMS I would have thought you’d be in a good place.

      I think I stored the profiles I loaded onto my SIMS, can dig them out if you wanted to try what was working for me?

      Thanks,

      Phil

      1. Casey avatar
        Casey

        Hi Phil, much appreciate the response and your offer to share your config. Yes, please send me your config (I believe you have my email address). I will try using that on my setup, which is identical to yours. In parallel I’ll re-try with the OYEITIMES software since there may be a compatibility issue with pySim.

      2. Casey avatar
        Casey

        I had success this morning .. yay!

        I went back and used the OYEITIMES proprietary software and found that I wasn’t able to program the new SIM cards.
        https://www.amazon.com/dp/B07F5DVZR2?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1
        So, I tried re-programming one of the SIMs I received with OYEITIMES hardware.
        https://www.amazon.com/dp/B089FJGDFG?ref=ppx_yo2ov_dt_b_fed_asin_title
        I made some very minor tweaks to the GUI (cleared the SMSP field and removed a leading space in front of the ICCID). The re-programming was a success (according to the software) and the Authentication was a success when connecting the modem to the eNB 🙂

        So, SIM cards to matter and (as you mentioned above) the software you use makes a difference too.

        1. Phil Greenland avatar
          Phil Greenland

          Very good, I didn’t spot the SIMS with the programmer when I looked earlier, you’ve essentially got the same kit as me. With regards to the other SIMS it may be worth asking the Amazon seller if they have the programming software that goes with them. It likely should work with your reader, which is just a regular smart card reader AFAIK. Glad to hear you got it working.

          Regards,

          Phil

Leave a Reply

Your email address will not be published. Required fields are marked *