Every operator has a group of IP addresses. If you know the network address of the operator you can compare the visitor's IP with operator's address.
So for example if you know the mobile operator owns a group of ip addresses starting with 212.235.*.*
you compare first 16 bits of the visitor's address with it, if for example the visitor's address is 212.235.190.215 you know it comes from mobile network.
You can check this condition with simple string operations - compare first x characters of visitor's ip address with x known characters at the beginning of operator's ip address.