CSCI 152: Operating Systems Programming
Laboratory Assignment 1 for September 3, 2003
Assignment Description:
In this assignment students will write
a simple Network Client/Server program. The server has a very
simple job, it launches rocketship into outer space. A client connects
to the server on a certain port number. The server waits for a
message from the client. The client then sends the server a text
message "launch". Once the server recieves this message it sends
the countdown to the client; 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, and finally
the message "Blast Off!" This only happens 50% of the time
though. The other 50% of the time the server sends the countdown;
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, and then the message "Kaboom!"
Meaning that the rocketship blew up and was destroyed in an
explosion. Luckily this program only launches rocketships without
people on them so nobody gets hurt.
This assignment is very contrived but I think it will be
- fun
- challenging but not too difficult
- a good learning experience
Goal:
The goal of this assignment is to introduce students
to dealing with operating system
fundamentals such as process and thread management,
concurrency issues and network sockets.
Objectives:
- Learn about using multiple processes and threads.
- Learn about sockets and how to create a basic network server and client.
- Learn how to use random functions (if you haven't already).
Expected Outcome:
- This project must be completed using one of the following languages
- You can do this project on any platform you like as long as you want to do it on Linux (just kidding, anything is okay).
- Server
- Server must be capable of handling mulitple clients
simulaneously. (This means the Server must spawn either a new thread or process
for each client).
- Use whatever port number to listen on that you want to, randomly choose some high number (like 9176 or 4300).
- There should be a one second delay between each number in the countdown. You will want to use something like Sleep(1);
- The server accepts two different commands or text messages and can deal with any other input
- "launch" - launches a ship as previously described and closes the connection
- "cancel" - server sends a reply "Launch was cancelled" and closes the connection.
- "anything else" - server sends a reply "Did not understand command: anything else" and closes the connection.
- You have to use some kind of method or function like rand() so
that the server can respond randomly whether "blast off" or an
explosion occurred.
- Note that the server is sending and recieving text messages
(that means no using java to serialize objects and ship them across or
things like that).
- Server should print messages out to the terminal to say what is happening internally
- For example,
- "Client connected to server"
- "Server recieved request: 'launch' "
- "Begin Countdown"
- "Blast off successful" or "rocketship destroyed"
- "Closed connection to client"
- Client
- You should be able to use a standard telnet client to connect to the server and send messages.
- You should also write your own client
- Client should display a some kind of small menu and handle
automatically connecting to the server and sending a message depending
on what you choose.
- Example of client options:
- [1] connect to server and launch
- [2] connect to server and cancel
- [3] quit
- I am pretty open to however you want to do the client as long as you get the basic functionality in there.
- Add enhancements to this project as desired.
- Read "Practical Software Engineering Guidelines" which were included with your syllabus
- Include DEBUG LEVEL feature included in these guidelines
- Debug level feature
is used for determining how verbose of messaging the server and client
should display about what is happening in them internally.
- Applications should take a DEBUG LEVEL as an optional command line parameter.
- When you demonstrate this program in class I want to see 2 or 3 different debug levels.
- Documentation is required
- Javadoc is required if you use java to implement project.
- TURN-IN
- print out of all code used to create this project.
- you must demonstrate this project to your TA during lab.
Some vague ideas about how to proceed:
- First write a simple single threaded server that you can connect to with telnet and recieve some message.
- Next modify the server to spawn a new process or thread for each client.
- Then write a really dumb client that can connect to the server.
- Finally fill out the rest of the features in the client and server.
- Definitely Start with the server and use telnet for testing it.
- FIND AN INTRODUCTORY TUTORIAL ON NETWORK PROGRAMMING FOR YOUR LANGUAGE AND PLATFORM OF CHOICE
Grading:
- Most of the credit for this lab comes from implementing the server, the client is pretty small and easy
- Lack of Documentation or Bad Documentation may result in as much as 20% penalty
- Projects will be judged in comparision to each other
- like with a curve except if everyone turns in projects that are
well organized, documented and functional then everyone would recieve
100%.
Resources: