August 31, 2010

configuration of the testbed

# all the machines should be upgraded to ubuntu 10.04 #

PRE INSTALLATION
----------------
- note down the ip address of the eth0 interface

INSTALLING UBUNTU
-----------------
- use the 10.04 ISO image from the CD
- make sure the Fedora 4 partition is formatted and wiped out
- use the username: lili, password: interference-
    - for instance, if m/c name: ut-mesh-d-14.csres.utexas.edu; then password: interference-d14
                    if m/c name: ut-mesh-14.csres.utexas.edu; then password: interference-14


POST INSTALLATION
-----------------
A. Configuring the network interfaces
- /etc/resolv.conf: create this file if it doesn't exist and use the following entries
search public.utexas.edu
nameserver 128.83.139.9

- /etc/network/interfaces: add the entry

auto eth0
iface eth0 inet static
address
gateway 128.83.141.1
netmask 255.255.255.0
network 128.83.141.0
broadcast 128.83.141.255

- sudo service network-manager stop (kills the network manager service, we don't need it)

- sudo /etc/init.d/networking restart
  - try connecting to the internet, should work!

INSTALLING VIM, SSH and WIRESHARK
---------------------------------
- open the Administration->Synaptic Packet Manager. Click Reload. (updates the package manager). Close the package manager.
- sudo apt-get install ssh
- sudo apt-get install vim
- sudo apt-get install wireshark

ADD RSA key of the host machine to this remote machine
------------------------------------------------------
- generate rsa key on the host machine using
    ssh-keygen -t rsa1
- cat ~/.ssh/ >> ~/.ssh/authorized_keys@remote_machine
- chmod 600 ~/.ssh/authorized_keys@remote_machine

Update the SUDOERS file
-----------------------
- sudo visudo
-
User_Alias FULLTIMERS=lili
lili    ALL=NOPASSWD:ALL
FULLTIMERS ALL = NOPASSWD: ALL
 

Remove ath5k and install madwifi
-------------------------------
http://art.ubuntuforums.org/showthread.php?t=1163380

IMPORTANT
--------
Driver Bug: Do not try to perform channel switch in the master mode; causes a hard freeze (Ref: http://madwifi-project.org/ticket/1903)

July 14, 2010

python editor & IDE

留个印儿,待用。
vim
ulipad
eric
pydev
emacs
eclipse
netbeans

komodo
wingIDE
(the last two are commercial software)
douban

Learning to program is like learning to write good natural language. The best way to do it is to read some stuff written by masters of the form, write some things yourself, read a lot more, write a little more, read a lot more, write some more ... and repeat until your writing begins to develop the kind of strength and economy you see in your models.

ps.今天看到篇很棒的文章《How to become a hacker》。文章很长,分期分批的看吧,里面的路线图以及很多思想当真是值得借鉴的。豆瓣小组当真是个好地方=]

July 11, 2010

funny words

韩乔生老师最牛的一次解说

—7号球员夏普分球,传给了9号队员,9号队员也叫夏普,他们可能是兄弟。
—在足坛活跃着很多兄弟,比如荷兰的德波尔兄弟,爱尔兰的基恩兄弟(韩老师到底也没有纠正的错误,爱尔兰的两个基恩不是兄弟)。好球,这个球传给10号传得非常好。
—咦,10号怎么也叫夏普。可能是这样的,外国球员印在球衣上的只是姓,这些球员都姓夏普,就像韩国有很多球员都姓朴。漂亮,
—10号连过两名队员,破门得分,11号上前祝贺,11号是–夏普(停顿好大一会)对不起,观众朋友,夏普是印在球衣上赞助商的名字。

July 6, 2010

Associative container

pair类型,以及更为典型的map类型。既具有vector类型可以纵向联系某种特定数据类型的特点,又可以把两种不同数据类型但在应用中意义相关的数据横向联系起来。这种联系可以理解为“映射”,每个key和唯一的另一个数据类型存放地址相关。另一种理解方法,key值可以视为对应于其值value的一个指针或者是迭代器,只是这样的对应始终是一对一的。此外,map类型默认如果所查询的key值不存在,则自动添加到队尾,默认赋值0。这个特点很适合计数使用。

但在单纯进行查找操作的时候则需要小心。若要仅仅确定某个key是否存在,可以使用m.count(k),返回值为0或1。若要确定某个key值的具体位置,则可使用m.find(k),若k键存在,则返回的是指向它的一个迭代器,若不存在,则返回指向超出队尾位置的迭代器,这个返回值和m.end()的返回值一致。

//count number of times each word occurs in the input
map word_count
string word;
while(cin >> word){
    ++word_count[word];   }

//equal funtion with .insert
......
while(cin >> word){
    //insert element with key equal to word and value 1
    //if word already in word_count, insert does nothing
    pair::iterator, bool> ret =
              word_count.insert(make_pair(word, 1));
    if (!ret.second)   //word already in word_count
        ++ret.first->second;   //increment counter
        //which is equal to ++((ret.first)->second);
}

这里有一点需要注意的,仍然是不同符号连用时优先级的问题。之前在c.lang组里面也遇到了这样的问题,简单的一段程序都会出现匪夷所思的结果。那么,得到的启发就是,在任何情况下,多写几层括号,既可以方便之后的阅读代码,又可以避免因为默认优先级而引起难以察觉的问题。

ps. 设计程序的一个良好习惯是首先将程序需要完成的任务明确成条目,然后列出涉及的操作,明确了这些需要提供的操作,有助于建立需要的数据结构和实现这些行为。一般的顺序是,明确输入输出参量以及将其相关联起来的数据的结构-->明确程序行为->根据数据结构设计类->设计主函数->设计输出函数-->设计成员函数。

pps. 一篇介绍C++的文章(为什么C++)

July 5, 2010

Install Click in Ubuntu 10.04

GIT is the best way to acquire the code, so it is necessary to install this software first. Besides, there are several packages needed to patch before the click installs. And it is also tricky for the final step of installation.

**************

# git clone git://git.kernel.org/pub/scm/git/git.git

# apt-get install git-core

# git clone git://read.cs.ucla.edu/git/click

# apt-get install autoconf

# apt-get install libgtk2.0-dev

# apt-get install libtool

To update to the latest version checked in to the public repository, change into your working copy directory DIR and run:

# git pull

To fetch the Click packages:

# git clone git://read.cs.ucla.edu/git/click-packages DIR

Installation of Click:

# cd CLICKDIR
# ./configure --prefix=$HOME --enable-analysis --enable-test
# make install

The –prefix=$HOME configuration switch causes Click to install into your home directory. To run the Click driver and read its manual pages, you'll need to add $HOME/bin and $HOME/man  to your PATH and MANPATH environment variables, respectively. Alternatively, if you have root privilege on your machine, you can install Click in /usr/local, /usr/local/click, or wherever you'd like.

The –enable-analysis and –enable-test configuration switches turn on support for two necessary sub-packages, including trace analysis and regression test elements.

If you get a bus error when running Click on a Solaris or other non-x86 machine, try running your configuration through click-align: “click-align config.click | click”.

Furthermore, make sure your system has the necessary libraries and packages
installed.  On a Debian or Ubuntu system, this will include automake,
autoconf, libtool, libgtk2.0-dev (or libgtk2-dev), and graphviz.  Then:

# cd CLICKDIR/apps/clicky
# autoreconf -i
# ./configure [--prefix=PREFIX] --with-click=CLICKPREFIX
# make install

That's done:)

But on the other hand, there are some warning coming out, although they seem to be all right till now.

FIRST & SECOND appear in the Click Configuration step.

Your Linux kernel header files cause errors when included by a C++ program,
so I won't try to compile the linuxmodule driver.

There are two common reasons for this error:
1. You have not applied the Linux kernel patch that comes with this distribution.  Apply the right patch and try again.  See the INSTALL file for more information.
2. Your Linux configuration enables some functionality that is not yet covered by our patches.  Turn off this functionality and try again, or fix the error and tell us how you did it.  See the config.log file for more detailed information on the error.

==============

WARNING: `makeinfo' is missing on your system.  You should only need it if you modified a `.texi' or `.texinfo' file, or any other file indirectly affecting the aspect of the manual.  The spurious call might also be the consequence of using a buggy `make' (AIX, DU, IRIX).  You might want to install the `Texinfo' package or the `GNU make' package.  Grab either from any GNU archive site.

=============

The THIRD comes out when I build the Click install.

click-elem2man: warning: category 'devices' begins with a lowercase letter (used in UMLSwitch)
click-elem2man: warning: category 'devices' begins with a lowercase letter (used in UMLSwitch)
../missing makeinfo ./click.texi
WARNING: `makeinfo' is missing on your system.  You should only need it if
         you modified a `.texi' or `.texinfo' file, or any other file
         indirectly affecting the aspect of the manual.  The spurious
         call might also be the consequence of using a buggy `make' (AIX,
         DU, IRIX).  You might want to install the `Texinfo' package or
         the `GNU make' package.  Grab either from any GNU archive site.
make[1]: [click.info] Error 1 (ignored)
......
install-info: warning: don't call programs like install-info with an absolute path,
install-info: warning: /usr/sbin/install-info provided by dpkg is deprecated and will go away soon;
install-info: warning: its replacement lives in /usr/bin/.
This is not dpkg install-info anymore, but GNU install-info
See the man page for ginstall-info for command line arguments
install-info: No such file or directory for /root/share/info/click.info
make[1]: [install-info] Error 1 (ignored)

=============

The FINAL one appears when I build the clicky.

xcallbacks.c: In function ‘on_cut1_activate’:
xcallbacks.c:11: warning: unused parameter ‘menuitem’
xcallbacks.c:12: warning: unused parameter ‘user_data’
xcallbacks.c: In function ‘on_copy1_activate’:
xcallbacks.c:19: warning: unused parameter ‘menuitem’
xcallbacks.c:20: warning: unused parameter ‘user_data’
xcallbacks.c: In function ‘on_paste1_activate’:
xcallbacks.c:27: warning: unused parameter ‘menuitem’
xcallbacks.c:28: warning: unused parameter ‘user_data’
xcallbacks.c: In function ‘on_clear1_activate’:
xcallbacks.c:35: warning: unused parameter ‘menuitem’
xcallbacks.c:36: warning: unused parameter ‘user_data’
xcallbacks.c: In function ‘on_properties1_activate’:
xcallbacks.c:43: warning: unused parameter ‘menuitem’
xcallbacks.c:44: warning: unused parameter ‘user_data’
xcallbacks.c: In function ‘on_preferences1_activate’:
xcallbacks.c:51: warning: unused parameter ‘menuitem’
xcallbacks.c:52: warning: unused parameter ‘user_data’
xcallbacks.c: In function ‘on_about1_activate’:
xcallbacks.c:59: warning: unused parameter ‘menuitem’
xcallbacks.c:60: warning: unused parameter ‘user_data’

July 2, 2010

Install RT2870 usb wireless adapter in Ubuntu 10

Step 0 : At terminal, aaa@ubuntu:~$ sudo gedit /etc/modprobe.d/blacklist.conf. Add “blacklist rt2870usb” without quote at the end of the file, then save it.

Step 1 : Download the latest rt2870 driver (here) from Ralink.

Step 2 : Untar the file and save to your home folder, and name it. (eg. the folder name is rt2870)

Step 2.51 : According to the instruction I found in the internet, there should be another three steps done with the dongle: firstly, without plug your wireless usb at this moment, at terminal aaa@ubuntu:~$ type lsusb.

Step 2.52 : Then plug in the wireless usb to the computer, type lsusb again, the wireless usb ID (8 digits) will be found. Write it down.

Step 2.53 : Check it at aaa@ubuntu:~/rt2870/os/linux$, sudo gedit usb_main_dev.c. If the usb device is not included, add the wireless usb ID. Save the file. For example, the additional two lines are:
{USB_DEVICE(0x0B05,0x1761)}, /* Asus */
{USB_DEVICE(0x1761,0x0B05)}, /* Asus */

Step 3 : In Makefile, set the "MODE = STA" in Makefile and chose the TARGET to Linux by set "TARGET = LINUX". Then, change the directory of RT28XX_DIR in line 7 by "aaa@ubuntu:~$ shell pwd". Finally, via the command "aaa@ubuntu:~$ shell uname -r", define the linux kernel source include file path LINUX_SRC modify to meet your need.

Step 4 : At same terminal , sudo gedit config.mk, and change two settings.
# Support Wpa_Supplicant
HAS_WPA_SUPPLICANT=n → y
# Support Native WpaSupplicant for Network Maganger
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n → y

Step 5 : At aaa@ubuntu:~/rt2870$, sudo gedit Makefile, check the folllowing at the top of the file:
RT28xx_MODE = STA
TARGET = LINUX
CHIPSET = 2870
If ok, close the file. If not, change the setting as above.

Step 6: rt2870 2.2.00 version do not support kernel 2.6.31-14-generic, so you have to do a patch. The download link is here, and the patch is via "patch -p1 < rt2870-2.6.31.patch".If you get a message of unable to patch, then download and install Patch_2.5.9-5_amd64.deb.

Step 7 : At aaa@ubuntu:~/rt2870$, do the compilation.
sudo make uninstall
sudo make clean
sudo make
sudo make install

Step 8 : At aaa@ubuntu:~$ sudo modprobe rt2870sta

Step 9 : At aaa@ubuntu”~$ sudo gedit /etc/rc.local, add following two lines prior to exit0.
ifconfig ra0 up
pkill NetworkManager
save it, then at same terminal, sudo gedit /etc/modules, add rt2870sta, then save the file.

Step 10 :At aaa@ubuntu:~$ ifconfig or iwconfig, you will see your wireless is up as ra0 or wlan0.

Step 11 : Now configure networkmanager, use wep instead of wpa-psk or wpa2-psk. Your wireless will be able to connect to the internet. If there's no connection, then do step 12.

Step 12 : Update networkmanager. Go to System – Software Sources – Other software, add the following line
deb http://ppa.launchpad.net/network-manager/trunk/ubuntu karmic main

That's the end.

Install madwifi in UBUNTU 10.04

When I install the madwifi driver from madwifi.org, the problem appears:

In file included from /home/user/madwifi/madwifi-hal-0.10.5.6/ath/../net80211/ieee80211_monitor.h:34,
from /home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.c:75:
/home/user/madwifi/madwifi-hal-0.10.5.6/ath/../ath/if_athvar.h:107: error: conflicting types for 'irqreturn_t'
include/linux/irqreturn.h:16: note: previous declaration of 'irqreturn_t' was here
/home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.c: In function 'ath_attach':
/home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.c:478: error: 'struct net_device' has no member named 'priv'
/home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.c:819: error: 'struct net_device' has no member named 'open'
/home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.c:820: error: 'struct net_device' has no member named 'stop'
/home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.c:821: error: 'struct net_device' has no member named 'hard_start_xmit'
/home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.c:822: error: 'struct net_device' has no member named 'tx_timeout'
.....
.....
.....
make[3]: *** [/home/user/madwifi/madwifi-hal-0.10.5.6/ath/if_ath.o] Error 1
make[2]: *** [/home/user/madwifi/madwifi-hal-0.10.5.6/ath] Error 2
make[1]: *** [_module_/home/user/madwifi/madwifi-hal-0.10.5.6] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.31-14-generic'
make: *** [modules] Error 2
This is due to the fact that there was a change in the kernel headers. The new kernels replaced the old net_device structure with a new one called net_device_ops. It looks like this change exists since kernel 2.6.29 and up.

There currently is no stable release of the madwifi drivers for the new kernerls. But the madwifi project's latest trunk compiles and works fine (at least for me) and I have not noticed any issues yet. This should work with any Linux distribution with a kernel of 2.6.29 and above. To find out your kernel version run:
$uname -r
Here is how to get and install it:

1. You can either get the latest trunk from the madwifi website at here or use the one that worked for me (click).

2. Download and uncompress the files, cd to the directory containing the file. Then gunzip and untar the files:
tar -xvzf madwifi-trunk-r4099-20090929.tar.gz
3. Cd into the newly created directory and install the drivers. Firstly, make sure you have the kernel headers:
sudo apt-get install build-essential
Then compile and install:
sudo make
sudo make install
4. Add the ath_pci module to the kernel. You need to add a line to the end of the /etc/modules file. The line should read: ath_pci. You can do this with vi of course, but if you don't know the vi editor then it would be much easier to use gedit. So, do:
sudo gedit /etc/modules
Add ath_pci to the end of the file. Here is how my file looks:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

lp
sbp2
ath_pci
At this point you can reboot and you should have wireless. You could save yourself a reboot by modprobing the kernel with the ath_pci module like this:
sudo modprobe ath_pci
That's done:)

Days of our lives

Daisypath Anniversary tickers