(Raw Socket Programming)
1. You are given the virtual network in Fig. 1. This network has two subnets, and one node common to both these subnets. Your first exercise is to write a simple packet sniffer at node
192.168.20.2
eth1
eth1 eth1
192.168.20.3
192.168.30.0/8
eth2
eth1
192.168.30.1
h1
192.168.20.0/8
h2
192.168.20.1
192.168.30.2
r1
Figure 1: A network with 2 subnets.
r1. This packet sniffer should print the MAC addresses (source and destination), IP addresses
(source and destination) of all IP packets sent and received by r1. Refer https://www. binarytides.com/raw-sockets-c-code-linux/ and http://squidarth.com/networking/ systems/rc/2018/05/28/using-raw-sockets.html [50]
- Modify the packet sniffer in the previous exercise to print the MAC addresses (source and destination), IP addresses (source and destination) of only those IP packets that are received
by r1 on interface eth1. [20] - Enhance the program created in the previous exercise so that you transfer IP packets across
the subnets in Fig. 1. Infact, you will essentially be building a rudimentary router. Some hints
can be found at https://opensourceforu.com/2015/03/a-guide-to-using-raw-sockets/
r2



