Thursday, October 17, 2019

Assignment 2 Specification

Assignment
2 Specification

1.
About Assignment 2

This
assignment is worth 60%
of the marks for the course. 

Assignment
Submission

The
assignment submission will have two parts: 

a
short report which
will be submitted using the USQ Studydesk Assignment submission
link 

program
code which
will be submitted using your Git repository

Assignment
Topics

This
assignment will cover the following topics

The
use of the Git repository

The
use of a makefile

C
command line arguments

Using
pointers in C

Calling
functions in C

Writing
functions in C

Encapsulation
in C

Configuration

Logging

Error
handling

Parsing
HTTP text.

Sending
HTTP text.

Opening
and reading from a file

Additional
Topics: 

Accepting
UDP connections.

Reading
from UDP connections.

Writing
to UDP connections.

Write
a UDP client 

Write
a UDP server 

Write
a TCP client

CscNetLib

You
will be using the CscNetLib networking library, beginning with
demonstrations in the Samples directory.  Follow the
instructions in Getting
Started with CscNetLib to
obtain and compile it.

Network
Framework Documentation

The
documentation for CscNetLib routines exists in the network framework
header files, and you will need to read these carefully in order to
complete the work in this assignment. For example, if you
want to know just what a given netCli_???() routine
does, and what the return value is, you will find the documentation
for the routine immediately before the prototype for that routine in
the file “netCli.h”
in the place where you built it.

Asking
for assistance

If
you are stuck at any stage which
is likely then
seek help on the forums. Hopefully someone has already had the same
problems as yourself, and you can read the solution in the forums. If
not, then you need to ask. While you are there, please help others if
you happen to know the answers to their problems.

Develop
a piece at a time

It
is good practice, and in this course your marks depend on it. You
need to plan your delta (small improvement) so that your increment
can be tested. Get the delta working and test that before moving on.

Using
Git

In
this course, you are provided with a Git repository, and there
are instructions for how to set it up and use it.
For the assessments, your marker will access your Git repository. You
may have already used Git for other subjects at this university, but
for those not already familiar with Git, please use the following
links to make yourself familiar with Git and with revision control
systems in general. 

You
need to check your code into the Git repository provided for this
course (NOT GitHub), and push it to the server regularly.
This is good practice normally, and in this course your marks depend
on it. In the assignments, failure to check in your code regularly
will incur the loss of the marks associated with the code. Code with
no development history is worth zero marks.

2.
Marking

In
addition to satisfying the assignment requirements, marks will be
allocated for the following:

code
quality. (indentation, commented blocks of code)

proper
use of Git

code
builds without errors by typing “make”

no
memory leaks – CscNetLib has a debugging mode you will be shown in
order to prevent memory leak issues

Your
marker will examine your code, but also the code must:

run
in a Linux environment – your code must run; if it does not the
marker will say so

build
using make

compile
without errors and ideally without warnings – warnings may cost
marks 

The
marking criteria for each part of this assignment are shown in the
specification of each part.

Marks: 
100  (20 marks Part 1; 80 marks Part 2)

3.
Assignment 2 Specification

Tasks:

 Write
a report answering the questions in shown in Part 1 of this
Specification

 Implement
a UDP Client and Server as specified in Part 2 of this specification

You
may be asked to add more information to your report in Part 2

3.
Assignment 2 Specification

3.1.
Part 1 – Report

Your
tasks (20 marks)

Prepare
a PDF document,
answering the following questions and completing the following
tasks.  

This
report is to submitted using the Assignment Submission Link for
Assignment 2 on the Studydesk.

1.
Server architecture 

(1
marks) In
Part 2 of this assignment, the connection to the weather server is
made using UDP.  Given the system described, is UDP is a
suitable choice for this connection rather than TCP?  Explain
your reasoning  

(1
marks) Again
referencing Part 2 of the assignment, assume we add another dome and
dome controller. What changes to the specification of the monitoring
client might we need to make so handle multiple dome servers? 
A couple of dot points is a sufficient answer 

(1
marks) In
your opinion, is there a good reason to have the monitoring process
in Part 2 of this Assignment, rather than have the dome controller
poll the weather server directly?  Justify your opinion. 
A couple of sentences is all that is required.

2.
udpCliDemo and udpSrvDemo

(2
marks) Build
and test udpSrvDemo and udpCliDemo. You will need to use two command
line windows to do this. In one command line window, invoke
udpSrvDemo. In the other command line window, invoke the udpCliDemo
command with the appropriate IP address and port and a message as
arguments (by default the IP 127.0.0.1 and the port 9992 should
work). Take screenshots of your two command line windows and paste
them into your report.

(5
marks) Copy
the function main() from udpCliDemo.c into your report, and comment
every line of code.

(5
marks) Copy
the function main() from udpSrvDemo.c into your report, and comment
every line of code.

3.
netCliDemo

(5
marks) Copy
the function main() from netCliDemo.c into your report, and comment
every line of code.

3.2.
Part 2 – Code

Narrative

There
is an automated observatory that opens every night when the weather
is clear to take images of the night sky.  The observatory has a
series of weather instruments that monitors things like the
temperature, humidity, and whether the sky is cloudy.  This
Weather Server serves this information using a UDP server process
listening on UDP port 8123.

There
is a Dome Controller running a HTTP/1.0 server listening on TCP Port
9991.

A
Monitoring program periodically requests data from the Weather
Server, and if the weather is bad, will send a HTTP request to the
Dome Controller to CLOSE the dome.

Your
tasks

Task
1 – Weather Server Program

