Wednesday, December 22, 2010

Reordering latex bibliography citation in the order of usage or appearance in text

Use the IEEEtran bst file as the bibliography style file to achieve this. This can be done by using the following command:


before calling the \bibliography{} directive.

Also remember that you will need to re-create the .aux file by running latex (with the above command in place), and then run the bibtex command if you are changing from a previous bibliography style like abbrv. The changes will be visible when you run latex again after you have done the previous step. Also, make sure the latex directory contains the bibliography style file.

Sunday, December 5, 2010

Salient features of the BGP routing protocol

* Border gateway protocol - as the name implies it is a protocol used among gateway nodes of the ASs

* Focuses on reachability (loop free) rather than optimality. - why? - it is hard to come across a single routing metric since transit ASs have different internal routing protocols and routing metrics.

* Trust is important in BGP - because it relies solely on route advertisements from peers

* Does not fall into distance vector or link state routing - advertizes complete path as a list of ASs

* Looping within BGP is avoided by advertising complete path AS prefixes - if an AS already sees itself in the list, it determines that the path is no longer useful.

Monday, October 25, 2010

What is a bit - meter in communications

A bit-meter/sec is a popular metric used in determining the performance of communications systems. A bit meter/sec literally, is measured as the product of the speed (in bps) and
the distance of the mobile user from the transmitter (in meters) at which this speed
can be achieved.

The higher the sum of bit-meters/sec for all the users in the system, the better is the
performance of the mobile system.

Wednesday, October 20, 2010

Zeno's Paradox - and its implication on graduation (if any)

As a graduate student, I am really hoping that Zeno's paradox of the tortoise and achilles does not hold true. As per the greek philosopher Zeno, if a tortoise and Achilles are in a race, where the proud achilles gives the tortoise a head start in a race, when the Achilles is covering up the lead given to the tortoise, the tortoise must have already moved some distance. And, when Achilles is making up that lead, the tortoise has moved even further. This is his paradox. Imagine a graduate student working towards his thesis, when her advisor agrees that she has finished half of the work for her thesis, the advisor always adds another small amount. Again when the student finishes that lead, there is always another small addition. Hopefully, this ends... and the student graduates at some time!

Saturday, October 16, 2010

Finally, a wordle cloud for the site

Wednesday, October 13, 2010

How to log into multiple gmail/gtalk accounts using google talk

This is a simple solution based on what I learned online. The idea is to basically start multiple instances of the google talk client without having each of those instances use mutexes. This allows the applications to co-exist without any problems. These applications can be started by creating a common gtalk startup shortcut with the switch nomutex:
"c:\path_to_google_talk_app\googletalk.exe" /nomutex
For example, in my case I have used the following path:
"c:\program files\google\googletalk.exe" /nomutex
This is the link that should be posted in the shortcut execution path created on windows. Please google more on how to create a short cut if not known already.

Monday, September 6, 2010

Disable carrier sense in 802.11 madwifi drivers

qi.tqi_qflags |= HAL_TXQ_BACKOFF_DISABLE;
to the file: ath/if_ath.c in the function: ath_txq_setup()

Connect router to ADSL modem router

I have a connection coming in through an ADSL2 connection which goes to a box that works as the modem + the wireless router. I wanted to connect a more powerful linksys wireless router and use it instead for getting the wireless connectivity.

Here is what I did: I converted the linksys wireless router to a wireless switch.

The way I did it:

---adsl2 ---> adsl2modem+router box --> linksys box --> wireless out

To convert the wireless router to a switch, I put the wireless router on the same IP subnet as the adsl2modem+router box by using a random IP in that subnet. Then I disabled DHCP and if possible one should also disable NATing. This ensures that all clients associating with the linksys box will be eventually asking DHCP from the adsl2modem+router box and everything works like a charm :)

Friday, August 6, 2010

Increasing display brightness of Samsung NC10 Ubuntu

Display brightness can be easily controlled by using the setpci command. The setpci command basically controls the display device whose address can be found using the lspci command. In case of the NC10 the command looks like:

sudo setpci -s 00:02.1 f4.b=FF

In this case, 00:02.1 is the address of the Intel display adapter, and we further set brightness to maximum value by using FF. Minimum value is 00. Hence the range is all intermediate values from 00 to FF. f4 is the address of the register, and the .b possibly signifies a byte.

