Elmurod A. Talipov
14Aug/09Off

Connect G1 to Ad-hoc network

This guide will help you to connect your G1 to laptop's Ad-hoc wireless network.

Requirements:
1. Rooted G1 phone.
2. Terminal emulator. (You can download it here or from Android market)
3. Busybox for android. (download)

Steps:
1. Install Terminal emulator
I assume that most of you guys already have this since it is essential for root access.
For those who don't have this installed you will have to make sure that you have root access first.
The easyest way to install this application is to download it from Android market, but if you don't have access to internet from your phone, you could install it over ADB or some other way.
2. Install busybox for android
Open Terminal emulator and type following commands:
Become super user:

su

Make new directory for busybox and navigate to it:

 mkdir /data/busybox
cd /data/busybox 

Now you should copy your downloaded busybox file to this new directory. You could do this simply by connecting your phone to the computer over usb cable and copy file to the sdcard or you could push it using ADB service directly to our directory. If you wish to do this over ADB you should do the following.

a) ADB is part of Android SDK and you can freely download it for Windows, Linux or even Mac, just google it. Your downloaded busybox file must be in the same folder with adb or you can specify the different path in adb command if you have it somewhere else. To push the file to the phone using ADB you could type the following command on your computer (offcourse you must first navigate to the folder in which is your Android SDK and then to the subfolder tools):

adb push busybox /data/busybox/busybox

b) The other way is to copy the file to your sdcard and then move it to our folder with cat command, since we don't have cp command to copy the file. To do this you must type the following commands on your phone assuming we didn't leave Terminal emulator and we are still in /data/busybox/ directory.

cat /sdcard/busybox > ./busybox 

Now that you have it in your folder you should do the following:
Make busybox binary executable

chmod 755 ./busybox

Execute following command to install busybox:

./busybox --install

Make all the installed tools in folder executable like you did with the first one:

chmod 755 *

Last step is to export it to PATH to make it usable at all time.

export PATH=/data/busybox:$PATH

3. Now you can modify two important files to make your phone able to connect to Ad-hoc
First gain root access with su command like before:

su

Remount /system partition as read-write with the following command:

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system 

Navigate to /system/etc/wifi/

cd /system/etc/wifi

Now you must edit tiwlan.ini file in current directory. I did this with VI editor which is part of busybox. You must know some basic things about VI editor befor you do this. VI operates in two modes. When you open editor you are in command mode and you can't edit your file yet.
To edit file type:

vi tiwlan.ini

First you must navigate trough file with your trackball. Find the following line:

WiFiAdhoc = 0

This is the line we need to edit. To enter edit mode press A on your phone's keyboard. Now move the cursor with trackball to the end off this line. Replace 0 with 1. You must add two more lines in order this to work. To add new line press enter key and then type:

dot11DesiredSSID = HTCG1
dot11DesiredBSSType = 0

Replace HTCG1 with whatever you like. This is SSID of your wireless Ad-hoc network.
Now you must exit back again to command mode. This is done with escape key, and since our keyboard doesn't have escape key we must click down trackball and simultaniously press 1. This is the same as you pressed escape on regular computer keyboard. In command mode again we can't edit the file but we can type commands. Command for saving file is 'w' and for exiting editor is 'q'. Every command is typed after ':' so our command to save file and exit editor will be:

 :wq 

The next file we need to edit is /data/misc/wifi/wpa_supplicant.conf
Edit it the same way as previous file and add these lines:

network={
          ssid="HTCG1"
          key_mgmt=NONE
          mode=1
}

Save and exit
'mode = 1' indicate that this is Ad-hoc network

4. Make Ad-hoc network on your laptop or computer.
I assume you know how to do that and I won't explain it because you can google it. Only thing to know when you do this is that you have to set SSID for the network same as the SSID in two files you edited and that you must make open network without wep or other security. Yet if you decide to have protected network you must also edit wpa_supplicant.conf file and modify it. Again google it if you want to know more.

