22 June 2009

The funniest story I ever told

I am a very good listener you know.
But to tell a story, that too if it is a joke, it’s very difficult.

Ok here is one story,,,
IPL ടുര്‍ണമെന്റ് നടന്നു കൊണ്ടിരിക്കുന്ന സമയം. ബാംഗ്ലൂരില്‍ ഹോസ്റ്റല്‍ റൂമില്‍ ഞങ്ങള്‍ friends എല്ലാരും കൂടി ടീവിയില്‍ match watch ചെയ്യുവയിരുന്നു. Suddenly ബാംഗ്ലൂരില്‍ normaly സംഭവിക്കാറുള്ള അത് സംഭവിച്ചു,,, കരണ്ട് പോയി. ചുറ്റും ഇരുട്ടയത് കൊണ്ട് ആരും പായെന്നു എഴുന്നേറ്റില്ല,,, അപ്പോള്‍ ഇരുട്ടതിരുന്ന ഒരുത്തന്‍ എന്നോട് ഒരു joke പറയാന്‍ ആവശ്യപ്പെട്ടു. ഞാന്‍ അത് കേള്‍ക്കാന്‍ വേണ്ടി wait ചെയ്തിരിക്കുവയിരുന്നു,,, എന്റെ കയ്യില്‍ കുറെ jokes ഉണ്ട് you know.

എന്റെ കയ്യില്‍ ഉണ്ടായിരുന്ന ഏറ്റവും funny അയ ഒരു joke ങ്ങനെടുത്തു പ്രയോഗിച്ചു...

ഒരു ദിവസം ഞാന്‍ tarin ല്‍ യാത്ര പോകുവായിരുന്നു,,, from Bangalore to ernakulam. And I liked the upper berth very much,,, കുറച്ചു ചൂടെടുക്കുമെന്കിലും സുഘമായി കിടന്നുറങ്ങാം. ഒരു എട്ടു മണിയയപോഴേക്കും ഞാന്‍ ബെര്‍ത്തില്‍ കേറിക്കിടന്നു, അലറോം set ചെയ്തു and I started sound sleep.

One advice അലരത്തിനെ എപ്പോഴും വിശ്വസിക്കരുത് കേട്ടോ,,, ഒരിക്കല്‍ ഞാന്‍ ernakulam thivandrum വേണാട് express ല്‍ കേറിക്കിടന്നു, ഒന്‍പതു മണിക്ക് അലറോം set ചെയ്തു,,, ആ പഹയന്‍ ഒന്‍പതു കഴിഞ്ഞിട്ടും മിണ്ടിയില്ലാ,,, അവനേം കുറ്റം പറയാന്‍ പറ്റില്ല രാത്രി ഒന്‍പതു എന്നത് അവനോടു 21:00 എന്നുപറഞ്ഞ്‌ കൊടുക്കേണ്ടതെന്ന് ഞാനും ഓര്‍ത്തില്ല...

Back to the story,,, ഇടയ്ക്കു ഞാന്‍ കണ്ണുതുറന്നപ്പോള്‍ train നിര്‍ത്തിയിട്ടിരികുവാ,,, and I heard someone shouting ആലുവ,,, ആലുവ,,, ആലുവ… ഹോ ആശ്വാസമായി ആലുവ എത്തി അടുത്ത stop ernakulam. ഞാന്‍ ഒന്നും നോക്കാതെ berth ‍നിന്നു ചാടി ഏറന്ജി. ഓടിപ്പോയി മുഖം കഴുകി പുറത്തേക്കു നോക്കിയപ്പോഴാ,,, തമിഴ്നാട്ടിലെ ഏതോ ഒരു സ്റ്റോപ്പ്‌ല് വണ്ടി നിര്‍ത്തിയിട്ടിരിക്കുവാ,,, and ഏതോ ഒരു പഹയന്‍ അലുവ വില്‍ക്കാന്‍ വിളിച്ചു പറഞ്ഞു കൊണ്ട് പോയതാ…

Berth ല്‍ നിന്ന് ഇറങ്ങുന്നതിനു മുന്‍പ് ഞാന്‍ സമയം നോക്കിയില്ല,,, അലാറം അടിച്ചില്ല്ല എന്നോര്‍ത്തില്ല,,, and ഒരുത്തനും ആലുവ എത്തുമ്പോള്‍ ബസിലെ പോലെ വിളിച്ചു പറയില്ല എന്നും ഓര്‍ത്തില്ല,,, very bad എന്റെ ഒരു കാര്യം ഞാന്‍ ഓര്‍ത്തു.

