CSC458/2209 - Assignments - Programming Assignments

Programming Assignment 1

For this assignment, we will use MiniNet to create a virtual network to build a simple router.

  • Assignment description.
  • 12% of the overall mark.
  • Due date: Friday, October 11th at 5pm.
  • When you submit your assignment on MarkUs, we will run the a subset of marking script tests and give you feedback. You can submit up-to 8 times each day for the last 7 days before the deadline.
  • Make sure to check out guidelines for programming assignments before starting.
  • You can find examples of good and bad programming practices here.
  • This assignment is to be done in groups of two or three students. Feel free to use Piazza to find teammates.
  • You You will need to know (or learn!) socket programming for this assignment. This is covered in tutorial # 1. You can find some useful links about socket programming here.
  • Submission guidelines: The assignment should be tested on teaching lab machines and submitted electronically. Please compress and submit the whole contents of the router folder as a single file on MarkUs as a single file.
    • Use your teaching lab credentials to login.
    • The file name must be pa1.tar.gz.
    • Note that, if you resubmit your assignment, the previous file will be overwritten.
    • Please see the deliverables section in the Programming Assignment Guidelines (see below) for information on what should be included in the submission.

Programming Assignment 2

For this assignment, we will explore the impact of router buffer sizes on network performance.

  • Assignment description.
  • VM Setup Guidelines.
  • 18% of the overall mark.
  • Due date: Friday, November. 29th at 5pm.
  • Please note that the assignment is to be completed individually.
  • Submission guidelines: Please compress and submit the whole contents of the router folder as a single file on MarkUs as a single file.
    • Use your teaching lab credentials to login.
    • The file name must be pa2.tar.gz.
      • Please cd into your assignment folder and tar the whole folder in to a tar.gz file.
      • Then, name your code as pa2.tar.gz and upload to your markus repository.
      • No other format or structure will be accepted.
      • Do not submit multiple tar.gz files into your repository.
    • Note that, if you resubmit your assignment, the previous file will be overwritten.
    • Please see the description page for details on what you need to submit.

CSC458/2209 - Assignments - Problem Sets

For problem sets 1 and 2, we will grade each question in a 0-2 scale. You will get a 0 if nothing is turned in; 1 when you have some understanding of the problem; and 2 when you demonstrate strong understanding of the problem. Keep your answers concise, and clear. Note the late submission policy described in the course information sheet.

Problem Set # 1

  • 10% of the overall mark.
  • Due date: Fri. Oct. 4th at 5pm
  • Submission guidelines:
    • The assignment should be submitted electronically (on MarkUs) as a single file.
    • The filename must be ps1.pdf. Anything other than that will not be accepted by the system.
    • Note that, if you resubmit your assignment, the previous file will be overwritten.
  • Textbook problems (5th edition):
    • Chapter 1: 3,11, 19, 20
    • Chapter 2: 1, 13, 45
    • Chapter 3: 4, 21

Problem Set # 2

  • 10% of the overall mark.
  • Due date: Fri. Nov. 15th at 5pm
  • Submission guidelines:
    • The assignment should be submitted electronically (on MarkUs) as a single file.
    • The filename must be ps2.pdf. Anything other than that will not be accepted by the system.
    • Note that, if you resubmit your assignment, the previous file will be overwritten.
  • Textbook problems (5th edition):
    • Chapter 3: 55, 64
    • Chapter 4: 9, 25
    • Chapter 5: 12, 25, 39
    • Chapter 6: 5, 17, 27

Programming Assignment Guidelines

Here, you can find guidelines for CSC458/2209 programming assignments. Please read this information carefully before starting your assignment.

