29 December 2011

Disable Control-C [ CTRL+C ] in linux

Signals are the notification send to a process on the occurrence of an event.

#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>

struct sigaction act;

void sighandler(int signum, siginfo_t *info, void *ptr)
{
    printf("Received signal %d\n", signum);
    printf("Signal originates from process %lu\n",
        (unsigned long)info->si_pid);
}

int main()
{
    printf("I am %lu\n", (unsigned long)getpid());

    memset(&act, 0, sizeof(act));
#if 0
    act.sa_sigaction = sighandler;
    act.sa_flags = SA_SIGINFO;
    sigaction(SIGINT, &act, NULL);
#endif
#if 0
    act.sa_handler = SIG_IGN;
    sigaction(SIGINT, &act, NULL);
#endif

    signal(SIGINT, SIG_IGN);

    // Waiting for CTRL+C...
    sleep(100);

    return 0;
}

Reference:
http://nixcraft.com/shell-scripting/12605-shell-script-disable-ctrl-c-ctrl-z.html

How to handle SIGSEGV, but also generate a core dump

Signals are the notification send to a process on the occurrence of an event.

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>

void sighandler(int signum)
{
    printf("Process %d got signal %d\n", getpid(), signum);
    signal(signum, SIG_DFL);
    kill(getpid(), signum);
}

int main()
{
    signal(SIGSEGV, sighandler);
    printf("Process %d waits for someone to send it SIGSEGV\n",
        getpid());
    sleep(1000);

    return 0;
}
ulimit -c unlimited
echo "0" > /proc/sys/kernel/core_uses_pid
echo "core" > /proc/sys/kernel/core_pattern
$ ls
sigs.c
$ gcc sigs.c
$ ./a.out
Process 2149 waits for someone to send it SIGSEGV
Process 2149 got signal 11
Segmentation fault (core dumped)
$ ls
a.out*  core  sigs.c

Reference:
http://www.alexonlinux.com/signal-handling-in-linux
http://www.alexonlinux.com/how-to-handle-sigsegv-but-also-generate-core-dump
http://aplawrence.com/Linux/limit_core_files.html

28 December 2011

extract file in linux

extract () {
   if [ -f $1 ] ; then
       case $1 in
 *.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
 *.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
 *.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
 *.bz2)  bunzip2 $1 && cd $(basename "$1" /bz2) ;;
 *.rar)  unrar x $1 && cd $(basename "$1" .rar) ;;
 *.gz)  gunzip $1 && cd $(basename "$1" .gz) ;;
 *.tar)  tar xvf $1 && cd $(basename "$1" .tar) ;;
 *.tbz2)  tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
 *.tgz)  tar xvzf $1 && cd $(basename "$1" .tgz) ;;
 *.zip)  unzip $1 && cd $(basename "$1" .zip) ;;
 *.Z)  uncompress $1 && cd $(basename "$1" .Z) ;;
 *.7z)  7z x $1 && cd $(basename "$1" .7z) ;;
 *)  echo "don't know how to extract '$1'..." ;;
       esac
   else
       echo "'$1' is not a valid file!"
   fi
}
http://ubuntuforums.org/showthread.php?t=1116012

21 November 2011

value of pi (π)

==> In term of fractions: 
22/7,
333/106,
355/113 = 3.1415929203539823008849557522124,
103993/33102, 
104348/33215, 
208341/66317,
312689/99532,
833719/265381,
1146408/364913,
4272943/1360120,
...
...
428224593349304/136308121570117, ...

==> From GNU's math.h header file:
# define M_PI       3.14159265358979323846  /* pi */

Reference:
http://numbers.computation.free.fr/Constants/Pi/piApprox.html
http://c2.com/cgi/wiki?ValueOfPi

10 November 2011

htonll - 64bit host to network conversion

See difference in output for little endian and big endian machines (bswap64.c)

Constant folding is the process of simplifying constant expressions at compile time.
With constant folding support, i = 1 * 2 * 3 * 4 * 5; is calculated at compile time, i = 120.
#include <endian.h>

