This is a fully operational project (written in C) demonstrating how to develop a Linux Kernel Module that is able to listen to incoming connections.
Every component of this project evaluates the following:
- Construction of a simple program using methods of layering, error detection and recovery, and reflection of error status across layers
- Implementation of a simple client-server socket-based application
Clone this repository by git clone https://github.com/tyeborg/client-server-socket-app.git
- To build the Linux Kernel Module, you will need to run the following command line in your Linux Machine to install Linux Kernel Headers:
sudo apt install linux-headers-$(uname –r)
- Open a terminal to commence initialization of the Kernel module. (To build the Kernel module, the Makefile is needed)
The content within the Makefile is displayed below:
obj-m += server.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
-
With the existence of the Makefile, enter make into the command line to build the Kernel module.
-
Once the Kernel module is built, install it by using the following insmod terminal command:
sudo insmod server.ko
Viola! At this point, the Kernel module launched a kernel thread which will listen to incoming connections on the defined port of 5000.
- Open a separate terminal to build the Client module.
- Build the Client module using
gcc client.c -o client
on the terminal. - Run the Client module using
./client
on the terminal.
- Build the Client module using
Fantastic, the Client module and the Kernel module are running simultaneously! Now it is time to establish a connection between them...
-
As the Kernel module is listening to incoming connections, the client [you] can fulfill them if and only if both modules are running on the same port. Therefore in the Client module, ensure 5000 is entered when prompted with which port to connect to.
-
When a connection is received, enter the absolute filename that is desired to be read (in the Client module).
To access kernel messages that are printed onto the log, use the following command in the terminal: dmesg
"Kernel module builds and runs, but it doesn't seem to always get a file, and cannot reconnect. So, generally working and well put together with a few bugs in place." - Kevin Chalmers
- Solution:
Excellent
(A running solution meeting all the specification) - Correctness:
Good
(Program produces correct answers or appropriate results for the majority of inputs) - Logic:
Excellent
(Program logic is correct with no known boundary errors, and no redundant or contradictory conditions) - Robustness:
Good
(Program handles almost all erroneous or unexpected input gracefully without surprising the user) - Error Freedom:
Good
(All obvious errors are removed but there are some smaller issues not rectified -- Program will compile and run) - Clarity:
Excellent
(Program contains appropriate documentation for all major functions, variables, or non-trivial algorithms -- Formatting indentation, and other white space aids readability)
Grade: 78.00 / 100.00