2009年6月28日 星期日

xargs experience

Step 1:
change to the directory which the tcpreplay file was located.
# ls | awk '{print "echo filename:"$1" ; tcpdump -nv host 207.46.2.152 -r "$1}' | sh
# ls | xargs -n 1 tcpdump -nv host 207.46.2.152 -r

Disable the write permission of all the directory include the sub-directory
# find -type d | xargs chmod a-w

Delete all the files that are below the CVS directory
# find ./* -name CVS | xargs -n 1 rm -rf

Delete all the found *.la files
# find /PathTOHere/puma5_toolchain/src/buildroot-2009.02/project_build_armeb/puma5/root/lib -name '*.la' | xargs rm -rf

2009年6月22日 星期一

Signal type

kill is an application that can send signal to the specified application
e.g.
This will terminate the specified process (SIGKILL)
# kill -9 process-id
This will reload the specified process (SIGHUP)
# kill -1 process-id


The reference of the SIGNAL(7) man page
Signal Value Action Comment
-------------------------------------------------------------------------
SIGHUP 1 Term Hangup detected on controlling terminal
or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe: write to pipe with no readers
SIGALRM 14 Term Timer signal from alarm(2)
SIGTERM 15 Term Termination signal
SIGUSR1 30,10,16 Term User-defined signal 1
SIGUSR2 31,12,17 Term User-defined signal 2
SIGCHLD 20,17,18 Ign Child stopped or terminated
SIGCONT 19,18,25 Cont Continue if stopped
SIGSTOP 17,19,23 Stop Stop process
SIGTSTP 18,20,24 Stop Stop typed at tty
SIGTTIN 21,21,26 Stop tty input for background process
SIGTTOU 22,22,27 Stop tty output for background process

2009年6月15日 星期一

ActiveX HowTo

Unregister ActiveX component (ActiveX can be two type of extension filename, .dll or .ocx)

Change path to the ActiveX directory, unregister DLL component by using the regsvr32 program with -u parameter
C:\WINDOWS\Downloaded Program Files>regsvr32 -u XXX.dll

C:\WINDOWS\Downloaded Program Files>regsvr32 -u XXX.ocx

After successfully unregister the ActiveX component, it will show a pop-up message that shows the following descriptions:
DllUnregisterServer at XXX.dll success.

2009年6月4日 星期四

wincvs tutorial

Test version 2.0.2.4 (Build 4)

1. What is the first step?
A. Login to the cvs server via wincvs
Admin -> Login -> Login settings -> enable CVSROOT field, fill the string as following type
:ssh:user-name@CVS-server-address:port:cvs-folder-path

set the global settings in the Tab: Globals
Enable the following setting
Checkout text files with Unix LF (0xa)

2. How to checkout cvs modules?
A. You can use the manually isuue command (procedure 3) or simply run the following command
Remote -> Checkout modules (Must specify the module name first)

3. How to update (sync) the CVS code of working directory?
A. Admin -> Command Line -> Enter the command line
Input the submit cvs command
e.g
cvs -q up

4. How to issue other command (e.g. like checkout other branches of module..)?
A. Following the previous procedure 3 instructments, then issue the following command
cvs co -r cvs_branch module-name

AJAX - JQuery introduction

AJAX 的API包括JQuery.js ProtoType.js JQuery.js ProtoType.js 的license為M.I.T Licenese

JQuery的主要功能包括 * 不同平台的browser顯示的畫面具有一致性 * 可以有AJAX 做到local端動態只有更新某一個division顯示畫面的功能
Google Map API 底層有包AJAX API

AJAX 的目的是讓Browser User unaware 去update web pages的某一些部份(some division), 不用手動去做page refresh, 底層是利用Java Script 去切割成一塊一塊的division, 然後利用event trigger的方式,當某一塊division被event trigger 需要update時, 那一塊division就會主動連到server去做page refresh

