Assignment 1

416 Distributed Systems: Assignment 1

Due: Jan 13th at 9PM

Winter 2017

This assignment is intended to get you started with programming in the Go language. To solve this assignment you will need to install Go, figure out how to compile, run, and debug a Go program, and implement a UDP-based protocol described below.

High-level protocol description

There are two kinds of nodes in the system: a client (that you will implement) and a server (that we will implement). The server listens to connections from clients and expects UDP packets containing a single uint32 integer (between 0 and max size of uint32). It responds to each UDP packet with one UDP packet containing a string. This string can have one of three values:

  • value "high" when the number the client sent is too high
  • value "low" when the number the client sent is too low, and
  • an arbitrary string value, which we call fortune, that is max 1024 bytes, when the number that the client sent is just right.

The communication steps for an example run of this protocol are illustrated in the following space-time diagram:

The client's goal is to programatically find the right number that gets the server to return the fortune string. The client should print to standard out the found fortune string followed by a newline and then exit. The client should not print anything else.

You will test and debug your solution against the running server instance -- the client is run with two arguments, the UDP IP:port to use locally, and the UDP IP:port of the server. You will not have access to the server's code.

Implementation requirements

  • The client code must be runnable on CS ugrad machines and be compatible with Go version 1.6.3
  • Your code must not assume that UDP is reliable and must implement retransmission.
  • Your solution can only use standard library Go packages.
  • Your solution code must be Gofmt'd using gofmt.

Solution spec

Write a single go program called client.go that acts as a client in the protocol described above. Your program must implement the following command line usage:

go run client.go [local UDP ip:port] [server ip:port]

  • [local UDP ip:port] : local address that the client uses to connect to the server (i.e., the external IP of the machine the client is running on)
  • [server UDP ip:port] : the UDP address on which the server receives new client connections

Starter code and testing server

Download the starter code. The server is running at IP:port


Download the solution code.

Rough grading rubric

  • 50%: Solution finds the fortune without packet loss.
  • 40%: Solution implements retransmission to handle packet loss.
  • 10%: Solution properly prints the fortune.

Make sure to follow the course collaboration policy and refer to the assignments instructions that detail how to submit your solution.