ഇത്രയും പറഞ്ഞിട്ടും കൂടെയിരുന്ന ഒരുത്തനും ചിരിച്ചില്ല,,, I felt very bad,,, that was the best I had...

അവന്മാരെ convince ചെയ്യിപ്പിക്കാനായി ഞാന്‍ പറഞ്ഞു,,, dai നീ അടുത്ത പ്രാവശ്യം പോകുമ്പോള്‍ ശ്രദ്ധിച്ചാല്‍ മതി ഇപ്പോഴും തമിള്‍ നാട്ടിലെ ഏതോ ഒരു stop ല്‍ ഒരുത്തന്‍ അലുവ വില്‍ക്കാന്‍ വിളിച്ചോണ്ട് നടക്കുന്നത് കേള്‍ക്കാം.

ഇത്രേം പറഞ്ഞപ്പോള്‍ എല്ലാരുംകൂടെ ഒറ്റച്ചിരി,,, അവരത്‌ decode ചെയ്തെടുത്തു, ഒരുപ്രാവശ്യം മാത്രമല്ല,,, ആ അലുവക്കാരന്‍ എല്ല്ലാ പ്രാവശ്യവും എന്നെ പറ്റിക്കാറുണ്ട്...

എന്തായാലും ഞാന്‍ happy ആയി... എന്റെ ഒരു താമസകെട്ടു എല്ലാരും ചിരിചല്ല്ലോ.

20 June 2009

പന്തയം

ഡല്‍ഹിയിലെ ഒരു സാധാരണ ബാറില്‍, കുടിയന്മാരുടെ പതിവ് 'കലാപരിപാടി' നടന്നു കൊണ്ടിരിക്കുകയായിരുന്നു. ഇടയ്ക് കടന്നുവന്ന, ഒരു പണക്കാരന്‍ കുടിയന്മാരേ വെല്ലുവിളിച്ചു.

"നിങ്ങള്‍ക്ക്‌ ആര്‍കെങ്കിലും പന്ത്രണ്ടു കുപ്പി ബിയര്‍ ഒറ്റയിരിപ്പില്‍ ഇടവിടാതെ കുടിക്കാന്‍ പറ്റുമോ? അങ്ങനെ ആരെങ്കിലും കുടിച്ചാല്‍ പതിനായിരം രൂപ ഞാന്‍ തരുന്നതായിരിക്കും. ഇടയ്ക് വച്ച് തൊട്ടാല്‍ നിങ്ങള്‍ എനിക്ക് ആയിരം രൂപ തരണം."

കുടിയന്മാര്‍ ആരും ഒന്നും മിണ്ടിയില്ല, സാധാരണയായി അഞ്ചു കുപ്പിയില്‍ കുടുതല്‍ അവിടെനിന്നും ആരും കുടികാറില്ല. അതുകൊണ്ട് തന്നെ ആരും മുന്നോട്ട്‌ വന്നില്ല.

അവിടെ ഉണ്ടായിരുന്ന എക മലയാളി എറങ്ങി പോവുകയും ചെയ്തു; അര മണിക്കൂര്‍ കഴിഞ്ഞപ്പോള്‍ മടങ്ങി വന്നു.

"സാര്‍ ഇപ്പോഴും ആ പന്തയം നിലവില്‍ ഉണ്ടോ?"
"ഉണ്ടല്ലോ."
ഉടനെ തന്നെ പന്ത്രണ്ടു കുപ്പി കൊണ്ടുവന്നു മലയാളിക്ക് കൊടുത്തു.
"ഇതാ കുടിച്ചോളു"
"ഒറ്റയിരുപ്പിന് ഒട്ടും സമയമെടുകാതെ അയാള്‍ അത് കുടിച്ചു തിര്‍ത്തിട്ട് അച്ചാര്‍ തൊട്ടു നക്കുകയും ചെയ്തു".
ബാറില്‍ ഉണ്ടായിരുന്ന എല്ലാവരും ഹരഘൂഷത്തോടെ മലയാളി അയ യുവാവിനെ ആദരിച്ചു.

