Monday, April 4, 2011

Recalculating TCP and IP checksums in netfilter modules

Here is how you recalculate ip and tcp checksums if your netfilter kernel module tinkers with packets.

len = skb->len;
th->check = 0;
th->check = tcp_v4_check(len - 4*iph->ihl,
iph->saddr, iph->daddr,
csum_partial((char *)th, len-4*iph->ihl,

iph->check = 0;
iph->check = ip_fast_csum((u8 *)iph, iph->ihl);

Wednesday, March 23, 2011

Wednesday, February 23, 2011

TCP timers

Timers in TCP- Apparently TCP in linux uses a single timer that times the oldest packet in the window. So rest of the packets in the window get additional advantage in terms of timeout.
Here is the timer wheel concept as used in some other OSes.

Custom kernel development for android

Here is a tutorial on building a kernel and running a custom kernel for the android emulator..

modules in android goldfish

Here is a short tutorial on compiling and loading modules in the android goldfish kernel.

A good book for understanding the TCP/IP stack in Linux

TCP/IP Architecture, Design and Implementation in Linux

Saturday, November 8, 2008

The thing about luck..

I just had a gruelling (:P) practical exam. it was a combo of 3 theory subjects..The discussions before and after the exam typically revolve around how luck favoured some while some got really i-got-zombie-assignment-done-in-5-min to i-got-intermediate-code-changed :P :) Even i am a part of these animated discussions..
These discussions set met thinking about that thing called "luck". Sometimes it does appear that some people have it very easy while some have to struggle in spite of working hard. But should we be blaming luck.. Is there anything like being-completely-fair..Even fortune favours the brave..When we cringe about bad luck, do we remember our share of those moments when we got really lucky..Or is good luck passed off as a-just-reward-for-my-hard work :) If we keep a count of good-luck and bad-luck moments, would both sides match..I think so..Only the timing of that lucky and unlucky moment differs.Should we take recourse to bad luck as an explanation to our poor performance or should we just accept that we should have worked harder. PU vice-chancellor Narendra Jadhav says-everything that he wanted,he achieved it by himself and his own hard work.There were no strokes of luck..(credits to hardik for telling me about this). It will all even out in the end..those who struggle harder now may go on to achieve greater heights later..Those who got unlucky this time may have got damned lucky some other important time.. So no more blaming luck for me..I am gonna accept whatever come my way with equanimity..:) :D :P