OS Options: Must run on CSEE shell servers
- Part 1 [60 points total]: Construct a packet filtering
tool. You will test your tool by filtering a set of IP datagrams
captured during a set of test runs. The captured packets are stored
as a sequence of records in a file with the format given below.
0 15 31
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IP Header ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IP Header (Packet 2) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...
The testing of your tool takes the form of the following.
When displaying a packet, the format must follow
the form below for each IP packet
- IP.port -> IP.port Proto TCPFlags Datalen
Proto is either "TCP" or "UDP" depending on the protocol field.
TCPFlags is a set of characters specifying the TCP flags that
are set. These are U, A, P, R, S, or F.
And Datalen is the length of the entire IP packet.
An example would be:
- 157.182.194.39.22 -> 157.182.194.28.7462 TCP S 40
- 157.182.194.28.7462 -> 157.182.194.39.22 TCP S,A 40
- . . .
The first packet would be an TCP packet with IP source address of 157.182.194.39
and source port of 22 going to IP destination address
157.182.194.28 and destination port 7462. The TCP flag that
is set is SYN. Packet length is 40 bytes.
- A [15 points]: Display only IP packets meeting
specific IP address criteria. The Source IP address and/or
the Destination IP address must match criteria given
by the user. This criteria may include a netmask to apply
to the IP address as well. This criteria may be given
as command line arguments to the filter. With the
-s argument specifying the Source IP address to look
for and the -d argument specifying the
Destination IP address to look for. e.g.
$ pfilter -s 157.182.194.28/24 filename
might only display information for IP packets that have
a source IP address that falls in the 157.182.194.28/24 subnet.
Both the Source IP address and Destination IP address may be given
or just one of them may be given.
- B [10 points]: Display only IP packets meeting specific
TCP/UDP port criteria. The Source port and/or the
Destination port must match criteria given
by the user. This criteria may be given as command line arguments
to the filter. With the
-S argument specifying the Source port number to look
for and the -D argument specifying the
Destination port number to look for.
Both the Source port and Destination port may be given
or just one of them may be given.
- C [10 points]: Display only IP packets meeting
specific protocol criteria. The IP Protocol must match criteria
given by the user. This criteria may be given as a command line
argument to the filter. The choices are "UDP" or "TCP". The
argument that may be used is
-p.
- D [10 points]: Display only TCP packets meeting
specific flags. The TCP flags must match
criteria given by the user. This criteria may be given as a command line
argument to the filter. The choices are any TCP flag ("SYN", "FIN", "URG",
"RST", "PSH", or "ACK").
The argument that may be used is
-f.
- E [15 points]: At the end of the file, display each
individual unique UDP and TCP connection/session. Each session
should include the IP addresses, TCP/UDP port numbers, number of
bytes sent in each direction, and number of packets sent in each direction.
- Part 2 [20 points total]: Construct a program that takes
as it's input: (1) IP address, (2) UDP port number, (3) a
variable length string representing a stock symbol, (4) a
variable length string representing the type of quote, either
"ask" or "bid", (5) the time, in
milliseconds, between each retransmission, and (6) the maximum
number of times to retransmit before giving up. The routine or
object should send quote queries to the IP address and UDP port
until it receives a response or retransmits enough times and
gives up. The time between each retransmission must be as given
by the appropriate parameter. Each query should have a qid (query id)
that is echoed by the sender in its response or error message.
This qid must be psuedo-random and generated by the client.
The format of a quote query and response are given below.
Query:
Bytes: 2 2 Var 1 Var 1
+------+-----+--------+-+------+-+
| 0x1 | qid | symbol |0| type |0|
+------+-----+--------+-+------+-+
Response:
Bytes: 2 2 Var 1 Var 1 Var 1
+------+-----+--------+-+------+-+-------+-+
| 0x2 | qid | symbol |0| type |0| price |0|
+------+-----+--------+-+------+-+-------+-+
Error:
Bytes: 2 2 Var 1 Var 1
+------+-----+------+-+---------------+-+
| 0x3 | qid | code |0| error message |0|
+------+-----+------+-+---------------+-+
The routine or object must return whether a response was
received or not and the price.
The output should be formatted nicely and readable.
- Part 3 [20 points total]: Construct a stock quote server for the
client given in Part 1. Construct a program that takes as input
a port number to bind to and listen for UDP messages from a stock
client. The server should respond to all requests.
The server must randomly determine the stock price given
some parameters and saved information. They are:
- There should be a 5% chance that the stock symbol is not defined
if the server has not seen the symbol before. If the symbol is not
defined, then it will never be defined and all subsequent queries
for it will not be defined.
- For symbols that are defined, but have not been queried before,
they have a random value between 5 and 30 dollars. The cent value
must also be random with 1/64th resolution. This is the IPO price. The ask and
bid prices are the same for an IPO.
- For symbols that are defined, a stocks ask price may go up (50%
chance) or down (50% chance) by up to 10% of the stocks previous value.
In other words, the stocks new price will be anywhere between
90% of the previous value and 110% of the previous value.
- For symbols that are defined, a stocks bid price may go up (50%
chance) or down (50% chance) by up to 25% of the stocks previous value.
In other words, the stocks new price will be anywhere between
75% of the previous value and 125% of the previous value.
- Once a query is performed, the stocks price is saved as the
last bid price (50% chance) or ask price (50% chance). In other words,
the price of the stock is saved as the ask or bid price. The
next query will determine new ask and bid prices and one of
those two will be saved as the new stock price.
Notes:
Your submissions must at least compile before any credit will be given.
Submissions that do not compile will not be graded. Submissions submitted
after the due date will not be graded. All work must be your own original work.
To get partial credit for parts of the assignment, you must demonstrate that
those pieces work by themselves.
If you share code with others, you will be given a 0 for the assignment. This
assignment set is worth 25% of your total grade.
Todd L. Montgomery (revised 03.09.2004)