Monday, March 12, 2012

Zigbee standard message sequence while Disassosiation

Disassociation

  1. MLME-DISASSOCIATE.request (64-bit address, 0 x 00–0 x ff (disassociation reason), True/False(Security enable))
        → Higher layer to MAC of device.

  1. PLME-SET-TRX-STATE.request (TX_ON)
        → MAC to PHY of device.

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC of device.

  1. PD-DATA.request ( psduLength((<=127, msdu length)), psdu(set of octets) )
        → MAC to PHY of device.

Note: Sent Disassociation notification.

  1. PD-DATA.confirm (SUCCESS)
        → PHY to MAC of device.

  1. PLME-SET-TRX-STATE.request (RX_ON)
        MAC to PHY of device.

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC of device.

Note: Wait for macAckWaitDuration & get it.

  1. PLME_SET-TRX-STATE.request (RX_ON)
        → PHY to MAC on coordinator side.

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC on coordinator side.

Note: Receives disassociation request.

  1. PD-DATA.indication ( psduLength(<=127, msdu length) psdu(set of octets), 0 x 00 to 0x ff(ppduLinkQuality) )

        → PHY to MAC on coordinator side.

  1. PLME-SET-TRX-STATE.request (TX_ON)
        → MAC to PHY on coordinator side.

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC on coordinator side.

  1. PD-DATA.request ( psduLength((<=127, msdu length)), psdu(set of octets) )
        → MAC to PHY on coordinator side.

Note: Sent Acknowledgment request.

  1. PD-DATA.confirm (SUCCESS)
        → PHY to MAC on coordinator side.

  1. MLME-DISASSOCIATE.indication ( DeviceAddress(64 bit address), 0 x 000 x ff (DisassociateReason ), True/False(Security use), 0 x 000 x 08 (ACLEntry ) )
        → MAC to Higher layer on coordinator side.

  1. PD-DATA.indication ( psduLength(<=127, msdu length) psdu(set of octets), 0 x 00 to 0x ff(ppduLinkQuality) )
       PHY to MAC on device.

Note: Received acknowledgment.

  1. MLME-DISASSOCIATE.confirm ( SUCCESS )
        → MAC to Higher layer on device.

Zigbee standard message sequence while a Device associate with a Co-ordinator (In Device side)



