Learning UDP sockets in C
Created in the early days of the TCP/IP protocol suite, the socket API remains the standard low-level API to interact with the underlying networking stack. Despite its age, it remains widely used and most networking students are exposed to it during their studies. Although more recent languages and higher-level APIs can simplify the interactions between applications and the networking stack, it remains important for students to understand its operation. At UCLouvain, we aks the students to write a simple transport protocol in C over UDP. This enables them to understand how to parse packets, but also how to manage timers and how to interact with the socket API.
During the last years, UCLouvain’s Computer Science Engineering Department has developed the INGINIOUS code grading platform. This platform allows students to submit code that are automatically graded by test suites that verify a set of quality criteria in the submitted code. It is already used in dozen of courses.
INGINIOUS is very flexible. With the help of several Bachelor and Master students, we have developed a series of networking exercises that will appear in the coming months on CNP3 Inginious course. The first exercise covers the basics of interaction with the socket API to send and receive UDP messages. More precisely, the student needs to write a client and a server. The client sends a vector of integers and the server returns the num of the received integers. This exercise was written by Jean-Martin Vlaeminck. For this, he has extended the CTester framework that we use for the basic systems course (in French) to support the different calls of the socket API. The exercise verifies the classical mistakes that students usually do when writing their first socket calls, namely avoiding memory leaks, checking return values from system codes and sending and receicing information in network byte order.
This exercise is available on https://inginious.org/course/cnp3/sum_of_ints_udp and its source-code has been posted on https://github.com/obonaventure/CNP3-Inginious Feedback is more than welcome on https://github.com/obonaventure/CNP3-Inginious/issues, please indicate sum_of_ints_udp in the title of your issue.