This section describes the Netfilter hooks and the sequence of events as a packet traverses the kernel space. At each of these hooks, the kind of processing done on the packets is also briefly discussed.
PREROUTE Hook: This hook is called before any processing is performed on the packet. This is the hook where we get our first opportunity to inspect, or modify, or drop the packet. The actions that are performed here are as follows:
Control actions are performed only for packets whose destination is not the current node, else the actions are performed in LOCAL_IN hook.
It is in PREROUTE that route replies, route errors, and source routed packets are handled.
If the current node is not the destination, then these packets are forwarded to the next hop after performing necessary actions.
All source routed packets destined for the current node are accepted after stripping its Meghadoot header, while pure control packets are directly accepted.
If the destination of a packet is a REALLY OUTSIDE NODE, then the Meghadoot header is stripped and the packet is accepted, i.e., it is routed according to the kernel routing tables4.1.
If the destination of a packet is an OUTSIDE NODE, then the Meghadoot header is stripped, after which the packet is tunneled to the IN (foreign agent) where the destination is currently registered4.1.
FORWARD Hook: After the PREROUTING stage, input routing is performed on the packet. If the destination of the packet is not the current node, then the FORWARD hook is called. The Meghadoot implementation does not make use of this hook.
LOCAL_IN Hook: After input routing, if it is found that the destination is the local node, the LOCAL_IN hook is called. Bulk of the packet processing is performed at this hook.
Route requests, registration requests, AP beacons, registration acknowledgements, requests from a foreign agent and acknowledgements from a home agent are handled at this stage4.2. All pure control packets (these are the only packets which still have the Meghadoot header) are dropped after they have been handled appropriately.
If the packet received is a tunneled packet4.1(received from the HA of a node) and the destination is currently registered as a foreign node, then the packet is untunneled (the tunnel header is removed), after which the packet is source routed to the destination.
LOCAL_OUT Hook: This hook is called for all the packets which are generated within the local system. At this hook Meghadoot protocol header is inserted into all the packets that are leaving the system, except in the case when the current node is an IN and if the destination is either a node of the type REALLY OUTSIDE NODE or has moved out and registered with another IN (in this case, the packet is tunneled to the foreign IN). The way a packet is routed and transmitted is dependent on the type of the current node.
At an MN: A route request is made to the IN and the packet is forwarded based on the route reply received from the IN (refer Section 3.2.2 and Section 3.4)
At an IN: An IN routes the packet based on the type of the destination node and sends it appropriately as explained in Subsection 3.4.1.
POSTROUTE Hook: The POSTROUTE hook is called just before a packet is transmitted through the network device. In a Meghadoot network a POSTROUTE Hook is used only at an IN. When an IP packet is received from outside the CZ and the packet is destined to a node which is registered with the HA as this IN, then the packet is handled appropriately by the IN. If the destination is in the same CZ, the packet is source routed. If the destination is of the type OUTSIDE NODE, then the packet is tunneled to its FA.