Pages

Wednesday, February 18, 2015

IEEE frames

There are three types of frames defined by IEEE.

1. IEEE 802.3: This is the standard ethernet type defined by IEEE also called Ethernet II or standard ethernet. The main difference from other type of frame is that it has a two byte ether type field which identifies the higher layer protocol data present in the payload field.


The figure below shows the different ether type and the protocol represented by it.
It is interesting to note that the ether type field values are greater than 0x0600(1536 decimal). This is because if the value is less than 0x0600, it represents the length of the payload. If it is greather than or equal to 0x0600, it represents the ether type.


2. IEEE 802.3 wih SNAP:

Some upper layer protocols does not have a ether type. To recognize such protocols, the standard ethernet is modified. To accomodate such protocols, SNAP was defined which is an extension of  the IEEE 802.2 Logical Link Control (LLC) to distinguish much more protocols of the higher layer than using of the 8-bit Service Access Point fields (LSAP) present in the IEEE 802.2 header.



The 5-octet SNAP header follows the 802.2 LLC Header if the DSAP and SSAP contains hexadecimal values of AA or AB.

The SNAP header consists of a 3-octet IEEE Organizationally Unique Identifier (OUI) followed by a 2-octet protocol ID. If the OUI is hexadecimal 000000, the protocol ID is the Ethernet type (EtherType) field value for the protocol running on top of SNAP; if the OUI is an OUI for a particular organization, the protocol ID is a value assigned by that organization to the protocol running on top of SNAP.

"Why is a separate sub-network header necessary?" 
                - Source Wikipedia(http://en.wikipedia.org/wiki/Subnetwork_Access_Protocol)

 The answer is that it was to augment a decision that was made during the layout of the LLC header. At the time that the LLC header was being designed it was thought that a single octet (256 possible values) in the header would be enough to specify all the protocol values that vendors would want to register. As the values began to be reserved, it was discovered that the LLC header would soon run out of open values. The hexadecimal AA and AB values were reserved, and an additional header—the SNAP header—was developed; it can support all EtherType values, as well as multiple spaces of private protocol values.

3. IEEE 802.3 wih 802.2 LLC Header:

The purpose of the LLC header is to provide a "hole in the ceiling" of the Data Link Layer. By specifying into which memory buffer the adapter places the data frame, the LLC header allows the upper layers to know where to find the data.

DSAP: The DSAP, or Destination Service Access Point, is a 1 byte field that simply acts as a pointer to a memory buffer in the receiving station. It tells the receiving NIC in which buffer to put this information. This functionality is crucial in situations where users are running multiple protocol stacks, etc...

SSAP: The SSAP, or Source Service Access Point is analogous to the DSAP, and specifies the Source of the sending process.

The Control Byte: Following the SAPs is a one byte control field that specifies the type of LLC frame that this is.

Reference: http://www.wildpackets.com/resources/compendium/ethernet/frame_formats

Sunday, February 8, 2015

VIRTUALENV in Python

virtualenv is a tool to create isolated virtual environments or sandboxes. One project written 2.7 does not affect the other project written in 3.4. Both can reside on the same machine without creating conflict.

Installation commands in Ubuntu:

#Get the installation file
sandesh@sandesh:~$wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.7.tar.gz

#the virtualenv zipped file will be downloaded

sandesh@sandesh:~$tar -xvzf virtualenv-12.0.7.tar.gz
sandesh@sandesh:~$cd virtualenv-12.0.7

#install virtualenv
sandesh@sandesh:~/virtualenv-12.0.7$python virtualenv.py myenv

#a new folder called myenv will be created

Use virtualenv in Ubuntu:


# this runs the activate file inside the bin folder
sandesh@sandesh:~/virtualenv-12.0.7$source myenv/bin/activate

#myenv is the name of the virtual environment I created above.

#To install any package inside this virutal environment we execute the following command.
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$pip install django
Collecting django
  Using cached Django-1.7.4-py2.py3-none-any.whl
Installing collected packages: django

Successfully installed django-1.7.4

#we can check what packages are installed inside the virtualenv using following command.
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$ pip freeze
Django==1.7.4

#to get out of the virtualenv

(myenv)sandesh@sandesh:~/virtualenv-12.0.7$ deactivate

sandesh@sandesh-S400CA:~/virtualenv-12.0.7$