Exceeding the speed of light - possible or not

May or may not be possible. However, one thing is pretty clear from the space time diagrams is that the cause-effect relationship of things can be violated if this limit is exceeded.

Tuesday, July 6, 2010

Possible answers to building Machu Picchu

Why a location at the top of the mountains, actually on a ridge between mountains?
- Surrounded by two rivers, in the center of 4 mountains corresponding to 4 directions, all of which are worshiped as gods by the Incas

When was it built?
- 1450ish - ordered by their king. Mostly as a religious resort.

How was it built?
- Stone cut by stone. Special layering of soil to absorb and channelize water.

Why did the Spanish not destroy it?
- Was abandoned by the Incas and probably missed by the spanish.

Saturday, July 3, 2010

How to check shared libraries used by an application and add news ones?

To check which libraries are used, use the ldd command. ldd prints the shared libraries required by each program or shared library specified on the command line.

ldd /path/to/file

To add new library files, use ldconfig. "ldconfig creates, updates, and removes the necessary links and cache (for use by the run-time linker, to the most recent shared libraries found in the directories specified on the command line, in the file /etc/, and in the trusted directories (/usr/lib and /lib). ldconfig checks the header and file names of the libraries it encounters when determining which versions should have their links updated. ldconfig ignores symbolic links when scanning for libraries."

After adding new libraries (.so) files to /usr/lib, run sudo ldconfig and that should do it.
Check if the newly added files are used by your binaries by running ldd.

An example output:
[dummy-linux ~]$ ldd /bin/ls =>  (0x00007fff005ff000) => /lib64/ (0x0000003538800000) => /lib64/ (0x0000003538000000) => /lib64/ (0x000000353ac00000) => /lib64/ (0x0000003545800000) => /lib64/ (0x0000003537000000) => /lib64/ (0x0000003537400000)
        /lib64/ (0x0000003536800000) => /lib64/ (0x0000003537800000) => /lib64/ (0x0000003545000000)

Saturday, June 5, 2010

Latex fancyhdr does not print the header/footer

Make sure that :
is present after the last usepackage tag. The following the begin{document} tag use the following code:
\pagestyle{fancy} %\thispagestyle{fancy}
\fancyhead{\textbf{--- This is a draft ---}}
The most important part is to remember that this code should be placed after the begin{document} tag, else the header will not print. The code mentioned above can be customized to make sure the header is printed as per custom requirements.

Thursday, June 3, 2010

How to enable debugging in the Madwifi HAL

This could prove useful in tracing order of the control flow in the Madwifi code. This flag can be enabled by setting
make HAL_DEBUG=1

Thursday, May 13, 2010

Escape character \& Ampersand in ruby wget call fails

This is because ruby is not built to handle a bash escape with the ampersands in them. The correct way to solve this problem is by using the open-uri library supported by ruby.

An example is as shown here:
require 'open-uri'

Monday, May 10, 2010

How to enable packages like Wifi in click modular router

Special features which have custom elements like wifi, analysis, ethernet, ip6, ipsec, and radio are not included in the default compiled click modular router. They are called as groups and need to be explicity enabled during compilation by using:
./configure –enable-groupname

./configure –enable-wifi

Thursday, May 6, 2010

Packets Generated In Click router Improper

If on sniffing packets generated by click, you notice something like that shown in the trace below, a clear inference is that the IP packets are not being generated correctly:

03:08:38.841420 IP0 [|ip]
03:08:38.842393 IP0 [|ip]
03:08:38.842398 IP0 [|ip]
03:08:38.843370 IP0 [|ip]
03:08:38.843375 IP0 [|ip]
03:08:38.844345 IP0 [|ip]
03:08:38.844350 IP0 [|ip]
03:08:38.845322 IP0 [|ip]
03:08:38.845327 IP0 [|ip]
03:08:38.846299 IP0 [|ip]
03:08:38.846304 IP0 [|ip]
03:08:38.847277 IP0 [|ip]
This trace actually implies that you used IPEncap to generate and ipip packet instead of a plain ip packet.