5. Finally connect
If you configured correctly your computer wireless network and selected it to connect, you should then disable and enable wireless in your mobile phone settings. If SSID is broadcasted you should see your network and signal strenght in network list. Connect.

Tagged as: , , , 1 Comment
21Apr/09Off

A Wireless Sensor Networks Bibliography

Here is the list of sensor network bibliography prepared by Autonomous Networks Research Group at USC. () means the number of papers available on this topic. I believe this list will be very useful to decide your future research, and write your related work.

Topic 1: Introduction
1. Visions and Applications (27)
2. Hardware (15)
3. Surveys and Taxonomy (6)

Topic 2: Deployment, Localization, Synchronization, Calibration
1. Deployment (99)
2. Localization (83)
3. Time Synchronization (26)
4. Calibration (8)

Topic 3: Wireless Communication
1. Wireless Radio and Link Characteristics (35)
2. MAC Protocols (67)
3. Link Layer Techniques (28)
4. Power Control (18)

Topic 4: Networking
1. Topology Control (43)
2. Data Gathering (33)
3. Geographic Routing (18)
4. Robust Routing (34)
5. Mobile Nodes (19)
6. Resource Aware Routing (20)
7. Autonomic Routing (5)
8. Network Monitoring (14)
9. Network Coding (4)

Topic 5: Data-centric Querying, Routing, and Storage
1. Routing and Aggregation (105)
2. Querying and Databases (36)
3. Storage (23)

Topic 6: Capacity and Lifetime
1. Capacity (23)
2. Lifetime Optimization (34)

Topic 7: Transport
1. Transport Layer (29)

Topic 8: Signal Processing and Computation
1. Target Tracking (36)
2. Diffuse Phenomena (10)
3. Compression (18)
4. Detection and Estimation (32)
5. Middleware and Task Allocation (11)
6. Distributed Algorithms (19)
7. Programming (5)

Topic 9: Security
1. Security (71)

Topic 10: Sensor Network Architecture
1. Sensor Network Architecture (9)

Topic 11: Miscellaneous
1. Software (35)
2. Sensing (2)

Due to the copyright I can't not include complete list here. But, here is a {LINK} to the list.

14Apr/09Off

Sensor Network 802.15.4 AODV Simulation

