SIM router - kamwar/simLAB GitHub Wiki
SIM router
The module allows to connect many SIM cards and define routing attributes for every SIM. From the phone side, SIM router is visible as a single SIM.
You might define files and instructions routed to the specific SIM as in the example below
Routing Modes
You can use predefined routing modes or create your own configuration.
Note: for exchanging APDU between phone and SIM router you need simlabTrace HW. Without simlabTrace, you will still be able to run simLAB.
Predefined modes
-
mim_live.py In this mode, live SIM is connected to a SIM reader. This mode is commonly used for APDU tracing. If you want to connect the SIM remotely, check remote connection.
-
mim_soft.py No hardware (SIM reader nor live SIM) is needed besides simlabTrace. Soft SIM implementation is described [here](https://github.com/kamwar/simlab/wiki/SIM soft). This mode is commonly used for APN tests as you might easily modify IMSI. To register with NW simulator, set dummy xor authentication algorithm according to settings in ./sim/sim_codes.py
-
mim_soft_live_reg.py Live SIM is connected to a SIM reader. All files and instructions needed for registering and authentication are routed to the live SIM. All other files are routed to soft SIM. This mode is commonly used when authentication is only possible with live SIM. It's very convenient for network name and SAT tests.
-
mim_soft_live_auth.py Similar to previous mode. Only authenticate instruction is executed on live SIM. IMSI and some other files needed for registering are copied from live to soft SIM during startup. FPLMN file is cleared on the soft SIM.
-
mim_live_live_soft_sat.py Both Live SIMs are connected to SIM readers. All SAT instructions are forwarded to soft SIM. This mode is commonly used for testing dual profile SIM. From SAT menu, you might trigger refresh to simulate roaming broker scenario. To change master SIM, use SAT menu: Refresh --> Swap cards
-
mim_live_live.py Both Live SIMs are connected to SIM readers. All files and instructions needed for authentication are routed to the 2nd live SIM. This mode is commonly used for testing live SAT when authentication is only possible on the 2nd SIM (e.g. with NW simulator). It's useful for testing carrier SIM with SAT when test scenario is executed offsite.
MiM customized configuration
Example of forwarding specified files and instructions to 2nd (slave) SIM
#create and connect soft SIM
sim1 = sim_card.SimCard(mode=sim_reader.MODE_SIM_SOFT)
sim1.connect(sim_reader.READER_ID_0)
atr1 = sim1.getATR()
#create and connect live SIM
sim2 = sim_card.SimCard()
sim2.connect(sim_reader.READER_ID_0)
#initialize SIM router
simRouter = sim_router.SimRouter(cards=[sim1, sim2], atr=atr1)
#forward files related with registering (EF_IMSI, EF_FPLMN, EF_LOCI, ...) to sim2
sim2.routingAttr.filesReplaced = sim_card.FILES_REG
#forward instruction INTERNAL_AUTHENTICATE to sim2
sim2.routingAttr.insReplaced = ['INTERNAL_AUTHENTICATE']
#start SIM router
simRouter.run()
Remote SIM connection
SIM router uses zerorpc to connect live SIM. For remote live SIM connection, start server executing mim_live.py on the remote machine. Modify MiM configuration on the target machine using the server IP address:
# Connect to external SIM server/reader.
# Default configuration is set to local IP address, port 4148
sim_reader.PYSCARD_RPC_IP_ADDRESS = SERVER_IP
sim_reader.LOCAL_PYSCARD_SERVER = False
#now live SIM is configured with remote IP address
sim = sim_card.SimCard(type=simType)
sim.connect(sim_reader.READER_ID_0)
Note: remote connection is not supported for soft SIM