Saturday, February 25, 2012

More neutrino jokes

Here are some neutrino jokes collected from around the web:
-We don’t allow faster than light neutrinos in here, said the bartender. A neutrino walks into a bar.
- Neutrino. Knock knock.
- Hipsters liked neutrinos before they arrived.
- I wrote a speed of light joke…but a neutrino beat me to it.
- A. To prove particles can travel faster than light Q. Why did the neutrino cross the road?
- I’m going to tweet my neutrino joke yesterday.
- Want to hear a joke about neutrinos? It’d probably go straight through you.
- If that #neutrino is faster than light does that explain why physicists never saw it coming?
Do neutrinos go faster than light?
Some physicists think that they might.
In the cold light of day,
I am sorry to say,
The story is probably shite.
- lumidek LuboŇ° Motl

Friday, February 24, 2012

How to block indent code in vi or vim

The > command is to be used.

* To indent a block of 5 lines use 5>>

* To visually edit a block of lines use vjj> 
(v will start the visual mode, jj will select the lines to be indented, and > will result in the indent).

* To indent a curly-braces block, put your cursor on one of the curly braces and use >%

* If you’re copying blocks of text around and need to align the indent of a block in its new location, use ]p instead of just p. This aligns the pasted block with the surrounding text.

Running multicast traffic with iperf

Run an iperf server, and bind it to a multicast address:
mymachine1:/root# iperf -s -u -B 224.0.55.55 -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Binding to local address 224.0.55.55
Joining multicast group  224.0.55.55
Receiving 1470 byte datagrams
UDP buffer size: 41.1 KByte (default)
Run the multicast client. This will send the required IGMP messages. If your router has IGMP snooping enabled, multicast should work smoothly.
mymachine2:/root# iperf -c 224.0.55.55 -u -T 32 -t 3 -i 1
------------------------------------------------------------
Client connecting to 224.0.55.55, UDP port 5001
Sending 1470 byte datagrams
Setting multicast TTL to 32
UDP buffer size: 9.00 KByte (default)
------------------------------------------------------------
[  3] local 10.1.10.3 port 51296 connected with 224.0.55.55 port 5001
[  3]  0.0- 1.0 sec    129 KBytes  1.06 Mbits/sec
[  3]  1.0- 2.0 sec    128 KBytes  1.05 Mbits/sec
[  3]  2.0- 3.0 sec    128 KBytes  1.05 Mbits/sec
[  3]  0.0- 3.0 sec    386 KBytes  1.05 Mbits/sec
[  3] Sent 269 datagrams
IGMP messages seen by sniffing packets:
mymachine3:/root# tcpdump -nevv -i xl0 -s 1515 igmp
tcpdump: listening on xl0, link-type EN10MB (Ethernet), capture size 1515 bytes
06:28:40.887868 00:c0:aa:1c:77:85 > 00:c0:aa:1c:33:99, ethertype IPv4 (0x0800),
 length 46: (tos 0x0, ttl   1, id 59915, offset 0, flags [none], proto: IGMP (2),
 length: 32, options
 ( RA (148) len 4 )) 10.1.10.2 > 224.0.55.55: igmp v2 report 224.0.55.55
06:28:42.196233 00:c0:aa:1c:77:85 > 01:00:5e:00:00:02, ethertype IPv4 (0x0800),
 length 46: (tos 0x0, ttl   1, id 59920, offset 0, flags [none], proto: IGMP (2),
 length: 32, options
 ( RA (148) len 4 )) 10.1.10.2 > 224.0.0.2: igmp leave 224.0.55.55

 * MAC addresses have been changed for privacy.

Why a bash script cannot change environment variables

Read in an online forum:
Your shell process has a copy of the parent's environment and no access the parent process's environment whatsoever. When your shell process terminates any changes you've made to its environment are lost. Sourcing a script file is the most commonly used method for configuring a shell environment, you may just want to bite the bullet and maintain one for each of the two flavors of shell.

Thursday, February 23, 2012

Difference between L2 (layer 2) and L3 (layer 3) multicast

MAC Multicast address generation

Why is multicast dealt with at two layers?
Multicast was initially designed as a layer 3 functionality, where multple hosts from a network could subscribe to a multicast address.
However, the major deficiency in such an approach is that after a router has decided which port to forward packets from a particular multicast to, the IP layer multicast is usually translated to a MAC broadcast on a switch. This results in several inefficiencies. L2 frames are received by host which are not desired. In order to avoid this the switch does IGMP snooping (read over hearing), and marks ports on the switch which are subscribing to that multicast. It then keeps track of the ports by using a destination multicast address that is obtained by conversion of the L3 multicast address to L2 multicast frame address

Conversion of L3 multicast address to L2 MAC address: (based on information on a microsoft website)
"To support IP multicasting, the Internet authorities have reserved the multicast address range of 01-00-5E-00-00-00 to 01-00-5E-7F-FF-FF for Ethernet and Fiber Distributed Data Interface (FDDI) media access control (MAC) addresses. As shown in Figure above, the high order 25 bits of the 48-bit MAC address are fixed and the low order 23 bits are variable."

Two approaches to implementing multicast on switches:
* Pure IGMP snooping in L2 switches
* Deep packet IGMP inspection in L3 switches

Wednesday, February 22, 2012

Check the number of file systems supported on Linux

Maintained under /proc.

Virtual file system  is the system call interface and maintains and registers all file systems in a linked list as shown in the fig above.

Files and directories are maintained as Inodes
Root of the filesystem: Superblock
Operations supported on superblock: create_inode, destroy_inode, read_inode, and write_inode among others.

Command to check the file systems supported on your machine:
cat /proc/filesystems

Checking the mounted file systems along with their mount points:
mount