View on GitHub

COMP4511

COMP4511 network assignment tasks

Makefile update

If the source file has been changed, you need to update the name of the object file to match the new source file containing the module init_module and exit_module macros and the definition functions. SEE Makefile for more information.

Notice, you can include other source and header files but under the condition that there is a single source file containing the neccessary init_module and exit_module macros and their function.

Installation steps

change your current directory to to where the source and Makefile is located then issue:

git clone https://github.com/ahmedcs/comp4511.git
cd comp4511/drop_pkts
make

Now the output files is as follows:

drop_pkts.o and drop_pkts.ko

The file ending with .o is the object file while the one ending in .ko is the module file

Run

To install the module into the kernel

sudo insmode drop_pkts.ko

Note that the parameters of the module are:
1- port: the TCP port number of applications that needs to be tracked, 0 is the default which tracks all ports.
2- enable: enable the module to intercept and drop packets.
3- debug: debug will output the different logs on the kernel log (dmesg | tail) to display them.
4- pcount: the number of packet to accept before dropping (by default 1000).

However to call the module with different parameters issue the following:

sudo insmod drop_pkts.ko port=80 enable=1 debug=1 pcount=1000;

Stop

To stop the drop_pkts module and free the resources issue the following command:

sudo rmmod -f drop_pkts;