Saturday, April 4, 2009

MIT click Router Configuration

Hello Friends....
If u want to forward the packets coming to your machine to other machine in your machine by MIT Click Router.
Then Here is the code...
Initially U have to install the MIT Click Router.
Follow these steps....

Download tar file (click-1.6.0.tar.gz) from http://read.cs.ucla.edu/click/download
• % tar xzvf click-1.6.0.tar.gz
• % cd click-1.6.0
• % ./configure –disable=nsclick –enable=userlevel –disable=linuxmodule
• % cd click-1.6.0/userlevel
• % make
• % ./click /root/Click-MIT-router/click-1.6.0/conf/test.click
This command executes simple router configuration program, if installed properly we see the output as follows:
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369

/* If u get output what is above then u have done with the first step....*/

Now the file to send the packets coming to your machine to another machine.

ForwardYourPacketsToOtherMachine.click

//Define the variables that used in the program//

define(
$DEV eth0,
$SRC_ADDR 10.6.21.209, //Change this address by your address
$DST_ADDR 10.6.21.207, //Change this address by ur neighbor's address
$IP_ETHER 0x0800,
$SRC_ETHER 00:1c:c0:a7:82:04, //Change by your hardware address
$DST_ETHER 00:1c:c0:a7:82:0a //Change by your neighbor's H/W address
);
//Take the queue for storing the packets to send to the eth0 interface with new destination and source address//

Put_to_dev_q :: Queue(5000);

//Take the input packet form the eth0 device | Syntax: FromDevice(Device) //

FromDevice($DEV)
-> Classifier(12/0800) //Classify the incoming ethernet packets payload is IP packet or something other packet
-> Print("OLD ETHER") //Print this Ethernet packet with label "OLD ETHER"
-> EtherEncap($IP_ETHER, $SRC_ETHER, $DST_ETHER) //Put 0x0800 in type/length field of ethernet packet and source H/W
-> Print("NEW ETHER") //and dest H/W address as given to this function
-> IPAddrPairRewriter(pattern 10.6.21.209 10.6.21.207 0 0) //It will add source IP and Destination IP address which has come on
-> IPPrint("NEW IP") //0 input Port and going on 0 output port & print this IP Packet
-> Put_to_dev_q; //put this packet to the queue to send this to eth0 device for tx.


Put_to_dev_q
->ToDevice($DEV); //Transmit the packet from the eth0 device...

/* END of Program*/
The hardware address can be seen in Linux Machine by "ifconfig" command
in Windows "ipconfig -all" command

Run this program as ...
Go in the folder Click/userlevel there is a binary file named "click"

./click your/programs/path

e.g.

./click ~/ClickExamples/ForwardYourPacketsToOtherMachine.click



Kepp Enjoying ......