The reason to write this topic is many people asked me how to simulate sensor networks. Obviously, authors of 802.15.4/Zigbee protocol developers on NS2 have given a sample examples. But, these examples do not run correctly, and give some kind of unknown error (at least I don't know what errors mean). Therefore, I have decided to test AODV using 802.15.4 MAC/PHY. Thus, if my tests work, I hope you can test your own routing protocols using this source code.

Alright, the TCL file is fairly simple. I briefly explain what means what. We first set simulation environment. We are going to deploy 500 nodes, in 1000x500 sqm area, simulation time is 500 seconds. And we are using 802.15.4 MAC/PHY and interface queue is 100. We also set simulator and files to trace the simulation.

# Generated by Topology Generator for Network Simulator (c) Elmurod Talipov
set val(chan)          Channel/WirelessChannel      ;# channel type
set val(prop)          Propagation/TwoRayGround     ;# radio-propagation model
set val(netif)         Phy/WirelessPhy/802_15_4     ;# network interface type
set val(mac)           Mac/802_15_4                 ;# MAC type
set val(ifq)           Queue/DropTail/PriQueue      ;# interface queue type
set val(ll)            LL                           ;# link layer type
set val(ant)           Antenna/OmniAntenna          ;# antenna model
set val(ifqlen)        100	         	    ;# max packet in ifq
set val(nn)            500			    ;# number of mobilenodes
set val(rp)            AODV			    ;# protocol tye
set val(x)             1000			    ;# X dimension of topography
set val(y)             500			    ;# Y dimension of topography
set val(stop)          500			    ;# simulation period
set val(energymodel)   EnergyModel		    ;# Energy Model
set val(initialenergy) 100			    ;# value

set ns        		[new Simulator]
set tracefd       	[open trace-aodv-802-15-4.tr w]
set namtrace      	[open nam-aodv-802-15-4.nam w]

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

Let's set radio transmission range to 40 meters, but this does not mean exactly 40 meters. The code below filters packet with receiving signal strength above "40 meters".

set dist(5m)  7.69113e-06
set dist(9m)  2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(40m) 1.20174e-07
Phy/WirelessPhy set CSThresh_ $dist(40m)
Phy/WirelessPhy set RXThresh_ $dist(40m)

And lets set topography as flat, deploy nodes randomly in an area of 1000 x 500 sqm.

# set up topography object
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

# configure the nodes
$ns node-config -adhocRouting $val(rp) \
            -llType $val(ll) \
             -macType $val(mac) \
             -ifqType $val(ifq) \
             -ifqLen $val(ifqlen) \
             -antType $val(ant) \
             -propType $val(prop) \
             -phyType $val(netif) \
             -channel [new $val(chan)] \
             -topoInstance $topo \
             -agentTrace ON \
             -routerTrace ON \
             -macTrace  OFF \
             -movementTrace OFF \
             -energyModel $val(energymodel) \
             -initialEnergy $val(initialenergy) \
             -rxPower 35.28e-3 \
             -txPower 31.32e-3 \
	     -idlePower 712e-6 \
	     -sleepPower 144e-9

             #-IncomingErrProc MultistateErrorProc \
             #-OutgoingErrProc MultistateErrorProc

for {set i 0} {$i < $val(nn) } { incr i } {
        set mnode_($i) [$ns node]
}

for {set i 1} {$i < $val(nn) } { incr i } {
	$mnode_($i) set X_ [ expr {$val(x) * rand()} ]
	$mnode_($i) set Y_ [ expr {$val(y) * rand()} ]
	$mnode_($i) set Z_ 0
}

And we are goig to deploy sink node in the center of area, i.e. at [500, 250].

# Position of Sink
$mnode_(0) set X_ [ expr {$val(x)/2} ]
$mnode_(0) set Y_ [ expr {$val(y)/2} ]
$mnode_(0) set Z_ 0.0
$mnode_(0) label "Sink"

The code below is useful how big the nodes are going to be shown in NAM (network animator), thus it does not have meaning in real simulation.

for {set i 0} {$i < $val(nn)} { incr i } {
	$ns initial_node_pos $mnode_($i) 10
}

Finally, we have deployed nodes, and remained important thing is establish connection. We are going to use UDP protocol with CBR (constant bit rate, interval (interval_) is set to 2 seconds)

#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $mnode_(10) $udp

set sink [new Agent/Null]
$ns attach-agent $mnode_(0) $sink

$ns connect $udp $sink
$udp set fid_ 2

#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 50
$cbr set rate_ 0.1Mb
$cbr set interval_ 2
#$cbr set random_ false

$ns at 5.0 "$cbr start"
$ns at [expr $val(stop) - 5] "$cbr stop"

# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "$mnode_($i) reset;"
}

# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at [expr $val(stop) + 0.01] "puts \"end simulation\"; $ns halt"
proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
}

$ns run

We have finished writing sample AODV TCL script, we can run it

 ns aodv_802_15_4.tcl 

NAM gives me following deployment result.

nam-aodv-802-15-4nam

Download whole source code here : aodv_802_15_4.tcl . If you find any problem with that, leave comment here. If you want to test your own routing protocol simply change $val(rp) AODV with your own.

8Apr/09Off

How do I restart Linux network service?

RedHat Linux command to reload or restart network (login as root user):

service network restart

OR

/etc/init.d/network restart

To start Linux network service:

service network start

To stop Linux network service:

service network stop

Debian Linux command to reload or restart network:

/etc/init.d/networking restart

To start Linux network service:

/etc/init.d/networking start

To stop Linux network service:

/etc/init.d/networking stop

Ubuntu Linux user use sudo command with above Debian Linux command:

sudo /etc/init.d/networking restart

To start Linux network service:

sudo /etc/init.d/networking start

To stop Linux network service:

sudo /etc/init.d/networking stop