Instead, if you see a trace like the one below:
03:11:46.080628 IP5 bad-hlen 8
03:11:46.080634 IP5 bad-hlen 8
03:11:46.080639 IP5 bad-hlen 8
03:11:46.080645 IP5 bad-hlen 8
03:11:46.080650 IP5 bad-hlen 8
03:11:46.080656 IP5 bad-hlen 8
03:11:46.080661 IP5 bad-hlen 8
It means that you are not appropriately generating an IP header. The standard IP header is 20 bytes, where as your packets have an IP header of 8 bytes only. The solution to this problem is to ensure that you generate a proper IP header by using the UDPIPEncap element.

Monday, April 26, 2010

How to check which matlab toolboxes are installed

To check if a particular toolbox or a set of toolboxes are installed on your machine type the 'ver' command at the MATLAB prompt. This should describe the version of your MATLAB software followed by an alphabetical sequence of the toolboxes installed.

Sunday, April 25, 2010

The earth's magnetic field

  • Is produced due to the motion in the Earth's molten iron core.
  • Protects the earth by repelling charged particles emitted by the sun called as the solar winds. These particles trapped in the atmosphere and dragged towards the poles are seen as northern and southern lights. A nice illustration of this concept is shown here:
  • It also protects us from the particles ejected through explosions in space.
  • However, the earth's field is now decreasing - was seen from studying Mars which does not have a magnetic field any more. Though it did have one at some point.

Wednesday, April 21, 2010

What are active networks?

Radical design paradigm which advocates carrying programs
+ data as part of a packet. Routers are said to be active
in such a network since, each of the routers will be executing
the code in the packets instead of just forwarding or routing
them as in a conventional network. The routers should support
secure execution of code without which the entire infrastructure
could fail. Techniques have been provided for securely fingreprinting
the code to prevent spoofing and malicious code execution.

Largely not adapted in the real networks due to the huge change in

Tuesday, April 20, 2010

Summary on Supermassive black holes

  1. They are the largest form of black holes found in the universe.
  2. Super massive black holes (SBHs) were first believed to be present because of bright quasars observed in the center of active galaxies (the ones which had not cooled down yet). Since the black hole cannot be seen (due to its ability of not even letting light out of its gravitational pull), scientist looked for the signs of their gravitational pulls to detect their presence. It seemed that they were at the center of active galaxies initially. Instead they found the first supermassive black hole in the andromeda galaxy which is very much dormant and closest to earth.
  3. This was followed by subsequent discoveries by the hubble and other telescopes that black holes were present in almost all galaxies including our very own Milky way!
  4. They also found that the mass of the SBH is directly proportional to the size of the galaxy and also proportional to the speed at which stars were moving at the edge of the galaxy.
  5. This helped them link SBHs to the origin of galaxies.
  6. The SBH at the center of our galaxy is far off and is relatively small and somewhat dormant. Hence we should not be technically affected by the SBH.
  7. Instead we might be affected by the collision of our milky way with the andromeda galaxy which is moving at us with a great speed. The impact is expected to happen in a few billion years.

Saturday, April 17, 2010

Configuring a KVM guest to support multiple interfaces

As part of an experiment we were trying to configure
a single KVM virtual machine to have multiple interfaces
with each interface being on a different (IP) network.

We also needed to do this without bridging i.e. we did not
want to bridge the vnet devices coming out of the virtual
machines directly with the outside interfaces.

KVM has a concept of networks, which are essentially bridges
on some definite IP networks. The networks configured for
your ubuntu KVM setup can be checked by logging into the
virsh viewer and using the command:

virsh: net-list --all

A new network can be created by replicating and editing the XML
configuration for a network. The location for the default.xml
network definition is here: /etc/libvirt/qemu/networks/

To create a new network we will make a copy of this xml file in
the home directory (or any other path for that matter).

$> cp /etc/libvirt/qemu/networks/default.xml mynetwork.xml

Edit the mynetwork.xml file to define your new network. You can
read this new network configuration into the setup by invoking virsh
and using the net-define /path-to/mynetwork.xml command.

This network can be made to auto-start at the begininng by using the
appropriate net-autostart option in virsh. You can verify this network
by checking with the virsh net-list --all command.

Finally, you can add another interface to the KVM virtual machine instance
by editing the XML definition of the guest which is present
at: /etc/libvirt/qemu/domain.xml where domain is the name of your vm instance.

The network section can be edited to have two network interfaces as:

