This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sdk:connection-statistics [2015/03/17 16:43] 127.0.0.1 external edit |
sdk:connection-statistics [2021/08/04 09:20] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Connection Statistics ====== | ====== Connection Statistics ====== | ||
+ | {{ :sdk:sweg.png |}} | ||
+ | {{ :sdk:statistics.jpg |}} | ||
In many mobile use cases customers want to have additional information on network coverage, signal and connections quality, roaming and so on. | In many mobile use cases customers want to have additional information on network coverage, signal and connections quality, roaming and so on. | ||
- | Data gain be generated using a SDK script such as this one here. It queries ''cli status'' periodically and logs the items you are interested in into a comma separated file e.g.''/home/sdk/sandbox/logger/current.csv''. When the script restart or when a configurable timeout is reached, a new file is written. | + | This data can be generated using a SDK script such as ''logger.are''. It queries ''cli status'' periodically and logs the items you are interested in into a comma separated values file e.g.''/home/sdk/sandbox/logger/current.csv''. When the script restarts or when a configurable timeout is reached, a new file is written. |
- | A second script will upload the log files in the given directory from time to time to a FTP server. | + | A second script will upload the log files in the working directory from time to time to a FTP server. |
- | Once having the data on the server, it can be evaluated, e.g. by drawing it onto a map or analyse it with Excel. | + | Once having the data on the server, it can be evaluated, e.g. by drawing it onto a map or analyse it with Excel or NI DIAdem. |
+ | |||
+ | |||
+ | ===== Logging Skript ===== | ||
<code c logger.are> | <code c logger.are> | ||
/* DESC: A script that can be used for a longtime logging of a NetModule Router. | /* DESC: A script that can be used for a longtime logging of a NetModule Router. | ||
Line 129: | Line 135: | ||
int logNow() { | int logNow() { | ||
//get current status output | //get current status output | ||
- | sections=mkarray("system","wan","wwan","wlan","gnss","lan","openvpn","ipsec","dio","license"); | + | sections=mkarray("system","wan","wwan","wlan","gnss","lan","openvpn","ipsec","dio","license", "hotspot"); |
status=mkstruct(); | status=mkstruct(); | ||
for (i=0;i<length(sections);i++) { | for (i=0;i<length(sections);i++) { | ||
Line 180: | Line 186: | ||
nb_syslog("Current Logsize: %i byte",this.currentLogSize); | nb_syslog("Current Logsize: %i byte",this.currentLogSize); | ||
//if we don't have enough space delete enough old ones to have enough space | //if we don't have enough space delete enough old ones to have enough space | ||
- | for(i=0;i<length(files);i++) { | ||
- | if (this.currentLogSize < (this.maxLogSize-this.freespace)) break; | ||
- | if(remove(sprintf("%s%s",this.path,files[i]))) { | ||
- | this.currentLogSize=this.currentLogSize-size[i]; | ||
- | nb_syslog("Removed %s%s",this.path,files[i]); | ||
- | } else { | ||
- | nb_syslog("could not remove %s%s",this.path,files[i]); | ||
- | } | ||
- | } | ||
- | nb_syslog("new logsize: %i", this.currentLogSize); | ||
return 0; | return 0; | ||
} | } | ||
} | } | ||
+ | // ###################################################### | ||
+ | // ###################################################### | ||
+ | // ###################################################### | ||
l = new logger("/logger/"); | l = new logger("/logger/"); | ||
+ | // Timestamp of the Logentry | ||
l.addField("SYSTEM_TIME"); | l.addField("SYSTEM_TIME"); | ||
+ | |||
+ | |||
+ | // GPS Fields | ||
l.addField("GNSS1_LONGITUDE"); | l.addField("GNSS1_LONGITUDE"); | ||
l.addField("GNSS1_LATITUDE"); | l.addField("GNSS1_LATITUDE"); | ||
l.addField("GNSS1_SATELLITES_INVIEW"); | l.addField("GNSS1_SATELLITES_INVIEW"); | ||
- | l.addField("MOBILE1_SIGNAL"); | + | |
+ | |||
+ | // LTE Connection Fields | ||
+ | // Can be cloneed with MOBILE2 in case more LTE Connections are used | ||
+ | // Arbitrary Strength Unit (ASU) https://en.wikipedia.org/wiki/Mobile_phone_signal#ASU | ||
+ | l.addField("MOBILE1_SIGNAL_LEVEL"); | ||
+ | // received signal code power https://en.wikipedia.org/wiki/Received_signal_code_power | ||
+ | l.addField("MOBILE1_SIGNAL_RSCP"); | ||
+ | // Received signal strength indication https://en.wikipedia.org/wiki/Received_signal_strength_indication | ||
+ | l.addField("MOBILE1_SIGNAL_RSSI"); | ||
+ | // Service Type: LTE/HSPA/3G/2G/EDGE | ||
l.addField("MOBILE1_SERVICE_TYPE"); | l.addField("MOBILE1_SERVICE_TYPE"); | ||
+ | // NETWORK ID of the LTE Network we are connected to | ||
l.addField("MOBILE1_LAI"); | l.addField("MOBILE1_LAI"); | ||
+ | // Area Code in LTE Network | ||
l.addField("MOBILE1_LAC"); | l.addField("MOBILE1_LAC"); | ||
+ | // Cell ID we are connected to | ||
l.addField("MOBILE1_CID"); | l.addField("MOBILE1_CID"); | ||
+ | // Is the SIM registered in Home or Roaming | ||
+ | l.addField("MOBILE1_REGISTRATION_STATE"); | ||
+ | |||
+ | |||
+ | // WAN Data Connection field | ||
+ | // Connection that is current default Gateway | ||
l.addField("WAN_HOTLINK"); | l.addField("WAN_HOTLINK"); | ||
+ | // Per WANLINK/LTE Connection: | ||
+ | // Current State: up/down/dialin | ||
l.addField("WANLINK1_STATE"); | l.addField("WANLINK1_STATE"); | ||
+ | // Current upload and download rates | ||
l.addField("WANLINK1_DOWNLOAD_RATE"); | l.addField("WANLINK1_DOWNLOAD_RATE"); | ||
l.addField("WANLINK1_UPLOAD_RATE"); | l.addField("WANLINK1_UPLOAD_RATE"); | ||
+ | // Bytes that are already down- or uploaded. | ||
l.addField("WANLINK1_DATA_DOWNLOADED"); | l.addField("WANLINK1_DATA_DOWNLOADED"); | ||
l.addField("WANLINK1_DATA_UPLOADED"); | l.addField("WANLINK1_DATA_UPLOADED"); | ||
+ | |||
+ | // WLAN Fields | ||
+ | // WLAN Clients Attached to the Accesspoint | ||
l.addField("WLAN1_STATION_COUNT"); | l.addField("WLAN1_STATION_COUNT"); | ||
Line 215: | Line 244: | ||
l.intervall=5; // log every 5sec | l.intervall=5; // log every 5sec | ||
l.logfileIntervall=3600; // create a new file every 5 min | l.logfileIntervall=3600; // create a new file every 5 min | ||
+ | |||
+ | // ###################################################### | ||
+ | // ###################################################### | ||
+ | // ###################################################### | ||
+ | // ###################################################### | ||
Line 253: | Line 287: | ||
+ | ===== Skript to periodcly upload the csv Files ===== | ||
<code c uploader.are> | <code c uploader.are> | ||
Line 323: | Line 358: | ||
u = new uploader("/logger/"); | u = new uploader("/logger/"); | ||
- | u.server="ftp://share.netmodule.com/router/public"; | + | u.server="https://share.netmodule.com/router/public"; |
u.serverpath="/logger/"; | u.serverpath="/logger/"; | ||
u.user="*******"; | u.user="*******"; | ||
Line 331: | Line 366: | ||
</code> | </code> | ||
- | <code python scatter_sweg.py> | + | |
+ | |||
+ | Example Python script to visualize the Data: | ||
+ | |||
+ | |||
+ | |||
+ | <code python scatter.py> | ||
from mpl_toolkits.basemap import Basemap | from mpl_toolkits.basemap import Basemap | ||
import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
Line 371: | Line 412: | ||
minlat=85.0 | minlat=85.0 | ||
- | fi=open(r'data/sweg_20150220_.log','r') | + | fi=open(r'data/<logfile>.log','r') |
csvlog=csv.DictReader(fi, delimiter=',') | csvlog=csv.DictReader(fi, delimiter=',') | ||
for row in csvlog: | for row in csvlog: | ||
Line 483: | Line 524: | ||
plt.legend() | plt.legend() | ||
- | plt.title("SWEG VT 531 Testfahrt von " + startTime.strftime(tf) + " bis " + endTime.strftime(tf) ) # might want to change this! | + | plt.title("NetModule test drive from " + startTime.strftime(tf) + " until " + endTime.strftime(tf) ) # might want to change this! |
plt.savefig(dt.now().strftime("%Y%m%d_%H%M%S.png"),dpi=200) | plt.savefig(dt.now().strftime("%Y%m%d_%H%M%S.png"),dpi=200) | ||
plt.show() | plt.show() | ||
</code> | </code> | ||
+ |