typedef unsigned long long uint64;
typedef unsigned long uint32;

typedef union {
  uint64 big;
  uint32 small[2];
}long_long;

#define HTONLL01(x) ({long_long i; i.small[0] = htonl((uint32)(x>>32)); \
                      i.small[1] = htonl((uint32)x); x = i.big;})

#if __BYTE_ORDER == __BIG_ENDIAN
# define HTONLL02(x) (x)
#else
# if __BYTE_ORDER == __LITTLE_ENDIAN
#  define HTONLL02(x) (((uint64)htonl((uint32)x))<<32 | htonl((uint32)(x>>32)))
# endif
#endif

From "/usr/include/bits/byteswap.h"
/* Swap bytes in 64 bit value.  */
#define __bswap_constant_64(x) \
     (  (((x) & 0xff00000000000000ull) >> 56)                     \
      | (((x) & 0x00ff000000000000ull) >> 40)                     \
      | (((x) & 0x0000ff0000000000ull) >> 24)                     \
      | (((x) & 0x000000ff00000000ull) >> 8)                      \
      | (((x) & 0x00000000ff000000ull) << 8)                      \
      | (((x) & 0x0000000000ff0000ull) << 24)                     \
      | (((x) & 0x000000000000ff00ull) << 40)                     \
      | (((x) & 0x00000000000000ffull) << 56))

# define __bswap_64(x) \
     (__extension__                                               \
      ({ union { __extension__ unsigned long long int __ll;       \
         unsigned long int __l[2]; } __w, __r;                    \
     if (__builtin_constant_p (x))                                \
       __r.__ll = __bswap_constant_64 (x);                        \
     else                                                         \
       {                                                          \
         __w.__ll = (x);                                          \
         __r.__l[0] = __bswap_32 (__w.__l[1]);                    \
         __r.__l[1] = __bswap_32 (__w.__l[0]);                    \
       }                                                          \
     __r.__ll; }))

Reference:
http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/
http://en.wikipedia.org/wiki/Constant_folding

09 November 2011

ഒരു ട്രെയിന്‍ യാത്ര

On a fine Sunday evening same 5pm train.
I have got side lower seat.

