CSL374: Assignment 4 on Network Driver
- The goal of this assignment is to gain hands-on experience with the
linux network driver.
- You are given the source code for e1000e network driver for linux.
You need to compile and load this network driver. This assignment gives
you some idea about how open source linux driver code are written and
how to understand and make changes to them.
- Loading and unloading of a module requires root privilege. If you
don't have your own machine we will provide you virtual machine for this
- Please request a virtual machine on Baadal if you want a virtual machine
for this assignment.
Steps to compile and load e1000e module
- Download the e1000e source code from here.
- Untar the files, tar -xvf e1000e.tar.bz2
- cd e1000e/src
- make clean && make
- Make sure that all other network modules are unloaded before loading this module.
- sudo ./load
- If your system supports e1000 use the source code of
e1000 instead of e1000e.
- In Part B instead of taking the list of IP addresses you can take only one IP address.
- Please go through this file skbuff.
Driver compatibility issue
e1000e is network driver for Intel NIC. If your system is using some other NIC
you can not get the interface up using e1000e. You can check
which network driver you are using by the command,
lspci -v | less
Search for keyword "Ethernet" and you can find which driver your network card is using.
The simple way to do this to use a virtual machine if your host does not support e1000.
For example KVM uses e1000 network driver
If you want to use KVM install the qemu-kvm package.
Create a qemu image as instructed in qemu img.
Run the command,
qumu-system-x86_64 --enable-kvm ubuntu.img
to boot your virtual machine (here ubuntu.img is the name of qemu image).
If you want to use VMware install VMware bundle. Create a virtual machine using VMware. If it is not
using e1000 device driver you can try following steps,
To see whether your custom driver is loaded or not you can insert
- Edit the file (using vim/gedit or your favorite editor) os_name.vmx file created by VMware.
- Change the line
ethernet0.virtualDev = "vmxnet" to
ethernet0.virtualDev = "e1000" or you can add
ethernet0.virtualDev = "e1000" after
ethernet0.present = "true" if it is not already present.
- Boot your OS with this new configuration and check the network driver.
statement in various functions of the driver code.
printk is similar to
printf but in kernel we use
The log messages printed by
printk are stored in /var/log/kern.log.
You can also run the command
dmesg to see
the print messages by
printk. For the assignment Part A you need to insert
printk statement in various functions to see which function are called
until the network interface is up.
printk("CSL374: %s %d\n", __func__, __LINE__);
will print CSL374: [current function name] [current line number] in /var/log/kern.log.
For the second part we suggest you to look for the functions which are most frequently called when
you do some network activity. These are the functions which are called when packets are sent or
received. Luckily these are few. Please go through these functions. We think that the networks packets
which are sent or received
must be input parameters to some of these functions.
Please use Linux Cross Reference
if you not able to find the definitions of some structures/ functions in the driver source code.
Cscope and Ctags are good tools to browse through large source code.
- Linux Device Drivers
- Linux Cross Reference
- Intrusion Ratio = ((total number of packets outgoing/incoming to/from blacklisted hosts whose source/destination is native host) * 100) / (total number of packets outgoing/incoming whose source/destination is native host).
- Interrupt Throttle Rate:
Valid Range: 0,1,3,4, 100-100000 (0=off, 1=dynamic, 3=dynamic conservative, 4=simplified balancing)
Default Value: 3
The driver can limit the amount of interrupts per second that the adapter will
generate for incoming packets. It does this by writing a value to the adapter
that is based on the maximum amount of interrupts that the adapter will
generate per second.(See e1000e/README for more details.)
The Assignment(Part A)
- Load the custom e1000e module (sudo ./load will do the job). Write calling sequence of all the major functions and a short description
about its duties, which are called until the network interface is up.
- Unload the custom e1000e module (sudo ./unload will do the job). Write calling sequence all the major functions and a short description
about its duties, which are called until the module is unloaded.
The Assignment(Part B)
- Implement a module parameter which takes as argument, a list of IP addresses of blacklisted hosts.
Your driver code should drop the packets which are outgoing/incoming to/from these blacklisted host and whose source/destination is native host.
- Implement a module parameter which takes intrusion threshold(must be between 0 and 100) as a parameter.
Whenever the native host sends/receives a packet whose source/destination is native host it will calculate
intrusion ratio and set the interrupt throttle rate to 100 and stop dynamic conservative approach(see Keywords),
if intrusion ratio is greater than or equal to intrusion threshold. If the intrusion ratio is less than intrusion
threshold it will switch to dynamic conservative approach.
- Whenever native host sends a packet change the Time to live (TTL) field in network header to 16 if it is greater than 16.
Create a svn repo as instructed in tools.
Submit a txt file containing the diff from the original version. For example if revision 1 is the base version run,
svn diff -r 1 > diff.txt This will write the diff into a file named diff.txt.
You will also need to submit a pdf file which contains the answer of part A. Create a tar folder of these two files and upload on sakai.
- To be done in the group of two.
- The last date of submission is Oct 25.
- You can also use e1000 driver if your network card does not support e1000e.