Graphical interface for OSMO-NITB GSM Network – socket.io, node.js, shell scripts


I created a simple GUI for the OSMO-NITB software using the USRP1, a software defined radio (SDR) card.  This SDR along with OSMO-NITB allows users to create a GSM network: connecting cellphones, phone calls and text messages.

The OSMO-NITB runs through the terminal but I created a simple interface to turn on the 3 sections of Osmocom software needed to run the GSM network.

For more information on installing OSMO-NITB:
http://openbsc.osmocom.org/trac/wiki/network_from_scratch

 

 

Prerequisites: Ubuntu 12.04.05

Computer used: Dell Mini

 

1. Install node.js

Ubuntu 12.04.05 does not have the latestapt-get repo for node.js.  So I did the following:


apt-get install python-software-properties
apt-add-repository ppa:chris-lea/node.js
apt-get update

This installs the Chris Lea Repo which has the right node.js repo.

Using Launchpad repo by Chris Lea just run following commandsnode.js install

apt-get install nodejs

Check node.js version

node -v

Outputs

v0.10.20

npm install

Above command should install npm.Check npm version

npm -v

Outputs

1.4.3

If for some reason, if you see npm is not installed, you may try running:

apt-get install npm

 

above from https://rtcamp.com/tutorials/nodejs/node-js-npm-install-ubuntu/

Latest node.js & npm installation on Ubuntu 12.04

 

2. Setup Socket.io

ADD SPECIFIC NOTES

First let’s create a package.json manifest file that describes our project. I recommend you place it in a dedicated empty directory (I’ll call mine Osmo-Gui).

{
  "name": "Osmo-Gui",
  "version": "0.0.1",
  "description": "my first GUI socket.io app",
  "dependencies": {}
}

Now, in order to easily populate the dependencies with the things we need, we’ll use npm install --save:

npm install --save express@4.10.2

Now that express is installed we can create an index.js file that will setup our application.

——-

npm install --save socket.io

 

3. Make SH bash scripts

write bash (.sh) scripts which will run the appropriate command to start Osmocom software.

– these scripts are also available in github: https://github.com/ereedsanchez/GSM-GUI
e
dit .cfg files to for your particular Osmocom installation

 

For my particular installation the commands needed are:

$ sudo osmo-trx
$ sudo osmobts-trx -c /home/xdell0/gsm/osmo-bts_OSMOSITE.cfg
$ sudo osmo-nitb -c /home/xdell0/gsm/open-bsc-OSMOSITE.cfg

 

The bash scripts are:

 

TurnOnTRX.sh

#!/usr/bin/env bash
gnome-terminal -e "bash -c \"osmo-trx; exec bash\""

 

TurnOnBSC.sh

#!/usr/bin/env bash
gnome-terminal -e "bash -c \"sudo osmo-nitb -c /home/xdell0/gsm/open-bsc-OSMOSITE.cfg
; exec bash\""

TurnOnBTS.sh

#!/usr/bin/env bash
gnome-terminal -e "bash -c \"sudo osmobts-trx -c /home/xdell0/gsm/osmo-bts_OSMOSITE.cfg; exec bash\""

 

4. Make .sh scripts executable 

You must make sh executable script.

$ sudo chmod 700 location/of/file.sh

 

5. Edit Index.html and index .js file

Express automatically sets up a index.html and index.js file. Both files need to be changed for your specific needs.  For the index.html I used a table and radio buttons to execute the bash scripts.

 

index.html 
—–
see code:

https://raw.githubusercontent.com/ereedsanchez/GSM-GUI/master/index.html
—–

 

index.js


//run socket.io
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
//run shell script
var sys = require('sys')
var exec = require('child_process').exec;

app.get('/', function(req, res){
  res.sendfile('index.html');
});

io.on('connection', function(socket){

//Mesage
    socket.on('Cmessage', function(msg){
    io.emit('Cmessage', msg);
    console.log('message: ' + msg);
//Mesage shell script
	function puts(error, stdout, stderr) {sys.puts(stdout)}
    exec("./helloworld.sh", puts);
  });

//TRX
    socket.on('TurnOnTRX', function(msg){
    io.emit('TurnOnTRX', msg);
    console.log('TRX: ON');
//TRX shell script
	function puts(error, stdout, stderr) {sys.puts(stdout)}
    exec("./TurnOnTRX.sh", puts);
  });

//BTS
    socket.on('TurnOnBTS', function(msg){
    io.emit('TurnOnBTS', msg);
    console.log("BTS is On");
//BTS shell script
    function puts(error, stdout, stderr) {sys.puts(stdout)}
    exec("./TurnOnBTS.sh", puts)
});

//BSC
    socket.on('TurnOnBSC', function(msg){
    io.emit('TurnOnBSC', msg);
    console.log('BSC: ON');
//BSC shell script
  function puts(error, stdout, stderr) {sys.puts(stdout)}
    exec("./TurnOnBSC.sh", puts);
  }); 
});

http.listen(3000, function(){
  console.log('listening on *:3000');
});

 

 6. Run index.js 

From the terminal, and within the directory run index.js.

 

7. Open Browser and go to localhost:3000

Now you should see the web GUI and can turn on each step of the Osmocom process.