അടുത്തിരുന്ന couples പരിചയപ്പെട്ടു, about 60+ years old.
Later came to know that they where teachers and taught at my sis’s school and seemed neighbors to me, may be within 5km radius. And they are going to see some swami in Bangalore…blah blah blah... And the husband had heart attack once,,, :-(

And I started,,, reading + listening to music.
From trissur (or some where) 1 more couple came,,, seemed they got both the lower berths.
And they switched of the light immediately after finishing the dinner.

I don’t know why I interfere with the matter, may be I don’t want the lights gone at that moment. I said them that old couple can’t climb the berth.
I volunteered to give my side lower berth, so as the new couple also agreed to give one of there lower berth.
Here is the catch,,, I didn’t check their tickets.

So at some point of the journey,,, some where in തമിഴ്നാടു കുറെ ആളുകള്‍ ട്രെയിനില്‍ കയറി….
They started saying that i am sleeping on their berth and one of the younger couple as well...
As all of us was on sound sleep,,, we didn’t understand a thing for a moment.

കുറച്ചു സമയം കഴിഞ്ചു നമ്മുടെ old couplinte ടിക്കറ്റ്‌ ചെക്ക്‌ ചെയ്തപ്പോഴാണ് ഒരു കാര്യം മനസിലായത്... അവരുടെ berth S1ല്‍ അന്നു instead of S10…

പാവം ഞാന്‍... New couplinte വഴക്കും കേട്ടു,,, ഞാന്‍ പറഞ്ഞിട്ടാണ്...

പിന്നെ രാത്രി 2pm ന് നമ്മുടെ old couplinem അയിട്ടൂ S10ന്നു S1 വരെ നടന്നു...
അവിടെ ചെന്നപ്പോള്‍ ഭാഗ്യത്തിന് bearth അവിടെ തന്നെ ഉണ്ട്...

പക്ഷെ ഒരു problem... നമ്മുടെ മാഷ് കണ്ണാട എടുക്കാന്‍ മറന്നു...
I came back from S1 to S10, took the കണ്ണാട, went back to S1 with കണ്ണാട
അവിടെ എത്തി അപ്പോഴത്തെ കാഴ്ച്ച... നമ്മുടെ heart patient അയ മാഷ് side upper beartil കയറി കാലും അട്ടി കൊണ്ടിരിക്കുന്നു...

Gheee...

Does this need any moral???

22 September 2011

Open Internet Shortcut in IE

Use a file shortcut instead of an internet shortcut.

1. Create a shortcut to C:\Program Files\Internet Explorer\iexplore.exe.

2. Open the properties and add a space and the website to the target.
("C:\Program Files\Internet Explorer\iexplore.exe" http://www.google.co.in)

3. Once in IE the internet shortcuts in favorites or on the links bar will ignore the default browser and opens in IE as well.


Reference:
http://forum.worldstart.com/showthread.php?t=111659

30 July 2011

Spoof ARP and ICMP ECHOREPLY Using Linux Socket Filter

Download ARP and ICMP spoof code from here.
# gcc icmp_spoof.c -o icmp
# ./icmp eth0
Opening raw socket
Got raw socket fd 3
Fake MAC address is 00:aa:bb:cc:dd:ee
Created raw socket
Sent ARP reply: 192.168.109.5 is 00:0c:29:98:4f:5b
Received ICMP ECHO from 192.168.109.1 (code: 0 id: 512 seq: 27178)
Received ICMP ECHO from 192.168.109.1 (code: 0 id: 512 seq: 27434)

Reference:
http://blog.fpmurphy.com/2011/01/spoof-arp-and-icmp-echoreply-using-linux-packet-filter.html

20 July 2011

VLAN Advanced

On a large, flat, switched network with thousands of computers, performance suffers and security concerns increase.

Using VLANs to divide a growing network can help with manageability, performance and security.

The VLAN structure makes it easier for administrators to manage network resources. Users can be grouped logically with the resources(servers, printers, etc.) that they need. When a user's computer physically moves to a different location (for example, with a laptop computer), the VLAN management software can recognize the computer and automatically assign it to the VLAN to which it's supposed to belong.

VLANs reduce the need to have routers deployed on a network to contain broadcast traffic. VLANs are separated by switches that divide the network into multiple broadcast domains, to reduce the amount of traffic going to all devices and thus increase performance.

By confining the broadcast domains, end-stations on a VLAN can be isolated from listening to or receiving broadcasts not intended for them. Moreover, if a router is not connected between the VLANs, the end-stations of a VLAN cannot communicate with the end-stations of the other VLANs.


Reference:
http://thebestechblog.blogspot.com/2009/06/vlan.html
http://www.frokwon.net/essays/VLAN.htm
http://net21.ucdavis.edu/newvlan.htm
http://www.techrepublic.com/article/scaling-your-network-with-vlans/5779489

wpa_passphrase

WPA-PSK uses pre-shared key as a passphrase of 8 to 63 printable ASCII characters or as a string of 64 hexadecimal digits.

If ASCII characters are used, the 256 bit key is calculated by applying the PBKDF2 key derivation function to the passphrase, using the SSID as the salt and 4096 iterations of HMAC-SHA1.

wpa_passphrase -- utility for generating a 256-bit pre-shared WPA key from an ASCII passphrase. You can download wpa_passphrase.tar.gz from here.
# tar xzvf wpa_passphrase.tar.gz
# make
# ./wpa_passphrase humble mypassword
network={
ssid="humble"
#psk="mypassword"
psk=aa382e1c4ac62580c25ee2b33a1cf6179176baad4a5cffc43be9c8d2b103f4aa
}
AP can be configured with ASCII passphrase or HEX digits
Which enables the windows client to uses either of the above key
For home and small office networks its preferred to use WPA2-personal authentication method which also uses CCMP, AES based encryption.
Each wireless network device authenticates with the access point using the same 256-bit key.

Reference:
http://www.hautespot.net/wpapsk.html
http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?wpa_passphrase+8

30 June 2011

spinlock

volatile modifier tells compiler that value may change in a way which is not predictable by the compiler. it guaranties that the compiler won't re-order volatile read and write.
- useful for memory-mapped I/O and shared memory.

volatile guaranties that the compiler will generate ordered volatile read and write, but CPU may reorder the execution.

memory barriar is used to avoid the CPUs employ performance optimizations that can result in out-of-order execution.
Compiler memory barrier - prevent a compiler from reordering instructions, they do not prevent reordering by CPU. ex:- asm volatile ("" : : : "memory");

why spinlock required???

1. protects data from multiple thread of execution
==> spin + ena/dis preemption

2. protects data from interruct handler
==> ena/dis interrupt + spin + ena/dis preemption

SMP + PREEMPT ==> spin + disable preemption
SMP + NO PREEMPT ==> spin
NO SMP + PREEMPT ==> disable kernel preemption
NO SMP + NO PREEMPT ==> NULL

==> spinlock protects critical region
==> spinlock provides mutual exclusion
==> spinlock marks the non-preemptible regions

; Intel syntax
lock:
dd 0 ;

spin_lock:
mov eax, 1 ;
xchg eax, [lock] ;
test eax, eax ;
jnz spin_lock ;
ret ;

spin_unlock:
mov eax, 0 ;
xchg eax, [lock] ;
ret ;



Reference:
http://en.wikipedia.org/wiki/Spinlock#Example_implementation
http://en.wikipedia.org/wiki/Memory_barrier
http://en.wikipedia.org/wiki/Memory_ordering

21 June 2011

Hang a linux box with relatime process?

A runnable SCHED_FIFO task continues to run until it blocks or explicitly yields the processor; it has no timeslice and can run indefinitely.
A SCHED_RR is identical to SCHED_FIFO except that each process can run only until it exhausts a predetermined timeslice.

/proc/sys/kernel/sched_rt_runtime_us: A global limit on how much time realtime scheduling may use.

Since 2.6.25 kernel, the default values for sched_rt_period_us (1000000 or 1s) and sched_rt_runtime_us (950000 or 0.95s). This gives 0.05s to be used by SCHED_OTHER (non-RT tasks). In other words, the group scheduler is configured, by default, to reserve 5% of the CPU for non-SCHED_FIFO tasks.

Download testrt.c
root permission is required to execute this!!!

# gcc -o testrt testrt.c -lrt -Wall
# ./testrt
using realtime, priority: 20

# echo 1000000 > /proc/sys/kernel/sched_rt_runtime_us

system is hang!!!
Download simple-module.c
Download Makefile.mod
# mv Makefile.mod Makefile
# make
# insmod ./simple-module.ko

# cat /proc/getprio
==> [120:120:120:0] [1000] [0x00402100] systemd [1][0]
==> [120:120:120:0] [1000] [0x8020A040] kthreadd [2][0]
==> [120:120:120:0] [1000] [0x8420A040] ksoftirqd/0 [3][2]
==> [120:120:120:0] [1000] [0x8420A060] kworker/u:0 [5][2]
==> [100:100:100:0] [1000] [0x8420A040] khelper [6][2]
==> [120:120:120:0] [1000] [0x8020A040] sync_supers [95][2]
==> [120:120:120:0] [1000] [0x80A0A040] bdi-default [97][2]
==> [100:100:100:0] [1000] [0x8420A040] kblockd [99][2]
==> [100:100:100:0] [1000] [0x8420A040] ata_sff [255][2]
==> [100:100:100:0] [1000] [0x8420A040] md [261][2]
==> [120:120:120:0] [1000] [0x8420A060] kworker/0:1 [359][2]
==> [120:120:120:0] [1000] [0x80A4A840] kswapd0 [370][2]
...
==> [79:120:79:20] [1000] [0x00400100] testrt [3264][2463]
...

Reference:
http://lwn.net/Articles/296419/
http://book.chinaunix.net/special/ebook/Linux_Kernel_Development/0672327201/ch04lev1sec4.html
http://www.kernel.org/doc/Documentation/scheduler/sched-rt-group.txt
https://rt.wiki.kernel.org/index.php/Squarewave-example

20 June 2011

sample c programs

Find first bit in word - ffb.c

# ./ffb
first bit(0xDEADBEAF): 0
first bit(0xDEADBEA0): 5
first bit(0xDEADBE00): 9
first bit(0xDEADB000): 12
first bit(0xDEAD0000): 16
create a daemon and redirect output to logfile - pcreate.c

cat > daemon.sh << EOF
#!/bin/sh
while [ 1 ]; do date; sleep 1; done
EOF

# chmod +x daemon.sh
# gcc -o pcreate pcreate.c
# ./pcreate ./daemon.sh logfile.log
# tail -f logfile.log
program to print U-Boot environment variables - ubootenv.c
hexdump of U-Boot env partition - uboot.env

# gcc -o ubootenv ubootenv.c
# ./ubootenv uboot.env
CRC32: 0xE2A77069
Active Flag: 0x01

bootdelay=0
baudrate=115200
download_baudrate=115200
....
Euclid's Algorithm to find GCD (gcd.c)

# gcc -o gcd gcd.c
# ./gcd 12345 56789
gcd of 12345 and 56789 is 1
sieve of Eratosthenes to find prime numbers (prime.c)

# gcc -o prime prime.c
# ./prime 100
2 3 5 7 11 13 17 19 23 29
31 37 41 43 47 53 59 61 67 71
73 79 83 89 97
Tottal number: 25
Simple client/Server communication (server1.c, client1.c)
Simple client/Server communication (server2.c, client2.c)
Simple client/Server communication (server3.c, client3.c)



# gcc -o server serverX.c
# gcc -o client clientX.c

# ./server 5555
Here is the message: hello server

# ./client localhost 5555
Please enter the message: hello server
from server time: Tue Nov 23 05:06:08 2010


Reference:

19 June 2011

linux 2.6 simple module

Download simple-proc.c
Download Makefile.sim
# mv Makefile.sim Makefile
# make
# insmod ./simple-proc.ko

# echo "1" > /proc/arith/sum
# echo "11" > /proc/arith/sum
# echo "111" > /proc/arith/sum

# cat /proc/arith/sum
123

Download simple-module.c
Download Makefile.mod
# mv Makefile.mod Makefile
# make
# insmod ./simple-module.ko

# cat /proc/getprio
==> [120:120:120:0] [1000] [0x00402100] systemd [1][0]
==> [120:120:120:0] [1000] [0x8020A040] kthreadd [2][0]
==> [120:120:120:0] [1000] [0x8420A040] ksoftirqd/0 [3][2]
==> [120:120:120:0] [1000] [0x8420A060] kworker/u:0 [5][2]
==> [100:100:100:0] [1000] [0x8420A040] khelper [6][2]
==> [120:120:120:0] [1000] [0x8020A040] sync_supers [95][2]
==> [120:120:120:0] [1000] [0x80A0A040] bdi-default [97][2]
==> [100:100:100:0] [1000] [0x8420A040] kblockd [99][2]
==> [100:100:100:0] [1000] [0x8420A040] ata_sff [255][2]
==> [100:100:100:0] [1000] [0x8420A040] md [261][2]
==> [120:120:120:0] [1000] [0x8420A060] kworker/0:1 [359][2]
==> [120:120:120:0] [1000] [0x80A4A840] kswapd0 [370][2]
...
==> [79:120:79:20] [1000] [0x00400100] testrt [3264][2463]
...


Reference:
http://www.captain.at/programming/kernel-2.6
http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html

26 May 2011

linux 2.6.39 installation on Fedora Core 15

1. Install Fedora core 15.
2. Download Linux 2.6.39 source code from here.
3. Download the config file for 2.6.39 from here.
4. Remove all the arch related files other than x86 from here.
cd /usr/src/kernels
tar xjvf linux-2.6.39.tar.bz2
cp config.39 .config
make oldconfig
make
make modules_install
make install
timeout=10
#hiddenmenu
kernel .... rdshell rdinitdebug
kernel .... #rhgb quiet

Reference:
Fedora Core 14 Intallation
Fedora Core 15 Intallation

Linux 2.6.36 + Fedora 14
Linux 2.6.37 + Fedora 14
Linux 2.6.38 + Fedora 14
Linux 2.6.39 + Fedora 15

Fedora Core 15 installation on VmWare 2.0.2

1. login using Administrator account
2. Virtual Machine --> Create Virtual Machine
3. Name and Location --> "FC14-minimal"
4. Guest Operating System --> "Linux 2.6"
5. Memory and Processors --> "768MB"
6. Hard Disk --> "Create New Virtual Disk"
7. Hard Disk Properties --> "40GB"
8. Network Adapter --> "NAT"
9. CD Drive --> "Use a Physical Drive"
10. Floppy Drive --> "Don't Add a Floppy Drive"
11. USB Controller --> "Don't Add a USB Controller"
12. Ready to Complete --> "Finished"

13. Summary --> "CD/DVD Drice" --> "[] c:\Fedora-15-i386-DVD.iso"
1. Skip media test
2. Select "Basic Storage Devices"
("Yes, discard any data")
3. Select "Create Custom Layout"
>> "Free" -> "Create" -> "Standard Partition" -> 1536MB swap
>> "Free" -> "Create" -> "Standard Partition"
Mount point --> "/boot"
File system --> "EXT4"
Size --> 500MB
>> "Free" -> "Create" -> "Standard Partition"
Mount point --> "/"
File system --> "EXT4"
Fill to maximum allowed size
>> "format" and "write changes to disk"
4. Select "minimal" installation
5. A total of 188 packages will get installed.
vi /etc/syscofig/network-scripts/ifcfg-p3p1
>> DEVICE="p3p1"
>> ONBOOT="yes"
>> BOOTPROTO="dhcp"
mkdir /mnt/cdrom
vi /etc/fstab
>> /dev/cdrom /mnt/cdrom iso9660 defaults 0 0
mount -a
cd /etc/yum.repos.d/
vi fedora.repo >> enabled=0
vi fedora-updates.repo
>> baseurl=file:///mnt/cdrom
>> #baseurl
>> #mirrorlist
>> enabled=1
>> gpgcheck=0
yum install ftp make vim gcc gcc-c++ ctags ncur*
yum install man-db man-pages kernel-devel mlocate bind-utils
yum install ntsysv gpm strace plymouth-theme* openssh-clients...

yum install Xorg xorg-x11-drv-*
yum groupinstall 'GNOME Desktop Environment'
vi ~/.bashrc
>> alias vi=vim
vi ~/.vimrc
>> set is
>> set hls
>> set sw=4
>> set ts=4

>> set cindent shiftwidth=2
>> set fo+=or
>> syntax enable

>> set expandtab
>> set tabstop=4
vi /boot/grub/grub.conf
>> timeout=10
>> #hiddenmenu
>> kernel .... rdshell rdinitdebug
>> kernel .... #rhgb quiet
ntsysv --> only select "network", "sshd"


Reference:
Fedora Core 14 installation on VmWare 2.0.2
How To: Setup SSH/SCP without a password
linux 2.6.39 installation on Fedora Core 15

29 April 2011

Transparent Inter Process Communication (TIPC) protocol

TCP Disadvantage
- heavy connection setup/shutdown scheme of TCP is a disadvantage in a dynamic environment. The minimum number of packets exchanged for even the shortest TCP transaction is nine, while with TIPC this can be reduced to two, or even to one if connectionless mode is used
- The connection-oriented nature of TCP makes it impossible to support true multicast



TIPC Important design assumptions
- most messages cross only one direct hop
- security is a less crucial issue in closed clusters

TIPC Advantage
- fast link failure detection
--> Link setup - A TIPC node periodically broadcasts Link Request messages on all configured media interfaces. If such a message is received by a node with no prior established link to the sending node, it replies with a unicast Link Response message. This establishes a Link between those two nodes.
--> Link continuity check - A background timer is maintained for each link. When a certain amount of time is passed without regular incoming traffic, a message is sent over the link to indicate to the counterpart that the link is still up. This message also contains an acknowledge for the last received Link Level Sequence Number, in order to allow the receiver to release sent packet buffers, and a Last Sent Sequence Number, allowing the receiver to detect gaps in the packet sequence. The continuity check mechanism allows rapid detection of communication media failure, or node crashes.
- reliable multicast service
- full address transparency over the whole cluster
--> A TIPC address is written in the form <zone.cluster.node>, i.e. the address <1.2.3> identifies node number 3 inside cluster 2 in zone 1
--> The TIPC stack uses a functional addressing (port names) scheme. Port names are unique and valid among the whole cluster, an application may connect to this "port name"
- for both connectionless and -oriented message flows, packet or byte-stream order is maintained from the receiving application's point of view.
- fixed-size sliding window protocol
--> flow control - congestion control - is performed only for connection oriented connection

UDP - Connectionless, Unreliable, Not ordered, No congestion control

TIPC - Connectionless, reliable, ordered, No congestion control
TIPC - Connection-oriented, reliable, ordered, congestion control

Fragmentation/Defragmentation
Congestion Control
Sequence/Retransmission Control

struct sockaddr_tipc {
unsigned short family;
unsigned char addrtype;
signed char scope;
union {
struct tipc_portid id;
struct tipc_name_seq nameseq;
struct {
struct tipc_name name;
__u32 domain;
} name;
} addr;
};

struct tipc_name {
__u32 type;
__u32 instance;
};

/* Build socket address */
addr.family = AF_TIPC;
addr.addrtype = TIPC_ADDR_NAME;
addr.addr.name.name.type = IPC_TIPC_ADDR_TYPE;
addr.addr.name.name.instance = svcIndex;
addr.addr.name.domain = 0;
addr.scope = TIPC_ZONE_SCOPE;

Reference:
http://en.wikipedia.org/wiki/TIPC
FlorianWestphalTIPCAusarbeitung.pdf
http://www.strlen.de/tipc/
http://tipc.sourceforge.net/doc/draft-spec-tipc-07.html
http://ealnet2010a.wordpress.com/2011/02/11/tcp-vs-udp/
http://tipc.sourceforge.net/doc/Programmers_Guide.txt

06 April 2011

Login as a root from GUI Fedora 14

Update the following files:
vim /etc/pam.d/gdm
#auth required pam_succeed_if.so user != root quiet

vim /etc/pam.d/gdm-password
#auth required pam_succeed_if.so user != root quiet
Log out of that account and login in as root using the "Other" option. You will get some long winded alert about how it is not secure to use the root account, just close and you are in!

Reference:
http://blog.ask4itsolutions.com/2010/11/03/login-as-a-root-from-gui-fedora-14/
http://www.liberiangeek.net/2010/12/how-to-login-as-root-in-fedora-14-laughlin/

04 April 2011

3G, GPRS Internet connection via PC Suite

I have Nokia 5320 and i want to take 3G or GPRS internet.

Connect your phone to computer either via Bluetooth or Data cable
Bluetooth:
--> Install the PC suite software.
--> Pair mobile handset with your PC or Laptop via the Bluetooth program
--> Click on “Connect to the Internet” icon from the PC Suite programs.

Cable:
--> Install the PC suite software.
--> Connect mobile handset with your PC or Laptop via the USB cable.
--> Click on “Connect to the Internet” icon from the PC Suite Program.
For more info on DOCOMO 3G, SMS "3Glife" to 53333
WWW Services
-APN: TATA.DOCOMO.INTERNET
-Username
-Password

WAP Services
-APN: TATA.DOCOMO.DIVE.IN
-Username
-Password
-PROXY: 10.124.94.7:8080


http://www.tatadocomo.com/3g-plans.aspx
http://www.tatadocomo.com/3g-hspa-e-stick.aspx



Reference:
http://techbrail.com/connect-your-nokia-3120-classic-to-3g-gprs-internet-connection-via-pc-suite/209
http://www.mostlyblog.com/tata-docomo-gprs-settings-tata-docomo-gprs-settings-for-pc-and-laptop

03 April 2011

Search for best 3G phone in india

I am looking for best 3G phone in india.

My range is 5,000/- to 15,000/-.

Other requirements:
1. Radio
2. moderate quality camera.
3. 1-4GB memory
4. music keys
5. And very gud battery backup

http://www.nokia.co.in/find-products/products

17 March 2011

the cheapest STD call in india

Tata DOCOMO
The best offer i got from net is from DOCOMO.
Tata DOCOMO Tariff Plan
for Rs 24/- STD at 1p/6sec with validity of 30 days.

AirTel
I am using AirTel - it doesn't have any offer.
Maximum they can offer is 1/- for 3min STD call.

Idea
Idea is almost similar to AirTel,,, no offers at all.
Idea Prepaid Tariff Plan
The best they have for STD call is charge for 61/- and get 140min free. :-(

Vodaphone
Worst plan i ever see,,,
there is no difference to STD calls to same/other network.
Vodafone Tariff Plan

16 March 2011

process memory usage in Linux

In linux, the amount of physical memory a single process might use 
can be roughly divided into following categories.

* M.a anonymous mapped memory
o .p private
+ .d dirty == malloc/mmapped heap and stack allocated and written memory
+ .c clean == malloc/mmapped heap and stack memory once allocated,
written, then freed, but not reclaimed yet
o .s shared
+ .d dirty == there should be none
+ .c clean == there should be none
* M.n named mapped memory
o .p private
+ .d dirty == file mmapped written memory private
+ .c clean == mapped program/library text private mapped
o .s shared
+ .d dirty == file mmapped written memory shared
+ .c clean == mapped library text shared mapped

m.a.p.d
awk '/^[0-9a-f]/{if ($6=="") {anon=1}else{anon=0}} /Private_Dirty/{if(anon) {asum+=$2}else{nasum+=$2}} END{printf "sum=%d\n",asum}' /proc/<pid>/smaps

m.a.p.c
awk '/^[0-9a-f]/{if ($6=="") {anon=1}else{anon=0}} /Private_Clean/{if(anon) {asum+=$2}else{nasum+=$2}} END{printf "sum=%d\n",asum}' /proc/<pid>/smaps


Reference:
http://stackoverflow.com/questions/131303/linux-how-to-measure-actual-memory-usage-of-an-application-or-process

09 March 2011

Investing in Gold in India

Get the latest gold rate in Kerala from http://www.joscogroup.com.

1. Invest in Mutual Funds - gold ETF (Exchange Traded Funds)
2. buying gold coins from BANK
3. buying gold coins from JEWELERY

Presently there are nine different Gold ETFs available in India for trading and investment on the National Stock Exchange (NSE). These are :-
1. Benchmark Gold BeES (GOLDBEES.NS)
2. UTI Gold ETF (GOLDSHARE.NS)
3. Kotak Gold ETF (KOTAKGOLD.NS)
4. Reliance Gold ETF (RELGOLD.NS)
5. SBI Gold ETF (SBIGETS.NS)
6. Religare Gold ETF (RELIGAREGO.NS)
7. HDFC Gold ETF
8. ICICI Gold ETF
9. Quantum Gold Fund (QGOLDHALF.NS)


Gold rate as of 2011-Mar-09 in formation got from www.sify.com
Gold rate for 22 K ==> 1956/-
Gold rate for 24 K ==> 2103/-
    Bank        24K / gm  Bank 24K / gm    Diff   % diff 
SBI 2,103.00 2,296.25 193.25 9.19%
Bank Of India 2,103.00 2,292.50 189.50 9.01%
Bank Of Barada 2,103.00 2,344.50 241.50 11.48%
HDFC Bank 2,103.00 2,508.00 405.00 19.26%



Reference:
http://www.moneycontrol.com/mf/etf/
http://www.onemint.com/2010/04/14/how-to-buy-gold-coins-in-india/>