This project aims to forward data to any destination you want. Unlike kernel LVS, it makes forward decision by your instruction. After client connects to forwarder, the first package sent is used for making decision, then the following data is transmitted as usual.
Actor: Client ---> Forwarder ---> Real Server
- Forwarder create a user program, and listen on a tcp port waiting for client connection.
- Client call "connect" system call to connect Forwarder, then send Instruction to Forwarder.
- After receiving instruction, Forwarder record the connection file description(fd-c), and parse the instruction data.
- After parsing instruction data, Forwarder connect the Real Server, and record the connection file description(fd-s).
- After the dual connection is finished, Forwarder build a data struct containing fd-c, fd-s, and the tcp sequence number difference value. Then a acknowledge response to sent back to Client.
- Client receives the response, start the normal data transmission.
- Connection listener, a daemon running on user mode, aims to accept the connection from client and parse the instruction data, and initiate connection to real server. Then notify the kernel forwarder the dual connection file description.
- Kernel forwarder, a netfilter module running on kernel mode, modify the package data , and forward it to real server.
/proc/forwarder is root folder for configuration, under which the files and the corresponding functionality are listed by the following.
- listen_port, sets the tcp port which is listened by connection listener, accepting new connection from clients.
- forward, listener daemon writes socket file description pair to this file, corresponding to the upper fd-c and fd-s.
- show , shows all connection pairs that are handled by forwarder.