Sunday, January 30, 2011

Remove envelope icon from Indicator Applet

The envelope icon in Indicator Applet really annoys me. It unnecessarily increases the number of clicks needed to open an application like Empathy or Pidgin. To remove that icon uninstall the indicator-messages package using following command:
sudo apt-get remove indicator-messages
This makes that envelope icon disappear and applications start appearing in Notification Area.

Wednesday, January 19, 2011

Limit Internet Bandwidth Usage (internet speed) in Ubuntu

There are many reasons one would want to limit internet bandwidth/speed on a system e.g you dont want your siblings to choke your internet or, if you are a network admin, you dont want one user, downloading a big movie over torrent, to hurt every one else's surfing.

To limit internet bandwidth on a Ubuntu machine install wondershaper. For this open a terminal and type following command:
sudo apt-get install wondershaper
Now use ifconfig command to find out the name of interface connected to internet. The name will be something like eth0, eth1, wlan0 or something similar. In my case it is eth0


Now issue a command similar to follwoing (relpacing eth0 with your interface name):
sudo wondershaper eth0 1024 256
this will limit the download speed to 1024 Kbps and upload to 256 Kbps. Remember that this limit is for all internet traffic i.e torrent, ftp, browsing and any thing else.

If you want to remove these limits use
sudo wondershaper clear eth0
again replacing eth0 with your interface name

Using LD, the GNU Linker, to create a relocatable section of code or data

Relocatable sections are used when you cant load a section of code/data directly where you want. This may be for many reasons for example the memory where the code is supposed to go needs to be initialized first as is the case in ROM images.

For a relocatable section you need two addresses:
1. Relocation Address
2. Load Address

Relocation Address is the address for which the section is linked. Whereas Load Address is the address where the section will get loaded. Confusing? Lets try an example:

Consider an embedded system with 64MB ROM memory mapped at address 0x1E000000 and 256 MB DRAM mapped at 0x00000000. Your code will reside in ROM but when the system starts, it will copy it self from ROM into DRAM and continue execution from there.

To create a relocatable section we use AT keyword in section definition as follows
section_name startaddr : AT( loadaddr)
{
    /*section contents*/
    ...
}
 This will create a section which is linked for address startaddr but which is loaded in memory at loadaddr. Going back to above example embedded system, you will need at least two sections, one will contain the actual code and the other will contain the relocation/copying logic. This is required because the code for copying will get executed from ROM, so it needs to be linked for that address. So the GNU ld script will look something like following:

.init 0x1E000000 :
{
    *(.init)
}
.text 0x00000000 : AT ( ADDR(.init) + SIZEOF(.init) )
{
    *(.text)
}
the expression ADDR(.init) + SIZEOF(.init) will give us the address of first byte just after .init section. So .text section will get loaded just after the .init section. Upon reset, the code in .init section will copy the text section to DRAM i.e address 0x00000000 and pass control to it.