Write a
program called server (C code server.c)

This is a
UDP server listening on port 8123

The server
should read its configuration (IP address and Port) from an ini file
called “server.ini”

The server
should log its startup and connection requests to a log file
“server.log”.  Choose an informational log level for
connections

Upon
receipt of a packet containing the string “STATUS”, the
server will log the connection and send back a UDP Packet containing
a string of the format:

STATUS
T H C R

where:

STATUS
is either UNSF (unsafe to open the dome) or SAFE (safe to open the
dome) or ERRR (server error)

T is an
integer representing the temperature in degrees

H is an
integer representing the humidity in percent

C is a
character, either “C”, “O”, or “E”
representing clear sky, overcast or an error respectively

R is a
character, either “R”, “D” or “E”,
representing rain, dry, or error respectively

The
program sets STATUS to UNSF if C is “O” or R is “R”
or if there is an error “E” in either the C or R field,
otherwise, STATUS should be SAFE

The
information for the current weather conditions is read from a
one-line file in the directory where the server is located called
“weather.txt” and it is of the format:

T
H C R

where 

T is an
integer representing the temperature in degrees

H is an
integer representing the humidity in percent

C is a
character, either “C”, “O”, or “E”
representing clear sky or overcast or an instrument error
respectively

R is a
character, either “R” or “D” or “E”
representing rain or dry or an instrument error respectively

Make
changes in this file to test the various conditions

If the
file “weather.txt” cannot be read or if the server
receives a request other than “STATUS”, then the server
should log an error to the log file and respond with: 

ERRR
0 0 E E

If the
file can be read, assume its format is correct and the contents are
reasonable and correct (i.e. do not implement checking for the
contents of the file, make sure it is correct before using to test)

Task
2 – Weather Monitoring Client Program

Write a
program called client (C Code client.c)

The client
should read its configuration file (“client.ini”) and
obtain the following:

IP
address of weather UDP server

Port of
weather server

IP
address of the dome control HTTP server

Port of
the dome control server

Log level
(default choose an informational log level)

The client
should log its startup connection attempts to a log file called
“client.log”

Every two
minutes (120 seconds) the client program will connect to the weather
server system on UDP port 8123 and send a UDP packet with the text
string:

STATUS

The server
should respond with a UDP packet containing a string of text as
described in Task 1. Log the response to the log file.

The
program should receive and interpret the response. If program does
not receive a response, it should give up after a timeout of 30
seconds and log an error

If the
program cannot connect to the weather server (timeout or error)
treat the STATUS as UNSF with the parameters T = 0, H = 0, C = E, R
= E.  An error should be logged.

If the
response does not contain the correct number of words, or if the
STATUS is not SAFE, UNSF or ERRR, log an error, and treat the STATUS
as UNSF with the parameters T = 0, H = 0, C = E, R = E

If the
program detects or determines that the status of the weather is UNSF
or ERRR, it should connect to the dome controller via HTTP sending a
HTTP GET for the pseudo file “/CLOSE.html”, sending the
following arguments:

temp (the
temperature), hum (the humidity), rain (the rain state) and cloud
(the cloud state).  For example, if you were sending making a
request in a browser you would be sending:

http://domeIp:domePort/CLOSE.html?temp=20&hum=80&rain=R&cloud=O

If the
program cannot connect to the dome controller via HTTP, or if the
HTTP respose code is anything but 200, an error should be logged

There is
starter code (Section 4 of this specification) called domeControl.c
which you can run as the dome control HTTP/1.0 server.

Marking
(80 marks)

Client
Code 

(5
marks) Client
program correctly reads configuration file

(3
marks) The
client makes the UDP connection to the weather server and send the
request correctly.

(3
marks) The
client receives the response correctly from the weather server.

(5
marks) The
client correctly handles timeouts or other connection failures

(2
marks) The
client checks that the received packet has the correct number of
words and correct status codes

(10
marks) The
client correctly connects to the dome control via HTTP and receives
the response.

(5
marks) The
client logs each of the circumstances listed.

(5
marks) Testing

Server
Code 

(5
marks) Server
program correctly reads configuration file

(3
marks) The
server receives the UDP connection from the client receives the
request correctly.

(2
marks) The
server reads the data file correctly.

(3
marks) The
server correctly handles situation where the file cannot be read

(3
marks) The
server checks that the received packet has the correct message

(5
marks) The
server correctly creates the return message and sends the response.

(5
marks) The
server logs each of the circumstances listed.

(2
marks) The
server delivers explanatory text on failure.

(5
marks) Testing

Git,
General Code Quality

(1
mark) The
Git repository has directories for assignments 0, 1 and 2 named
“Ass0”, “Ass1” and “Ass2”
respectively.

(1
mark) All
needed files are in the repository, including input data.

(3
marks) The
checkins to the repository allow the marker to see the history of
how the code was built.

(1
marks) The
code builds without errors or warnings by typing “make”.

(1
marks) All
allocated memory is released.

(1
marks) The
code has proper indentation. Use Horstmann, Allman or K&R indent
style ,
with Allman being preferred.

(1
marks) Code
is broken into commented blocks.

Marks
removed for bad indentation or code not block commented.

4.
Starter Code and Files

Makefile

makefile (CscNetLib
installed in $HOME area)

makefile (CscNetLin
installed with root privileges)

Example
Configuration files

Skeleton
Code (you can use these or write your own)

Simple
domeControl.c web server code

Let’s block ads! (Why?)

Do you need any assistance with this question?
Send us your paper details now
We’ll find the best professional writer for you!

 



No comments:

Post a Comment