പതയക്കാരന്‍ അത്ഭുതത്തോടെ ചോതിച്ചു, "നിനക്ക് എന്തിനെ ഇതിനു കഴിഞ്ഞു?"
യുവാവ് പറഞ്ഞു, "പതിനായിരം രുപയായത് കൊണ്ട് ഒന്ന് ശ്രമിച്ചു നോക്കിയതാണ്".
"കൊള്ളാം എനിക്ക് നിന്നെ ഇഷ്ടപ്പെട്ടു, ഇതാ നിന്റെ രൂപ"
അയാള്‍ രൂപ എണ്ണി കൊട്ത്തിട്ടു ചോതിച്ചു, "ആട്ടെ എയെന്താണ് പന്തയംവച്ച സമയത്ത് ഇറങ്ങിപ്പോയത്"

യുവാവ് പറഞ്ഞു, "അടുത്ത ബാറില്‍ പോയി ഒന്ന് പരിക്ഷിച്ചു നോക്കാനായിരുന്നു".

Segway PT

In December 2001, renowned inventor Dean Kamen unveiled the Segway Personal Transporter (PT). The Segway PT is a two-wheeled, self-balancing electric vehicle.



Segway PTs are driven by electric motors at up to 12.5 mph.
The dynamics of the Segway PT are identical to a classic control problem, the inverted pendulum.
Users lean forward to go forward, lean back to go backward, and turn by using a "Lean Steer" handlebar, leaning it left or right.
Gyroscopic sensors are used to detect tilting of the device which indicates a departure from perfect balance.

18 June 2009

Prime Number

Program to check whether a given number is prime or not.
---------------prime.erl---------------
-module(prime).
-export([start/1]).

start(Num) ->
prime(2, Num).

prime(_, 1) ->
io:format("Prime number!!!~n", []);
prime(Num, Num) ->
io:format("Prime number!!!~n", []);
prime(N, Num) ->
if((Num rem N) == 0) ->
io:format("Not a prime number!!!~n", []);
true ->
prime(N+1, Num)
end.
---------------------------------------
Save the code with the filename prime.erl
$ erl
Erlang (BEAM) emulator version 5.6.3.2 [source] [async-threads:0]
Eshell V5.6.3.2 (abort with ^G)
1> c(prime).
{ok,prime}
2> prime:start(53).
Prime number!!!
ok
3> prime:start(51).
Not a prime number!!!
ok

17 June 2009

Why I fired my secretary……….

Last week was my birthday and I didn't feel very well waking up on that morning.
I went downstairs for breakfast hoping my wife would be pleasant and say,
'Happy Birthday!', and possibly have a small present for me.

As it turned out, she barely said good morning, let alone ' Happy Birthday.'

I thought...
Well, that's marriage for you,
but the kids... They will remember.

My kids came bounding down stairs to breakfast and didn't say a word. So when I left for the office,

I felt pretty low and somewhat despondent.

As I walked into my office, my secretary Jane said, " Good Morning Boss, and by the way Happy Birthday ! "

It felt a little better that at least someone had remembered. I worked until one o'clock , when Jane knocked on my door
and said, "You know, It's such a beautiful day outside, and it is your Birthday, what do you say we go out to lunch,
just you and me."

I said, "Thanks, Jane, that's the greatest thing I've heard all day. Let's go !"

We went to lunch. But we didn't go where we normally would go.

She chose instead at a quiet bistro with a private table. We had two martinis each and I enjoyed the meal tremendously.

On the way back to the office, Jane said, "You know, It's such a beautiful day... We don't need to go straight back to the office,
Do We ?"

I responded, "I guess not. What do you have in mind ?"

She said, "Let's drop by my apartment, it's just around the corner."

After arriving at her apartment, Jane turned to me and said, " Boss, if you don't mind, I'm going to step into the bedroom
for just a moment. I'll be right back."

"Ok." I nervously replied.

She went into the bedroom and, after a couple of minutes, she came out
carrying a huge birthday cake...

Followed
by my wife,

my kids,

and dozens of my friends

and co-workers,

all singing 'Happy Birthday'.

And I just sat there...
.
.
.
.
.
.
.
.
.

