CgiCorrelator¶
-
class
sitchlib.
CgiCorrelator
(feed_dir, cgi_whitelist, mcc_list, device_id)[source]¶ The CgiCorrelator compares CGI addressing against the OpenCellID DB.
The feed data is put in place by the FeedManager class, prior to instantiating the CgiCorrelator.
-
classmethod
bts_from_channel
(channel)[source]¶ Create a simplified representation of BTS metadata.
Parameters: channel (dict) – Returns: Contains MCC, MNC, LAC, and cellid Return type: dict
-
classmethod
build_chan_here
(channel, state)[source]¶ Build geo information for channel, to aid in geo correlation.
Parameters: - channel (dict) – Channel metadata
- state (dict) – Geo-json representing the current location of the sensor
Returns: - Original channel structure, with the current sensor location
embedded.
Return type: dict
-
classmethod
cell_matches
(cell, mcc, mnc, lac, cellid)[source]¶ Compare cell metadata against mcc, mnc, lac, cellid.
-
classmethod
cgi_whitelist_message
(cgi_wl)[source]¶ Format and return the CGI whitelist initialization message.
Parameters: cgi_wl (list) – CGI whitelist Returns: Formatted message Return type: str
-
classmethod
channel_out_of_range
(channel)[source]¶ Check to see if sensor is out of range for CGI.
Parameters: channel (dict) – Channel metadata Returns: True if the sensor is in range of the detected CGI Return type: bool
-
check_channel_against_feed
(channel)[source]¶ Determine whether or not to fire an alert for CGI presence in feed.
Parameters: channel (dict) – Channel metadata Returns: - Empty if there is no alert, a two-item tuple if an alert
- is generated.
Return type: tuple
-
check_channel_range
(channel)[source]¶ Check to see if the detected CGI is in range.
Parameters: channel (dict) – Channel metadata, enriched with feed info. Returns: - Empry if no alert is generated. A two-item tuple if an
- alert condition is detected.
Return type: tuple
-
check_scan_document
(scan_document)[source]¶ Check to see if there are no in-LAI neighbors for channel 0
-
classmethod
convert_float_targets
(channel)[source]¶ Convert string values for rxq and rxl to floating point.
-
correlate
(scan_bolus)[source]¶ Entrypoint for the CGI correlation component.
Parameters: scan_bolus (tuple) – scan_bolus[0] contains the scan type. If the type is ‘gps’, it will set the correlator’s geo location. For other scan types, we expect them to look like gsm_modem_channel events, and they are compared against the feed database as well as state history, tracking things like the current active cell’s CGI. Returns: - Returns a list of tuples, representing alerts. If no alerts
- fire, the list will be empty.
Return type: list
-
feed_comparison
(channel)[source]¶ Compare channel metadata against the feed DB.
- This function wraps a few checks against the feed DB. It first checks
- if the bts is in the feed DB. Next, it checks that the sensor is within range of the BTS in the feed DB. Finally, if it’s the primary channel, it checks to see if the primary BTS has changed.
Parameters: channel (dict) – Channel, enriched with geo information Returns: - If alarms are generated, they’ll be returned in a list of
- tuples. Otherwise, an empty list comes back.
Return type: list
-
get_feed_info
(mcc, mnc, lac, cellid)[source]¶ Check CGI against cache, then against the feed DB.
Parameters: - mcc (str) – Mobile Country Code
- mnc (str) – Mobile Network Code
- lac (str) – Location Area Code
- cellid (str) – Cell ID
Returns: Dictionary containing feed information for CGI
Return type: dict
-
get_feed_info_from_db
(mcc, mnc, lac, cellid)[source]¶ Interrogate DB for CGI information.
Parameters: - (str) – Mobile Country Code
- mnc (str) – Mobile Network Code
- lac (str) – Location Area Code
- cellid (str) – Cell ID
Returns: - Dictionary containing feed information for CGI. If no
information exists, the feed geo information will be zeroed out…
Return type: dict
-
classmethod
make_bts_friendly
(bts_struct)[source]¶ Create a human-friendly representation of CGI.
Parameters: bts_struct (dict) – Simple structure containing CGI components. Returns: - String reperesentation of CGI, with items being
- colon-separated.
Return type: str
-
classmethod
normalize_feed_info_for_cache
(feed_item)[source]¶ Normalize field keys for the feed cache.
-
classmethod
primary_bts_changed
(prior_bts, channel, cgi_whitelist)[source]¶ Create alarms if primary BTS metadats changed.
Parameters: - prior_bts (str) – Current primary BTS
- channel (dict) – Channel metadata
- cgi_whitelist – Whitelist of CGIs to NOT alert on
Returns: - True if the primary BTS has changed and the new BTS in not
on the whitelist. False otherwise.
Return type: bool
-
classmethod