Sunday, May 17, 2009

Ethernet Framing

Distinguishing Between Ethernet Frame Types

1) Receive good frame.
2) Analyze frame. Perform the following steps, in order:


If the EtherType/Length value is greater than 0x05-DC (decimal 1500), then process the frame as Ethernet II. Any EtherType value greater than 0x05-DC (such as 0x0800 for IP or 0x81-37 for NetWare IPX/SPX) will be interpreted as an Ethernet II frame.

If the IPX header (0xFF-FF) follows the Length field, the frame is interpreted as a 802.3 (Raw) frame with Netware IPX/SPX traffic. Standard SSAP and DSAP values do not include hexadecimal FF, so the 802.3 (Raw) frame can be distinguished from LLC frames (Ethernet SNAP, 802.2).

Next, the byte following the length field (DSAP) is examined. If the value is 0xAA, the frame is interpreted as a SNAP frame. Otherwise, it is interpreted as a 802.2 frame.

Thursday, April 23, 2009

Flipping burgers and bits is not same

How do we flip bits in a integer from p1 to p2 locations in C? Here is the macro for it.
#define flip_bits(x, p1, p2) (x ^ (((unsigned int)~0 >> ((sizeof(int) * 8) - (p2-p1+1))) << p1))

Sunday, April 19, 2009

Traceroute - How it works?

Traceroute is a Linux/Unix utility that is used to find all the routers along the destination host. It works by sending 3 UDP datagrams with destination ports numbers from 33434 to 33534 at a time
with TTL value starting with 1 till the destination is reached. Each router along the way send back ICMP message when it sees TTL value = 1.
A similar utility used in Windows, tracert does not use UDP packets but ICMP echo request (type 8) instead as in the case of ping.

Wednesday, April 1, 2009

Closures

Closures achieve lexical scoping.

Tuesday, March 31, 2009

What's up with C++?

As a software developer in networking industry, I have found recently that C++ is still used by handful of companies to implement protocols and standards. So I thought I will blog about my C++ learning trail as I unravel this powerful yet quite complex language. I have looked into the code snippets from the open source implementation of some common protocols at XORP. To begin C++ to me looks like the following 5 things:

1. Copy Constructor
2. Assignment Operator
3. Destructor
4. RAII
5. STLs