Mar 6 2012
Programatically Access Statistics from 3G Mifi/Access Point!!
Specifically I’m going to talk about the Huawei MIFI (Mobile 3G Wifi) E585 though these could be applied to another access point/ mifi. You will need the web debugger FIDDLER (a http request sniffer).
So, probably your MIFI/access point is configured with IP address 192.168.1.1 .
If there are pages that display the statistics (such as those on the E858) there is a chance the information can be accessed through a .php or other dynamic page.
On the E858, accessing http://192.168.1.1/ displays the current total download/upload and flux for the current session. (pictures coming later).
However, if you want to check more analytical statistics such as total usage you have to log on. Fortunately, if the data screen uses a JQuery (or javascript ajax script) fiddler can be used to sniff and discover the data source (post me a line for more instructions).
In the case of E858, all statistics are accessible through http://192.168.1.1/ipad.cgi which includes current bit rate, total number of connected devices, DNS, etc, without requiring http authentication.
Below is a quick proof of concept which parses the total usage (in gigabytes) and sends an e-mail when over a threshold. It’s a proof of concept – not an actual robust app 😛 (feel free to extend though) .
The parsing of ipad.cgi for the E858 or other data sources for other devices can be used to interesting tools and widgets not provided initially by the company software (if circumstances allow). In my case I plan to build a windows taskbar monitor to display total connected users, total data consumption, and real time info from my pc without logging into the MIFI.
Hope it helps!
[Download eclipse project here]
Imports go here…
public class Scan3GUsage {
public static void main(String args[])
{
double TotalFlux;
double threshhold = 15.00;
while(true)
{
System.out.println(TotalFlux = readTotalConsumption());
if(threshhold <= TotalFlux)
{
sendEmail();
System.exit(0);
}
try {
Thread.sleep(60*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static double readTotalConsumption()
{
String tempString = null;
try {
URL myURL = new URL(“http://192.168.1.1/ipad.cgi”);
URLConnection myURLConnection =
myURL.openConnection();
myURLConnection.connect();
BufferedReader in = new BufferedReader(
new InputStreamReader(myURLConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
if(inputLine.indexOf(“Tottflux”)!=-1)
tempString = inputLine.substring(10,15); //Must Account for MB, Other measurements
in.close();
return Double.parseDouble(tempString);
}
catch (MalformedURLException e) {
}
catch (IOException e) {
}
return -1;
}
public static void sendEmail()
{
Properties props = new Properties();
props.put(“mail.smtp.host”, “smtp.gmail.com”);
props.put(“mail.smtp.socketFactory.port”, “465”);
props.put(“mail.smtp.socketFactory.class”,
“javax.net.ssl.SSLSocketFactory”);
props.put(“mail.smtp.auth”, “true”);
props.put(“mail.smtp.port”, “465”);
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(“account”,”password”);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(“email@email.com”));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(“your_email@domain.com”));
message.setSubject(“Over the Usage Limit”);
message.setText(“Warning, you are over the 3G usage limit.”);
Transport.send(message);
System.out.println(“Done”);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
Enjoy,
Menelaos!
Alex
Sep 09, 2014 @ 03:42:07
Howdy! I know this is kinda off topic nevertheless I’d figured I’d ask.
Would you be interested in trading links or maybe guest
authoring a blog post or vice-versa? My blog addresses a lot of the same
topics as yours and I believe we could greatly benefit from each other.
If you are interested feel free to send me an e-mail.
I look forward to hearing from you! Fantastic blog by the way!