You should EMAIL me homeworks, alex at theparticle dot com. Start email subject with "CISC 7334X HW# "
HW# 1 (due by 2nd class;): Email me your name, prefered email address, IM account (if any), major, and year.
HW# 2 (due by 3rd class): Write an Internet page grabber program. Your program should work similarly to UNIX program ``wget'' (only much simpler). Read the description of `wget' online. You specify a URL at command line, and your program connects and downloads a web-page. Tip: Internet search engine is your friend. Submit the program source code. [hw2 hint Another hint: if you're doing this on Ubuntu, and can't find documentation for functions via "man" command, run this: apt-get install manpages-dev, which will install the linux programmer's manual pages; you'll be able to do: man gethostbyname to get documentation for the function, etc.].
HW# 3 (due by N+1 class;): In any language of your choice (I suggest C, but you're free to use anything you're comfortable with), write a `telnet' client. Your program should work identically to the telnet client installed on your computer. You open a socket to the destination, and write to socket whatever user types in stdin, and display whatever you read from socket. The simplest way to do this is to have 1 thread reading form the socket (and displaying everything it read), and have main thread reading stdin (and writing to socket). The networking part of this homework is nearly identical to previous homework---so you can reuse large parts of that code.
HW# 4 (due by N+1 class;): In any programming language of your choice (C prefered), write an NTP client. NTP is Network Time Protocol. Your program sends a UDP packet to the server. The server responds with a similarly formatted UDP packet with the current time. A public ntp server is: pool.ntp.org. This homework is part research part programming. Research part: Find the NTP specification, and determine what the UDP packet format is (google, etc.). Programming Part: Write a program to send the packet and recieve a response. When your program is executed, it will output the current time (recieved from NTP server) to standard output, in ``Wed Sep 24 07:29:23 EDT 2008'' format, (Note that since you're using UDP, not all packets will get through---so you might need to run the program a few times in order to get the correct time). You can lookup the format for the to/from message in ``NTP RFC'' (google for it)---the format is pretty simple. Your program should work similar to the unix utility ``ntptime''. Note that you should not use any "NTP" libraries---this homework is about creating your own UDP packet and sending it via the regular socket API. [hw4 hint].
HW# 5 (due by N+1 class;): In any language, build a DNS client. This is similar to HW3 (feel free to reuse the code from hw3). Accept hostname as command line argument. Construct a UDP packet with hostname, and send it to a DNS server. Recieve a UDP packet as response, and display the IP address on standard output. Note, your program must not use any DNS libraries (such as `gethostbyname' functions, etc.). ie: In this homework, you are writing your own DNS library.
HW# 6 (due by N+1 class;): In any language, write a program to send email. Do not use any SMTP libraries. (you can use DNS libraries). Given an e-mail address and the email text (read standard input?), your program will figure out what the MX for that e-mail, and then connect directly to that machine to send the e-mail---all using plain regular sockets (no libraries---you're writing your own library in this homework).
HW# 7: In any language of your choice, implement a simple web-server. Your web-server should serve pages from a some folder. You should be able to point your web-browser at the URL of your web-server, and see pages (and images) in that folder. This is not much different than writing a web-client. I recommend you use Java, since it's pretty easy to setup a basic server in that language---although you're free to use any language.
HW# 8: In this homework, you'll implement a simple Chat Server. Your server will start listening for connections. When a connection arrives, it will create a new thread to handle that connection (maintain a list of connections). When a string (line of text, your sockets are reading lines of text) arrives on any connection, the server will forward that string to all other connections. Pseudo code might look something like this:
The code isn't much longer than the pseudo code, but I'd like you all to figure it out on your own. Now, when you run the server, you should be able to telnet into that server. If more than one person telnets into that server, then everything one person types will be seen by everyone else. You can test it by running multiple Telnet instances (in different terminals), and seeing whether everything you type in one window appears in the other window. Submit the source code.
If you're feeling creative, think of how you'd handle user names and nicknames in such a system. How would one person find out who is connected? How would they find out information about other users?
Submit just the source code via email.
HW# 9: In many situations, you need to transmit a sequence of packets across the network. You generally cannot do much about big connection problems (lots of packets getting lost). But for situations when only a few (perhaps 1) packets are lost, perhaps there's a way to use error correction codes to `correct' the lost packet. Use the Hamming(7,4) code to implement such a scheme... In any language, write 2 programs, "sender" and "reciever". The sender will get a block of data (input file), cut it into `packets' (smaller files). The reciever program will take those smaller files and reconstruct the original block of data (even when 1 packet is missing).
TIP: every 4bits of the input go into their own output file (creating 4 files---one per bit). Add 3 more files to be the Hamming parity, for a total of 7 output files. If any one of those files is lost, (and end up with 6 files), you can still reconstruct the 7 original files (and recover the original data from 4 of those files). If you want to, make the scheme general, where the user specifies number of output files to create---(perhaps they want to cut it into 256 files instead of 7, etc.).
Submit the source code to the sender and reciever programs.
HW# 10(last one): In this homework, you'll write a few utilities. These should be flexible enough to run on schedule (cron, etc.). I highly recommend you use GPG for this (generate public/private key pair; do not keep private key anywhere near these programs), and command line email/ssh utilities, etc., don't recreate stuff if you can just use other programs/libraries. (I don't expect each of these to be longer than 10-20 lines of code).
Write a utility that accepts an "outbox" folder, "encrypted" folder, and "publickey" file. When a FILENAME.comp shows up in the "outbox" folder, your utility will encrypt the FILENAME using the public key and place it into the "encrypted" folder. Your utility then verifies that the encrypted file was created successfully (length is not zero, and there were no errors such as running out of disk space, etc.), your utility creates FILENAME.comp file in the "encrypted" folder, and erases the FILENAME.comp and FILENAME from the "outbox" folder. You then loop thorugh the "outbox" folder and erase all files (those without the .comp) with create date older than 30 days.
Write (another) utility that accepts an "encrypted" folder, "trash" folder, and list of email addresses. When a FILENAME.comp shows up in the "encrypted" folder, FILENAME is emailed to all the email addresses (as MIME attachment). Once you've confirmed you successfully emailed the file (no connection errors, etc.), you erase the FILENAME.comp file from encrypted folder, and move the FILENAME to "trash" folder. You then loop through the trash folder and erase all files with create date older than 30 days.
Then for entertrainment (not for homework), you can write another utility that nightly compresses your IMPORTANT_PROJECTS folder, into say IMPORTANT_PROJECTS.20141201062800.tar.gz, and places the file in the "outbox" folder. Verifies that compression completed successfuly (perhaps by uncompressing and checking; making sure size is not zero, etc.), and then also creates a IMPORTANT_PROJECTS.20131204062800.tar.gz.comp file.
Then for entertrainment (not for homework), have the program accept a list of SSH locations (host, folder, username, password or key), and ensure the file is replicated on each of those locations before locally moved to trash.
Note, it is a very good idea to ensure you only have 1 instance of each such program running at any given time. You can accomplish that by specifying another parameter such as "lockfile". Your program would then open the file and aquire an exclusive lock on it. If it can't aquire the lock, your program would exit (meaning another copy of your program is already running). This eliminates a lot of the race conditions that might cause corruption.
Submit the source code to the scripts, along with either a crontab file or instructions on how to setup the programs to run every minute (yes, every minute).