<interface type='network'>
<mac address='52:54:22:2a:26:33'/>
<source network='default'/>
<interface type='network'>
<mac address='52:54:00:2a:26:25'/>
<source network='mynetwork'/>

Note that the mac addresses need to be different and unique.
This definition can be read into the system by using the virsh
define domain.xml command.

Doing this should setup everything and get things running.

Script for generating a random MAC address

MACADDR="52:54:$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4/')"; echo $MACADDR

One line shell script to generate a random MAC address starting
with "52:54:". This can be changed to anything by editing the script.

Sunday, April 11, 2010

Why is stdio.h and stdlib.h not found while compiling Madwifi

It is because these both are user space libraries,
and ath_pci the end product of the driver is a kernel
module. In fact is it a set of kernel modules.

Hence the failure.

Thursday, April 8, 2010

Streaming an mpg video using vlc and saving it as an mpg at the receiver

vlc does not run as a root. So u need to login as a user

Streaming out the mpg file:
vlc supman17.mpg -I dummy --sout udp://

The other problem is this account does not have all the access, so it cannot create a file. So create one file by name of stream.mpg and grant permissions.
Receiving the incoming stream and saving as an mpg file:

touch stream.mpg
chmod 777 stream.mpg
vlc udp://@:9081 --sout file/muxer:stream.mpg

Monday, April 5, 2010

Replicating a KVM instance

virt-clone --connect qemu:///system --original vm4 --name vm5 --file

Where, vm4 is the name of the old KVM instance
and vm5 is the name of the desired duplicate instance.

Tuesday, March 30, 2010

Latex: file ended while scanning use of citex

The main cause is because you did not use a proper closing
brace for the argument. You will also typically see something
that talks about a runaway argument. This problem can be also
because you used a closing bracket, but of the incorrect type.
E.g. round braces instead of curly ones.

Putting the correct closing brace should solve the problem.

Monday, March 29, 2010

Dynamically changing channel or frequency hopping in madwifi

Can be implemented in two ways:

1. Using the function ath_set_channel()
This will allow you to change the channel from within the driver,
based on certain conditions. However, this will also reset the driver.

2. A simple iwconfig.
$> iwconfig ath0 channel X
where, X could be a channel number like 36.

Thursday, March 25, 2010

Linux drivers for Beceem WiMAX Chipset

It is a well known and tested fact that the Beceem
chipset for WiMAX connectivity works fine with
Windows machines. However, lately, when I tried
to get it working on a linux - Ubuntu platform
I ran into issues. As soon as I am inserting the
dongle, the machine carshes. I am using ubuntu
which has built in WiMAX drivers.

I also tried performance with the Intel 5150
chipset. However, I observed that the rate
(modulation and coding scheme - MCS) chosen
by the basestation transceiver to reach the
client fluctuated rapidly. On doing a check
I noticed that this condition persisted when
using a Windows platform. Though I am able to
get connectivity, the link does not stabalize
even when the client is immobile.

Sunday, March 21, 2010

Location of VM Instance description for KVM Guests


Friday, March 19, 2010

Shell script fo enable Nating for virtual machine (KVM)

Please copy and paste this script in a file and execute.

echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o $ext -j MASQUERADE
/sbin/iptables -A FORWARD -i $ext -o $int -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i $int -o $ext -j ACCEPT

The script can be invoked as:

scriptname vnet0 eth1

where vnet0 will be your internal interface, and eth1 is your outbound interface.

Shell script to create KVM - Ubuntu instance

Please copy and paste the following in a shell
script and execute the file from command line:

ubuntu-vm-builder kvm hardy --domain vm-gdb --dest vm-gdb --arch i386 --hostname vm-gdb --mem 256 --user user --pass user --ip --mirror --components main,universe --addpkg vim --addpkg openssh-server --libvirt qemu:///system --addpkg iperf --addpkg gcc --addpkg g++

Default location/path for apt package download debian


Wednesday, March 10, 2010

Difference between hardware and software RAID

RAID stands for redundant array of inexpensive disks.
RAID can be done either in hardware or software.

For computing machines such as desktops or servers,
hardware RAID is possible if the BIOS of the machine
supports a RAID option.

Alternatively, software RAID is possible if the operating
system supports RAID. Example, Ubuntu 9.04 and upwards
support software RAID options. These options are made
available when the user is setting up the operating

