Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding location using MCC, MNC, LAC, and Cell ID

I know what the values are for MCC, MNC, LAC, & Cell ID. I want to in C write a program to calculate the position in the form of latitude and longitude values in Linux.

FYI:

  • MCC - Mobile Country Code
  • MNC - Mobile Network Code
  • LAC - Location Area Code; a 16 bit number thereby allowing 65536 location areas within one GSM PLMN
  • more info is available here on Wikipedia, Location Area Identity

Question:

  1. How can I convert MCC,MNC,LAC,Cell ID into latitude and longitude values in linux?
  2. Why does Cell ID varies every time,when trying to read?
like image 712
Embedded Programmer Avatar asked Sep 08 '13 01:09

Embedded Programmer


People also ask

What is cell ID MCC MNC LAC?

Cell Global Identity (CGI) is a globally unique identifier for a Base Transceiver Station in mobile phone networks. It consists of four parts: Mobile Country Code (MCC), Mobile Network Code (MNC), Location Area Code (LAC) and Cell Identification (CI).

What is LAC and cell ID?

LAC means Location Area Code, which is a group of cell towers. And CID stands for Cell Identification, referring to the cell number and sometimes a sector. In other words, the CID tells you where the antenna is located and which direction it faced.

How do I find my cell tower ID?

One of the most accurate sources of cell tower locations is CellMapper.net, which uses a crowdsourced database of 4G and 5G tower locations.


1 Answers

i wrote a python script that can do this for you. You can get a binary from the pyc file.

#!/bin/python
"""
Written by Atissonoun - Credits to MFC & HAC
***You need to initialize the script in order to fix the import and the dependency.
This is only a Beta version of the project***
This python file works as the engine for the project.
imports, coordinates, run......
"""

#Importing modules
import requests
#defining a Api_Keys

Google_API_KEY="Your google API Key goes here"
OpenCell_Api_Key ="Your OpenCellID API Key goes here"

def Google(MMC,MNC,LAC,ID,API_KEY=Google_API_KEY):
    url = "https://www.googleapis.com/geolocation/v1/geolocate?key={}".format(API_KEY)
    data={
    "radioType": "gsm",
    "cellTowers":[
        {
        "cellId": ID,
        "locationAreaCode": LAC,
        "mobileCountryCode": MMC,
        "mobileNetworkCode": MNC
        }
    ]
    }
    response = requests.post(url, json=data)
    if response.status_code == 200 :
        lat=response.json()[u'location'][u'lat']
        long = response.json()[u'location'][u'lng']
        d={'LAT':lat,'LONG':long}
        print('Located Cell: {}'.format(ID))
        return d
    else:
        print('Error: {}'.format(response.status_code))
        return None

def Opencell(MMC,MNC,LAC,ID,API_KEY=OpenCell_Api_Key):
    url = "https://us1.unwiredlabs.com/v2/process.php"
    data = {
        "token": API_KEY,
        "radio": "gsm",
        "mcc": MMC,
        "mnc": MNC,
        "cells": [{
            "lac": LAC,
            "cid": ID
        }]
    }
    response = requests.post(url, json=data)
    if response.status_code == 200:
        if response.json()[u'status']== 'error':
            print('Error: {}'.format(response.json()[u'message']))
            return None
        else:
            lat = response.json()[u'lat']
            long = response.json()[u'lon']
            d = {'LAT': lat, 'LONG': long}
            print('Located Cell: {}'.format(ID))
            return d
    else:
        print('Error: {}'.format(response.status_code))
        return None
like image 183
Ahmed chiboub Avatar answered Sep 17 '22 14:09

Ahmed chiboub