On the couch...
.
.
.
.
.
.
.
.
.
.

Naked...!!!!!!!!

16 June 2009

VLAN

LAN

o A LAN is a shared communication system to which many computers are attached.
o LAN is also defined as a single broadcast domain.
o Ethernet and Wi-Fi are the commonly used LAN technologies.

-> LANs are OSI layer 2 technologies.
-> LANs use arbitration method called CSMA/CD.
-> LANs contain their own broadcasts and addressing schemes.
-> The workstations, hubs, and repeaters together form a collision domain.
-> Bridges and switches limit collision, but will allow broadcasts and multicasts to pass through.
-> And the L3 device, router prevents broadcast and multicast from travelling across the network.

With the transmission speed Ethernet is further divided:
Ethernet   -> 10 Mbits/sec
Fast Ethernet -> 100 Mbits/sec
Gigabit Ethernet -> 1000 Mbits/sec
10Base-5 -> 10Mbps, Coaxial cable, 500 meters
10Base-T -> 10Mbps, Twisted-pair cable, 100 meters
10Base-FL -> 10Mbps, Fiber-optic cable, 4 Km

VLAN

o VLAN groups collection of machines in a logical and non physical way.
o VLANs allow a network manager to logically segment a LAN into different broadcast domains, irrespective of physical location.
o VLAN is defined as a broadcast domain within a switched network.

-> VLAN reduces the broadcast domain at the MAC layer.
-> VLAN restricts access to network resources.
-> Traffic from one VLAN to another is possible only through a router.

IEEE 802.1Q (VLAN Tagging or dot1q), Cisco’s Inter-Switch Link, 3Com’s Virtual LAN Trunk are the commonly used protocol to configure VLAN.



12bit VID = (4096-2) VLANs are possible in a switch.

Types of VLAN's:
VLAN membership can be classified by port, MAC address, and protocol type.

1. Layer 1 VLAN: Membership by Port
   a. User mobility is restricted.
2. Layer 2 VLAN: Membership by MAC Address
   a. Manual configuration of MAC and VLAN membership required.
3. Layer 2 VLAN: Membership by Protocol Type
   a. It’s based on protocol type field in L2 header.
4. Layer 3 VLAN: Membership by IP Subnet Address
   a. Static IP should be configured in PC.
5. higher layer VLAN: Membership by application type

Protocol type based, IP subnet based and higher layer application based VLAN are not mentioned in the standard, hence these VLANs remains proprietary.

The Nortel ERS4500 supports up to 256 VLANs.
The Nortel ERS4500 supports VLAN types:
1. IEEE 802.1Q port-based VLANs
   a. vlan create 16 name red type port
   b. vlan members remove 1 2-12
   c. vlan members add 16 2-12
   d. vlan ports 2-12 pvid 16
2. Protocol-based VLANs
   a. vlan create 16 name test type protocol-Netbios

VLAN support in Linux:
Networking options -> 802.1Q VLAN Support
This module generates driver with the name 8021q.o

modprobe 8021q
vconfig add eth0 16
ifconfig eth0.16 192.168.16.2 netmask 255.255.255.0
ping 192.168.16.1

it could be observed that all packets coming from eth0.16 is tagged with VLAN ID 16.

Ethernet II frame
+-----------+----------+----------+-----------+----------+
|Destination|Source MAC|Frame type|Data | CRC |
|MAC Address|Address |(IP, ARP) |(46 to | Checksum |
|(6 bytes) |(6 bytes) |(2 bytes) |1500 bytes)| (4 bytes)|
+-----------+----------+----------+-----------+----------+
14(Ethernet) + 1500(DATA) + 4(CRC) = 1518
14(Ethernet) + 4(VLAN) + 1500(DATA) + 4(CRC) = 1522
14(Ethernet) + 4(vlan) + 20(IP) + 20(TCP) +1460(DATA) + 4(CRC)

Reference:
http://www.linktionary.com/l/lan.html

Bandwidth Management in Linux

The wide usage of VOIP and VPN in enterprise network made IP very popular. However, IP suffers a small handicap. Unlike protocols such as ATM, it treats everyone equally. With Transmission Control this drawback is patched.

The ability to divvy up bandwidth owned by a service provider for QoS is referred to as “bandwidth management”. TOS, RSVP, diffserv are the different type of bandwidth management techniques available.