Monday, March 8, 2010

Starting a background bash process in Ruby

Consider this example, I want to execute my C++ code
which runs an infinite loop in the background through
my Ruby code.

The code is just a single line: { `./a.out myarg` }

Thursday, March 4, 2010

Which files in the madwifi driver are executed by the iwpriv command?

The file ieee80211_wireless.c has all the logic for executing the iwpriv commands.
Information is included for controlling all private ioctl calls such as setting turbo mode
in the driver.

Sunday, February 28, 2010

Vintage / antique computer media

Buy vintage floppy drive for cheap (under $6) and
shipped for free on ebay Click here!!

Wednesday, February 17, 2010

Opening a Server at the next available free port

And also getting the port number back!
server = '', 0
port = server.addr[1]

(courtesy of stackoverflow / Aaron Hinni).

Matlab simultaneous assignment through deal

% Same as a = x, b = y, c = z:
[a, b, c] = deal(x, y, z);

Make any page editable with one line of code

Enter this in the browser address bar after opening the
page on which you want to test this:

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

Latex One liner to mark an error in the text

Here it is. I got it from Jacob Mattingley's website
at the Stanford University.


Thursday, February 4, 2010

[Ruby] Difference between NaN and Infinity

I am not sure if this is limited to ruby,
but came across a sweet data type that ruby
maintains when some sort of "wrong" operation
is encountered.

Infinity: Is the typical value, when a number
is divided by zero or a very small number (close
to zero).

NaN: Not a number is Ruby's way of saying that
zero was divided by a zero ==> resulting
in an undefined result which is indicated
by the NaN. Unfortunately, I am not sure if
Ruby has support for testing if a variable has
NaN value.

Difference between .dup and .clone in ruby objects

Being a newbie to Ruby I was confused when I had
to deal with the task of producing an object copy.
I came across this very nice post on a mailing
list which helped me understand the difference.

The crux here is:
Clone copies the entire object as is, including the
any state information the object may contain. While
the duplicate call (.dup) does not copy all of the
state while copying the basic data.

The simplest example which shows the difference is as

obj1 = []
obj2 = obj1.clone
obj3 = obj1.dup
p obj1.frozen?, obj2.frozen?, obj3.frozen?
# => true, true, false

Monday, February 1, 2010

What is the stationary time of a mobile wireless channel?

A mobile wireless channel is typically characterised
by a large amount of variation, among other things
due to multipath fading. The stationary time of a
channel can be defined as the time for which the
channel characteristics remain the same for the
given duration. Some studies have shown that the
stationarity of a V2V channel can vary from a couple
of milliseconds to a full second.

Please refer scientific literature for more accurate
information on this topic.

Wednesday, January 20, 2010

Why male species of some animals are more attractive?

This is seen typically with the peacock.
It seems scientists have linked it with
the number of mates chosen by the gender
of that species. Species where the males
are polygamus tend to be more attractive
as compared to their monogamus partners
which are responsible for taking care of
the kids.

Hmmm.. interesting observations. More
details are in an article in the Nature
science journal.

Sunday, January 3, 2010

List push_back() function causes a crash

Most people while working with list iterators
are sure to have come across this problem
when working in C++ at some point in their lives.

Program crashes abruptly.

Debugging using the gdb debugger shows that
the crash occurs while executing the push_back()
function. I was using the Devshed C++ development
environment and noticing similar crashes with my
code. However, it turns out the problem did not have
anything to do with push_back() function. Rather,
it was happening because, appropriate memory management
was not being done for other allocated memory structs.
Typically, re-assignment of pointers which were not
appropriately free()'d before re-initialization was
resulting in these crashes. So as such push_back() is
not crashing but other poor memory management was
responsible. Please also check that you are not passing
a NULL as an argument for push_back(), which could
possibly cause a crash.

free() causes C++ program to crash

The free() function is used as a means for
explicitly telling the C++ compiler to delete
the memory allocated to the pointer passed
as an argument in the free() function.

A typical type of crash can occur if
free() is called on a pointer to which
memory is not allocated or when the pointer
is not initialized. In this case, the pointer
points to an invalid memory location resulting
in a fatal error when trying to free memory
allocated at that location.

To remedy this problem, please verify if the
pointer is being correctly initialized by putting
appropriate checks.