Linux Command - dos2unix, Windows Linux difference endline code

Line Ending patterns are different in various operation system
Windows / MS-Dos: [CR][LF] 0d 0a
Mac: [CR] 0d
Unix/Linux: [LF] oa

// You will find many "0x0a 0x0d" hex code pattern in the dump of windows file
# hexdump File.h.win32 | grep 0a0d
0000010 3e68 0a0d 6923 636e 756c 6564 3c20 7473
[omit]
0000220 6365 3b74 0a0d 0a0d 2a2f 202a 7546 636e
0000260 3b29 0a0d 6f76 6469 4220 6675 6566 4d72
0000280 6820 6e61 6c64 7265 3b29 0a0d 6e69 2074

// after we convert the file from windows file mode to unix file mode, we will no more see the pattern "0a0d"
# dos2unix -n File.h.unix File.h.win32
# hexdump File.h.unix | grep 0a0d

We can use dos2unix command to do the code translation, the command format is as following
# dos2unix -n Windows-text-original-file Unx-text-destinated-file

Linux System - Tuning Linux server performance before adopting the server production

If We want to setup a high performance and throughput networked server. We may follow the directions of this article to achieve the purpose.

Modify the system settings
sysctl -w net.core.rmem_max=8388608
sysctl -w net.core.wmem_max=8388608
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
sysctl -w net.ipv4.tcp_rmem="32768 87380 8388608"
sysctl -w net.ipv4.tcp_wmem="16384 65536 8388608"
sysctl -w net.ipv4.tcp_mem="8388608 8388608 8388608"
sysctl -w net.ipv4.tcp_syncookies=0
ulimit -n 65535
ulimit -s unlimited
ulimit -u unlimited




# increase Linux TCP buffer limits
sysctl -w net.core.rmem_max=8388608
sysctl -w net.core.wmem_max=8388608

# increase Linux autotuning TCP buffer limits
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
sysctl -w net.ipv4.tcp_rmem="32768 87380 8388608"
sysctl -w net.ipv4.tcp_wmem="16384 65536 8388608"
sysctl -w net.ipv4.tcp_mem="8388608 8388608 8388608"

# stop syn blocking
sysctl -w net.ipv4.tcp_syncookies=0

# maximum number of open file descriptors (modify the open files number per process)
# This parameter is the important factor that determine the process can open how many file descriptor / socket number.
ulimit -n 65535

How to modify the configure file to make the modification effectiveness after
reboot

Ans:
We can modify the /etc/sysctl.conf to make the new setting effective after system reboot.

In the /etc/security/limits.conf, add
* soft nofile 8192 (modify to the max value of soft)
* hard nofile 20480 (modify to the max value of hard)

After this modification, relogin and type "ulimit -a" will show the open fd size of per process

suspend some seconds in the Linux/Windows

Linux
- sleep(n), , suspend n seconds
- usleep(n), suspend n * 10(-6) seconds

Windows
- Sleep(n) , suspend n * 10(-6) second

We can also use select to suspend n seconds m 10(-6) seconds

struct timeout tv;
tv.tv_sec = n;
tv.tv_usec = m;
select(0, NULL, NULL, NULL, &tv);

Then this function will suspend n seconds m 10(-6) seconds

2009年6月3日 星期三

Some action after the network is becoming disconnected

1. Use Notebook to directly test the socket of switch. Try to get a dhcp address if the network system is ok.

2. Sometime the host is strange in the network connection. Try to restart the network interface (e.g. service network restart, ifdown eth0; ifup eth0...). Or we can try to restart the OS

3. Try to change to use another network line, another pc to test the network line, another switch/hub to distinguish the real point of network failure.

My experience of facing the network disconnected in the company :
Find the network root line, e.g. if the lab is network disconnected, we can test the network root line directly. Sometimes the real problem is that the foreign network device was down (e.g. switch, router) or the foreign network line/socket was not connected well causing the network unstable.