Device Association with Coordinator (Device side)


  1. MLME-RESET.request ( true/false (SetDefaultPIB) )
        → Upper layer to MAC

  1. PLME-SET-TRX-STATE.request (TRX_OFF)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. MLME-RESET.confirm (SUCCESS)
        → MAC to Higher layer

  1. MLME-SCAN.request( 0 x 02(ScanType, Passive), 32-bit field(ScanChannels), 0 to 14(ScanDuration) )
        Higher layer to MAC.

  1. PLME-SET-TRX-STATE.request (RX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. PLME-SET.request ( 0 x 00(PIBAttribute Identifier-phyCurrentChannel), firstchannel(0 to 26) )
        → MAC to PHY

  1. PLME-SET.confirm ( SUCCESS, 0 x 00(PIBAttribute Identifier- phyCurrentChannel) )
        PHY to MAC

Note: Beacons will arrive

  1. PD-DATA.indication ( psduLength(<=127, msdu length) psdu(set of octets), 0 x 00 to 0x ff(ppduLinkQuality) )

        PHY to MAC

 Note: Receives the beacon from one channel for aBaseSuperframeDuration x (2n +1), where n is ScanDuration whose value < 14.

Note: Steps 8 to 10 done repeatedly to finish scanning of all channels specified in ScanChannels parameter of MLME-SCAN.request.


  1. PLME-SET-TRX-STATE.request (TRx_off)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. MLME-SCAN.confirm( SUCCESS, 0 x 02(ScanType-Passive scan), 32-bit field(unscanned channels), ResultListSize(No. Of elements returned, 0 for orphan), 0 x 00 to 0x ff(List of energy measured, one for each channel), PANDescriptorList(Null for ED & Orphan) )

        MAC to Higher level

Note: Selection of PAN based on list of PAN descriptors.

  1. MLME-ASSOCIATE.request ( LogicalChannel(Integer), 0 x 02–0 x 03 (CoordAddrMode), 0 x 0000–0 x ffff(CoordPANId), CoordAddress(As specified inCoordAddrMode ), CapabilityInformation, True/False(Security enable) )

        Higher layer to MAC

  1. PLME-SET-TRX-STATE.request (TX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. PD-DATA.request ( psduLength((<=127, msdu length)), psdu(set of octets) ) 

    → MAC to PHY

Note: Sent Association request.

  1. PD-DATA.confirm (SUCCESS)
        → PHY to MAC

  1. PLME-SET-TRX-STATE.request (RX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

Note: Wait for macAckWaitDuration, and receive the Acknowledgment.

  1. PD-DATA.indication ( psduLength(<=127, msdu length) psdu(set of octets), 0 x 00 to 0x ff(ppduLinkQuality) )

        PHY to MAC

Note: Wait for aResponseWaitTime.

  1. PD-DATA.request ( psduLength((<=127, msdu length)), psdu(set of octets) )
        → MAC to PHY

Note: Sent Data request.

  1. PD-DATA.confirm (SUCCESS)
        → PHY to MAC

  1. PLME-SET-TRX-STATE.request (RX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

Note: Wait for macAckWaitDuration, and receive the Acknowledgment.

  1. PD-DATA.indication ( psduLength(<=127, msdu length) psdu(set of octets), 0 x 00 to 0x ff(ppduLinkQuality) )

        PHY to MAC

Note: Receive Association response.

  1. PD-DATA.indication ( psduLength(<=127, msdu length) psdu(set of octets), 0 x 00 to 0x ff(ppduLinkQuality) )

        PHY to MAC

  1. PLME-SET-TRX-STATE.request (TX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. PD-DATA.request ( psduLength((<=127, msdu length)), psdu(set of octets) )
        → MAC to PHY

Note: Sent Acknowledgment.

  1. PD-DATA.confirm (SUCCESS)
        → PHY to MAC

  1. PLME-SET-TRX-STATE.request (TRX_OFF)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. MLME-ASSOCIATE.confirm ( 0 x 00000 x ffff(Short address for device), SUCCESS(Status if association))

       → MAC to Higher layer.

Zigbee standard message sequence while a Co-ordinator starts



Coordinator Starting

  1. MLME-RESET.request ( true/false (SetDefaultPIB) )
        → Upper layer to MAC

  1. PLME-SET-TRX-STATE.request (TRX_OFF)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. MLME-RESET.confirm (SUCCESS)
        → MAC to Higher layer

  1. MLME-SCAN.request( 0 x 00(ScanType, ED), 32-bit field(ScanChannels),     0 to 14(ScanDuration) )
        Higher layer to MAC.

  1. PLME-SET-TRX-STATE.request (RX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. PLME-SET.request ( 0 x 00(PIBAttribute Identifier-phyCurrentChannel), firstchannel(0 to 26) )
        → MAC to PHY

  1. PLME-SET.confirm ( SUCCESS, 0 x 00(PIBAttribute Identifier-phyCurrentChannel) )

        → PHY to MAC

  1. PLME-ED.request ()
        → No parameter associated.
        → MAC to PHY.

  1. PLME-ED.confirm ( SUCCESS(status), 0 x 00–0 x ff(Energy level) )
        PHY to MAC.

Note: Energy detection done repeatedly for each channel for aBaseSuperframeDuration x (2n +1), where n is ScanDuration whose value < 14.


Note: Steps 8 to 11 done repeatedly to finish scanning of all channels specified in ScanChannels parameter of MLME-SCAN.request.
  1. PLME-SET-TRX-STATE.request (TRX_OFF)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. MLME-SCAN.confirm ( SUCCESS, 0 x 02(ScanType-Passive scan), 32-bit field(unscanned channels), ResultListSize(No. Of elements returned, 0 for orphan), 0 x 00 to 0x ff(List of energy measured, one for each channel), PANDescriptorList(Null for ED & Orphan) )

        → MAC to Higher level

Note: Select PANId, ShortAddress, Logical Channel.

  1. MLME-START.request ( 0 x 00000 x ffff (PANId) LogicalChannel, 0-15(BeaconOrder), 0-15(SuperframeOrder), True/False(PanCoordinator), True/False(BatteryLifeExtension), True/False(CoordRealignment), True/False(SecurityEnable) )

        Higher layer to MAC

  1. PLME-SET-TRX-STATE.request (TX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
        → PHY to MAC

  1. PD-DATA.request ( psduLength((<=127, msdu length)), psdu(set of octets) )
        → MAC to PHY

Note: Sent Beacon.

  1. PD-DATA.confirm (SUCCESS)
        → PHY to MAC


  1. MLME-START.confirm (SUCCESS)
        → MAC to Higher layer

  1. PLME-SET-TRX-STATE.request (RX_ON)
        → MAC to PHY

  1. PLME-SET-TRX-STATE.confirm (SUCCESS)
         → PHY to MAC

Install Asterisk in Debian based systems like Ubuntu, BOSS linux, etc.

Asterisk installation steps

It is recommended to use the most recent version of Asterisk, Dahdi and libpri for the best result.

  • Libpri

    • wget http://downloads.digium.com/pub/telephony/ libpri/libpri-X.X.current.tar.gz

    • tar -zxvf libpri-X.X-current.tar.gz

    • cd libpri-X.X.X/

    • make clean

    • make install

  • DAHDI

    • wget http://downloads.digium.com/pub/telephony/ dahdi-linux-complete/dahdi-linux-complete- current.tar.gz

    • tar -zxvf dahdi-linux-complete-current.tar.gz

    • cd dahdi-linux-complete-X.X.X+X.X.X

    • make all

    • make install

    • make config

  • Asterisk

    • wget http://downloads.digium.com/pub/telephony/ asterisk/asterisk-X.X-current.tar.gz

    • tar -zxvf asterisk-X.X-current.tar.gz

    • cd asterisk-X.X.X/

    • ./configure

    • make menuconfig

    • make

    • make install

    • make samples

    • make config

Asterisk Files and Directories

After proper installation asterisk files can be seen in following locations.

  • /usr/sbin/asterisk

    • The Asterisk binary.

  • /etc/asterisk

    • Asterisk configuration files.

  • /usr/lib/asterisk/modules/

    • Loadable modules for applications, codecs etc.

  • /var/lib/asterisk/sounds/

    • Asterisk sound prompts.

  • /var/lib/asterisk/moh

    • Hold music

  • /var/spool/asterisk/

    • Call information, Voicemail and User greetings.

  • /var/log/asterisk

    • Asterisk logs

  • /var/log/asterisk/cdr-csv

    • Call detail records


Starting Asterisk

After installing asterisk use the following commands for starting and stopping and restarting the application.

  • /usr/sbin/asterisk

    • Run asterisk as a daemon from command prompt.

  • /etc/init.d/asterisk stop

    • Stop asterisk from command prompt

  • /etc/init.d/asterisk restart

    • Restart asterisk from command prompt

Asterisk CLI

Following is the command to connect to asterisk's CLI and some common CLI commands.

  • asterisk -vvvr

    • Connect to asterisk CLI while asterisk is running.

  • core stop now

    • CLI command to stop asterisk.

  • core set verbose 5

    • Set verbose level in CLI

  • core set debug 5

    • Set debug level in CLI


Adding a phone to Asterisk

Edit the channel configuration fie for the phone type used.

  • SIP based VoIP phone

    • configure /etc/asterisk/sip.conf

  • Analog phone

    • configure connected analog line in /etc/asterisk/chan_dahdi.conf

    • configure connected analog hardware in /etc/dahdi/system.conf


Adding SIP phone

Add following configuration to /etc/asterisk/sip.conf

[name] ; Account name

type=friend ; Account type

host=dynamic ; How to register

context=users ; Context name

secret=secret ;Account password


Next add extension to /etc/asterisk/extensions.conf under users contextwhich directs calls to new phone.

Exten => 500,1,Dial(SIP/name,30) ;Ring cdac for 30 seconds


Next configure the soft phone or the IP phone with same settings and register it with the asterisk server.



Configuring DAHDI and Asterisk for Analog and PRI calls

Two configuration files needed to be changed for getting Analog and Digital cards working with Asterisk.

  • /etc/dahdi/system.conf

    • Analog and Digital cards configuration are done in system.conf. Configuration can be entered manually or can be generated automatically by giving the command “dahdi_genconf -v” in command prompt.

    • Sample code is given below:

span=2,1,0,ccs,hdb3 # Configure to E1 span

bchan=5-19,21-35 # Define Bearer channels

dchan=20 # Define Delta channel

fxoks=1 # FXO signalling for FXS

fxsks=4 # FXS signalling for FXO

echocanceller=mg2,5-19,21-35 ,1,4


  • /etc/asterisk/chan_dahdi.conf

    • Configure the chan_dahdi.conf so that asterisk knows how to use the hardware and the features associated with the channels.

    • Sample code is given below:

group=1 ; FXS port uses FXO signalling

context=users

signalling=fxo_ks

channel => 1

group=2 ; FXO port uses FXS signalling

context=from_outside

signalling=fxs_ks

channel=>4

group=3 ; B-channel in chan_dahdi.conf

echocancel = yes

signalling = pri_cpe

switchtype = euroisdn

context = incoming

channel = 5-19,21-35


Save the configuration files and restart Asterisk for the changes to DAHDI will get affected. For using the analog line alter the extension to send the calls to this phone using the DAHDI line group 1 “DAHDI/g1”. For sending out calls on the analog line alter the dial plan using the DAHDI line group 2 “DAHDI/g2”.

For E1 connection make sure that the link is out of alarm. Use the command line tool dahdi_tool to check E1 card is out of alarms. Once the PRI is up and looking good, alter the dialplan so that the calls are sent across E1 line.

Friday, March 9, 2012

Enable Flashplayer Mozilla Firefox for Debian based system

1. Download proper flash player package (APT for Ubuntu 10.04+) from "http://get.adobe.com/flashplayer/"

2. Extract the the downloaded packege.

3. Copy and paste extracted libflashplayer.so file to /usr/lib/mozilla/plugins

4. Restart the browser.

5. Enjoy.

Thursday, March 8, 2012

Install Tiny OS in Ubuntu 11.10 from Ubuntu repository

These configurations are done for tiny os to work with Telosb mote.

1. Need to install java first. Follow the following steps.
    (a) Login as Root.
      sudo -i
    (b) Install "python-software-properties" package.
      apt-get install python-software-properties
    (c) Add proper Repo for Java package.
      add-apt-repository ppa:ferramroberto/java
    (d) Now install java packages.
      apt-get install sun-java6-jdk sun-java6-plugin

2. Add tiny os repo to your sourcelist.
      gedit /etc/apt/sources.list

3. Add following to your sourcelist.
      deb http://tinyos.stanford.edu/tinyos/dists/ubuntu hardy main
      deb http://hinrg.cs.jhu.edu/tinyos oneiric main

4. Give update.
      apt-get update

5. Install tiny os from the added repo.
      apt-get install tinyos-2.1.0

6. Edit your bashrc file for setting up tiny os environment after booting.
      (a) gedit ~/.bashrc

      (b) Add following line to bottom of the .bashrc file.
             source /opt/tinyos-2.1.0/tinyos.sh
             export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.

7. Save bashrc file.
      source ~/.bashrc

8. Run this command to avoid error with java.
      tos-install-jni

9. Install g++ to avoid some error.
      apt-get install g++

10. Now you can run your first tiny os Blink program.
        (a) cd /opt/tinyos-2.1.0/apps/Blink
        (b) make telosb

11. Enjoy


Possible Errors

Note: These are all the errors i faced while running Tiny OS in Ubuntu 11.10.

1. While running "java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSB0:telosb" you may get the following error.

The toscomm JNI library was not found. check that your tiny-os package is installed and try rerunning tos-install-jni

Can solve this by the following method.

  (a) Open the bashrc file.
          vim ~/.bashrc
  (b) Add path for the jre binaries.
       Add this line at the bottom most part of bashrc file with out double quotes.
         "export PATH=/usr/lib/jvm/java-6-sun/jre/bin:$PATH"
  (c) Run this command.
         "tos-install-jni"
  (d) Enjoy.

2. Error due to java, while running the java command for serial communication.

      Eg:
             java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb

      Exception in thread "main" java.lang.NoClassDefFoundError: net/tinyos/tools/Listen
Caused by: java.lang.ClassNotFoundException: net.tinyos.tools.Listen
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: net.tinyos.tools.Listen.  Program will exit.

  (a) Download "java" tar file from the Tiny OS CVS repository: http://tinyos.cvs.sourceforge.net/viewvc/tinyos/tinyos-2.x/support/sdk/java/
  (b) Untar and keep it in /opt/tinyos-2.1.0/support/sdk instead of existing java folder there.
  (c) Go inside the java folder in terminal and give "make" command.
  (d) Enjoy.

How to Install sun-java6-jdk in Ubuntu 11.10, Ubuntu 10.04 LTS

1. Login as Root.

      sudo -i

2. Install "python-software-properties" package.

      apt-get install python-software-properties

3. Add proper Repo for Java package.

      Log out from the current terminal and open a new one.

      add-apt-repository ppa:ferramroberto/java

4. Update your local package index.

      apt-get update

5. Now install java packages.

      apt-get install sun-java6-jdk sun-java6-plugin

5. Now enjoy.


Possible Errors

1. Error while giving command  "add-apt-repository ppa:ferramroberto/java"

      Traceback (most recent call last):
      File "/usr/bin/add-apt-repository", line 88, in
      ppa_info = get_ppa_info_from_lp(user, ppa_name)
      File "/usr/lib/python2.7/dist-packages/softwareproperties/ppa.py", line 80, in  get_ppa_info_from_lp
      curl.perform()
      pycurl.error: (7, "couldn't connect to host")


  Solution: Have to Open a new terminal after installation of "python-software-properties", before giving the next command.

2. Error while giving command  "add-apt-repository ppa:ferramroberto/java"


Error reading https://launchpad.net/api/1.0/~ferramroberto/+archive/java: couldn't connect to host

Solution: I solved this by giving the command after logging in terminal as root.

              1. sudo -i
              2. add-apt-repository ppa:ferramroberto/java