[Solved] COMP8051 Assignment 3 -XV6 Network Sockets & Theory

$25

File Name: COMP8051_Assignment_3_-XV6_Network_Sockets_&_Theory.zip
File Size: 480.42 KB

SKU: [Solved] COMP8051 Assignment 3 -XV6 Network Sockets & Theory Category: Tag:
5/5 - (1 vote)

Question 1 Parse network packets from the E1000 driver

Write a parse function in the file e1000.c in the code in network-sockets-xv6e1000-lab.zip to give a human readable dump of received packet details.

Your parse function should distinguish between UDP, ARP, TCP, packets. For the MAC layer your parse function should detail the mac addresses and the ethertype field. For the IP layer your parse function should detail the source and destination ip addresses and the flags.

(9 marks)

Background

Download the network-sockets-xv6-e1000-lab.zip from Canvas.

The code is taken from here https://pdos.csail.mit.edu/6.828/2019/labs/net.html Note the code at this link https://pdos.csail.mit.edu/6.828/2019/labs/net.htm l is for the 2019 version of xv6 i.e. riscv. See canvas for a port of the code to xv6 for the x86 i.e. network-sockets-xv6-e1000-lab.zip.

You may find it helpful to review Traps and device drivers, File descriptor layer from the xv6 book, and the lecture notes on networking.

We are using a virtual network device called the E1000 to handle network communication. To xv6, the E1000 looks like a real piece of hardware connected to a real Ethernet local area network (LAN). But in reality, the E1000 that the driver talks to is an emulation provided by qemu, connected to a LAN that is also emulated by qemu. On this LAN, xv6 (the guest) has an IP address of 10.0.2.15. The only other (emulated) computer on the LAN has IP address

10.0.2.2. qemu arranges that when xv6 uses the E1000 to send a packet to 10.0.2.2, its really delivered to the appropriate application on the (real) computer on which youre running qemu (the host).

We will be using QEMUs user mode network stack since it requires no administrative privileges to run. QEMUs documentation has more about user-net here. Weve updated the Makefile to enable QEMUs user-mode network stack and the virtual E1000 network card.

QEMUs network stack will record all incoming and outgoing packets to packets.pcap. To get a hex/ASCII dump of captured packets use tcpdump like this:

tcpdump -XXnr packets.pcap or use wireshark wireshark packets.pcap

Instructions

  1. Download the code from canvas network-sockets-xv6-e1000-lab.zip
  2. See the slides qemu-ethernet on canvas and associated video for details aboutvarious the network layer packet formats.
  3. You are to write the parse function in e1000.c.
  4. To test your parse code for TCP, ARP use the browser to connect to http://localhost:20001/
  5. To test your parse code for UDP. See net.h for a c struct to represent an UDP packet. See also the details in question 2.

Question 2 Socket layer xv6

Read the description below and also the File descriptor layer section in the xv6 book and describe how the user is able to send and receive packets to/from the E1000 device with simple system calls such as read and write.

(9 marks) Overview of the socket layer in xv6

Download the network-sockets-xv6-e1000-lab.zip from Canvas. The code is taken from here https://pdos.csail.mit.edu/6.828/2019/labs/net.htm l . Note the code at this link https://pdos.csail.mit.edu/6.828/2019/labs/net.html is for the 2019 version of xv6 i.e. riscv. See canvas for a port of the code to xv6 for the x86 i.e. network-sockets-xv6-e1000-lab.zip.

Network sockets are a standard abstraction for OS networking that bear similarity to files. Sockets are accessed through ordinary file descriptors (just like files, pipes, and devices). Reading from a socket file descriptor receives a packet while writing to it sends a packet. If no packets are currently available to be received, the reader must block and wait for the next packet to arrive (i.e. allow rescheduling to another process). The code in xv6-e1000-sockets.zip is a stripped down version of sockets that supports the UDP network protocol.

Each network socket only receives packets for a particular combination of local and remote IP addresses and port numbers, and xv6 is required to support multiple sockets. A socket can be created and bound to the requested addresses and ports via the connect system call, which returns a file descriptor. The implementation of this system call is in kernel/sysfile.c. The code for sockalloc() and related functions is in kernel/sysnet.c.

Take note of the provided data structures; one struct sock object is created for each socket. sockets is a singly linked list of all active sockets. It is useful for finding which socket to deliver newly received packets to. In addition, each socket object maintains a queue of mbufs waiting to be received. Received packets will stay in these queues until the read() system call dequeues them.

Running the test program.

(in one terminal on your laptop) $ python2 server.py 26099 listening on localhost port 26099

(then on xv6 in another terminal on the same machine run make qemu

and run nettests at the xv6 shell prompt

$ nettests

Question 3 Firecracker, virtio and virtio-sock

Give an overview of firecracker and its use of virtio for networking. In your answer focus specifically on virtio-sock.

(12 marks) References: https://www.usenix.org/system/files/nsdi20-paper-agache.pdf https://github.com/firecracker-microvm/firecracker https://github.com/firecracker-microvm/firecracker/blob/master/docs/vsock.md https://www.youtube.com/watch?v=LFqz-VZPhFE https://terenceli.github.io/%E6%8A%80%E6%9C%AF/2020/04/18/vsock-internals https://www.youtube.com/watch?v=R5DQWdPUQSY

https://developer.ibm.com/technologies/linux/articles/l-virtio/

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP8051 Assignment 3 -XV6 Network Sockets & Theory
$25