CSc 423 Assignment 1

Old Time Is Not Forgotten

Assigned
Due

Jan 17
30 pts
Jan 31

RFC 867 defines the very simple daytime protocol. This protocol reports the current time, and is generally considered obsolete. The current way to fetch time over the net is using the NTP (RFC 5905), which is far more precise, and definitely not a hello-world level networking client. However, there are a few somewhat change-resistant parties which still operate RFC 867 servers, including myself and the government of the United States. This assignment is to create a simple client for that protocol. Your client should take the name of the server and print the time it reports, for instance:

[bennet@m-mcc-csc-01456 asst]$ ./daytime sandbox.mc.edu 17 JAN 2019 11:31:23 CST [bennet@m-mcc-csc-01456 asst]$ ./daytime time.nist.gov 58500 19-01-17 17:31:38 00 0 0 850.8 UTC(NIST) *

RFC 867 is very simple: When a client connects on port 13, the server sends a string containing the date and time, then disconnects. It ignores anything sent by the client. As you might guess from the above example, the RFC does not specify the format of this string.

The assignment is pretty simple, because all you actually need to do is connect to port 13, read and print whatever the server sends, then close and exit. Use the Cleansocks library to create your simple command-line client. You can steal most of the code from this example. (So the biggest issue is actually making the library work.)

Your program should:

Running Your Program

You can test your program with any service running the daytime protocol. The NIST server at time.nist.gov is available as shown above. I have noticed that sometimes the government server will close your connection without sending anything. You might need to run it a couple of times to be sure.

The server on Sandbox works fine, but it seems to only be reachable from the on-campus wired network. One way is to simply work on Sandbox itself. Excellent connectivity there. Another way, if you have ssh installed, and an account on Sandbox, is create a temporary tunnel. Open an extra command window, and run this command as root:

ssh -L 13:localhost:13 -N userid@sandbox.mc.edu
(Of course, you type your user id.) It will ask for your Sandbox password. The command will continue to run. In another local window, you can run
[bennet@laptop asst]$ ./daytime sandbox.mc.edu 17 JAN 2019 12:35:18 CST
The running ssh is forwarding traffic between port 13 on your computer and port 13 on Sandbox. You can kill the forwarder with ^c when you're done. The ssh program is standard on most Linux boxes, and on Mac. If you have putty installed on Windows, it includes the plink.exe utility, which is a partial port (or maybe clone) of ssh command, and will do the same thing.

If you have a Linux setup, you can run your own daytime service by installing the xinetd package and enabling the service in /etc/xinet.d/daytime-stream. Then use systemctl start xinetd.service to start it. You should be able to access this via host name localhost.

If you're curious about the format of the NIST time string, It's here.

Submission

When your program is working, nicely commented and properly indented, submit it using the form here.