Linux can do transmission control for outgoing packets.
The following modules enable QoS support in Linux:
Networking options -> Netlink device emulation
Networking options -> Network packet filtering
Networking options -> Qos and/or fair queueing -> CBQ packet scheduler
Networking options -> Qos and/or fair queueing -> HTB packet scheduler
Networking options -> Qos and/or fair queueing -> ***

Qdisc - queueing discipline. These are used to give traffic classes different behaviour. (CBQ, PRIORITY, CSZ).
Class - some qdiscs are classful and can have a hierarchy - sort of a tree under them. These trees compose of classes. (FIFO, SFQ, HTB).
Filter - a filter examines a packet and sends it somewhere down the hierarchy (i.e. to classes). (RSVP classifier, u32 classifier).

Each interface has a root qdisc, and the packets pass through the qdisc. Filters attached to qdisc decide to which class the packet should send. The queue attached to the leaf class does the packet scheduling.
The root qdisc gets dequeued by the kernel. The request passes through the entire tree and the scheduling happens at the leaf node. The upshot of this is that classes never get dequeued faster than their parents allow.

Inbound Shaping
tc qdisc add dev imq0 root handle 1: htb default 2
tc class add dev imq0 parent 1: classid 1:1 htb rate 1000000kbit ceil 1000000kbit prio 0 quantum 57000

tc class add dev imq0 parent 1:1 classid 1:2 htb rate 1000000kbit ceil 1000000kbit prio 1 quantum 57000
tc qdisc add dev imq0 parent 1:2 handle 2: sfq perturb 10

iptables -t mangle -A PREROUTING -i eth0 -j IMQ --todev 0
iptables -t mangle -A POSTROUTING -o eth0 -j IMQ --todev 0

tc class add dev imq0 parent 1:1 classid 1:65 htb rate 9000kbit ceil 9000kbit prio 2 quantum 57000
tc qdisc add dev imq0 parent 1:65 handle 65: sfq perturb 10

tc class change dev imq0 parent 1:1 classid 1:2 htb rate 991000kbit ceil 1000000kbit prio 0 quantum 57000

tc filter add dev imq0 parent 1: protocol ip prio 2 handle 0x65 u32 match ip dst 192.168.10.160 flowid 1:65
tc filter add dev imq0 parent 1: protocol ip prio 2 handle 0x65 u32 match ip src 192.168.10.160 flowid 1:65

1: root qdisc
|
1:1 child class
/ | \
/ | \
/ | \
/ | \
1:2 1:65 1:66 child classes
| | |
| | |
| | |
2: 65: 66: qdisc

All the packets reaching eth0 after PREROUTING and all the packets leaving eth0 after POSTROUTING are forwarded to imq0, using iptables command.
A tc filter is configured to forward all IP packets to/from 192.168.10.160 to class 1:65.
The class 1:65 is configured to limit the transmission rate.

Reference:
http://www.linuxexposed.com/content/view/105/1
http://tldp.org/HOWTO/html_single/Traffic-Control-HOWTO

14 June 2009

iptables mystery

Iptables is the firewall and packet filtering replacement for Ipchains in the Linux 2.4 kernel.
Iptables is the user space tool used to configure the packet filtering and NAT rules within the kernel.

Each table contains a number of built-in chains and may also contain user-defined chains. Each chain is a list of rules which specifies what to do with a packet that matches.



iptables -A INPUT -p tcp --dport 22 -s 192.168.10.160 -j REJECT

This command appends a chain to the table FILTER and chain INPUT, the rule instructs to drop all the tcp packets coming to port 22 from machine 192.168.10.160.


iptables –N SSH
iptables –A SSH –p tcp –s 192.168.10.160 –j LOG
iptables –A SSH –p tcp –s 192.168.10.160 –j REJECT
iptables –A SSH –j ACCEPT

iptables –A INPUT –p tcp --dport 22 –j SSH

This set of commands creates an SSH chain and add set of rules to it. It tells to LOG and REJECT the connection coming from 192.168.10.160, and to ACCEPT all the other connections.
Finally all the tcp packets to the port 22 reaching FILTER table and INPUT chain are forwarded to SSH chain.

Reference:
http://www.frozentux.net/iptables-tutorial/chunkyhtml