In this course, we will use MiniNet ( to create a virtual network for our programming assignments. We assume you have a strong background working with Unix, and a solid experience with the C programming language.

Implementation Rules

All programming assignments are to be completed in groups of three students. You are expected to code in ANSI C for the assignments. If you are unsure of the differences between ANSIC and K&R C, there are a number of books available at the library that can help.

We expect good coding style throughout. At a minimum, good coding requires useful comments and meaningful variable names. We also expect you to design your program carefully, to achieve good functional decomposition, and to use appropriate algorithms and library routines.


All of the assignments are designed to be implemented on MiniNet. You will each get access to a virtual machine on CDF servers (more detail below). You can download a MiniNet VM from and use it on your own machine. However, you should test your code on the VM provided by CDF before submitting. This is MiniNet Version 2.2.1 and is the latest version at the time of posting this assignment. We will use an automated marking script, and subtle differences in the environment might lead to complication/execution errors and you might lose marks for that.

At times there will be ambiguities in the assignment specifications, or multiple ways an assignment can be implemented. We expect you to make reasonable design decisions in these cases. Base your decisions on what you know of the assignment as a whole. The TA's may give you advice on the tradeoffs of these decisions, but will not make them for you.


There are several tools that can make your life considerably easier.

  • make is a utility used to conditionally recompile your program based on the timestamps of the source code, object files, and executable. We expect that everyone in the class will have seen a makefile before as they are a permanent fixture of every flavor of Unix and most other platforms. If you don't know how to use make or write a makefile, learn. We require a makefile to be submitted with each assignment.
  • gdb is the GNU debugger. gdb is an interactive, source-level debugger. It allows you to trace through your code as it executes and examine program state. If your program seg faults, it will show you where. Learning to use gdb effectively will save you many hours of debugging hell. To compile with gdb, simply add the '-g' flag to the gcc command. You can then start gdb with your program with the command gdb progname. Type 'help' from the gdb prompt for more information.
  • Valgrind is a programming tool for finding memory leaks and memory errors. Use Valgrind to ensure that your program is not leaking memory, and that there aren't potential segfaults lurking in your code. The basic procedure for running valgrind is to run the command valgrind progname progarg1 progarg2..., where progname is the name of the program and progarg1, etc. are arguments to the program. Run valgrind --help for additional options- most of the things that you will be interested in will be in the Memcheck module.


There are two expected deliverables with each assignment. The first is the source code of your implementation. This should include a makefile which builds a program of the name specified in the assignment in the current directory. It is important to adhere to this requirement as some of the assignments are tested by shell scripts and must be graded by hand if your makefile is wrong. If you do not know how to write a makefile, look in the class directory for a sample.

The second deliverable is a project writeup. This file should be a file called README (all caps) and should be a text file. This file should contain the following:

  • An overview of the structure of your code.
  • Any design decisions you made and a short justification for them. If you found ambiguities in the assignment itself, also list here how they were resolved in your implementation.

References and Resources

  • "Unix Network Programming" by Stevens is the reference of choice for programming the Unix sockets API. There will also be a review session before the first assignment is due which will provide an introduction to socket programming.

  • "TCP/IP Volume 1: The Protocols", also by Stevens, is an excellent reference to the specification and common implementations of TCP/IP and some of the related protocols. Although this book is not a required course text, it is an excellent reference. Some of the assignments refer to chapters in this book for additional reading.

MiniNet on CDF

  • Every registered student (CSC458/CSC2209) will have access to a her/his own copy of a MiniNet VM on CDF servers.
  • Your MiniNet VM runs with 1GB of memory, and a private network connecting to the rest of the world.
  • At the moment the VM may be run only on the workstations in CDF labs. We will provide more information on this soon. For now, you are welcome to use your own machine to run the MiniNet VM. BA2220, BA2240, BA3175 and BA3195. Please note that BA3175 and BA3195 are sometimes closed to be dedicated to a particular class. Such closures are regular and scheduled; there's a schedule posted on the doors.

To use the Mininet VM for CSC458/2209:

  1. Log into one of the workstations in rooms BA2220 or BA2240.

  2. Open a terminal window and give the command

    cvm csc458

    If this is the first time you've used the VM, there may be a few seconds of delay and a message about formatting something.

  3. A new window will pop up showing the VM console. It will print various bootstrapping messages, may spend a few seconds showing a blank white or blank screen, and may change its size a few times; all this is normal as the Mininet OS boots within the virtual machine. When it is ready to use, the screen will say

    Ubuntu 14.04 LTS mininet-vm tty1
    mininet-vm login:
  4. At this point things should work as described in the Mininet documentation. In particular, you can log in on the console, or via ssh from the same host on which you started the VM, with ssh -p 8022 mininet@localhost

There are two differences from the Mininet documentation:

  1. The first time you use the machine, you'll be forced to set the mininet user's password to something only you know, as follows:

    mininet-vm login: mininet
    Password:   (also `mininet', as in the documentation)
    You are required to change your password immediately (root enforced)
    Changing password for mininet.
    (current) UNIX password:    (type `mininet' again)
    Enter new UNIX password:    (now type a new password)
    Retype new UNIX password:   (type the new password again)

    If all is well, you will now be logged in. If your new password is too simple or you don't type the same one the second time, you'll be asked to try again; if this happens too many times you may have to start over again.

    It will speed things up if you think of a new password ahead of time. Please don't re-use your CDF password for the virtual machine.

  2. The documentation says mininet can sudo to become super-user (within the virtual machine) without typing a password. For safety, we've changed it so you must first type your mininet password. If you run sudo several times from the same login session within a few minutes, it won't ask for your password every time. For example:

    mininet@mininet-vm:~$ sudo id
    [sudo] password for mininet:        (type your mininet password)
    uid=0(root) gid=0(root) groups=0(root)
    mininet@mininet-vm:~$ sudo id
    uid=0(root) gid=0(root) groups=0(root)  (the second time it doesn't ask)

Other Things You Should Know

  • It is best to close down the VM cleanly before logging off the CDF workstation, by doing sudo poweroff and waiting for the VM-console window to disappear. If you just log off (or if you kill the process started by the cvm command), the virtual machine will stop, but abruptly; rather like pulling out the power plug on a real system. Often this will do no harm, but there's some chance you'll end up with a corrupted virtual machine that won't work right any more.
  • If you use the VM console window, your keyboard and mouse may get stuck in there. To unstick them, press your keyboard's left-hand CTRL and ALT keys at the same time.
  • There is one copy of the Mininet VM associated with your CDF account. You'll get the same one no matter which workstation you log into.
  • Do not run the VM more than once at the same time; if you do, you'll likely end up with a scrambled, corrupt virtual disk. There is some simple protection to try to keep you from doing this by accident but it doesn't yet detect if you do it on two different workstations.