CMPUT 379辅导、辅导Computing Science、讲解C++程序、c/c++编程调试
- 首页 >> 其他CMPUT 379, Assignment 1, Winter 2019
University of Alberta / Department of Computing Science
Instructor: Ioanis Nikolaidis (nikolaidis@ualberta.ca)
(UNIX signals, timers,error detection)
Objective
During thecourse, we will study numerous forms of inter-process communication (IPC).Therearesystem utilities (like
netstat) thatallow oneto observetheIPC activity between processes.Thereexists however a form of very crudeIPC, Unix
signals, that is notexpected to be used for meaningful messageexchanges. As such, signal activity usually "flies under the
radar" of typical IPC inspection tools,and,as a result,can be used as a covert communication channel. Your assignment is to
usesignals to createa channel for communicating messages between two processes.The processes aresymmetric, i.e.,each
process sends to,and receives from, the other process.
Specification
You areasked to writea C program that produces an executablethat can send and receive messages to/from another
process.We will usetwo processes thatarerunning thesameexecutablecode. You are going to useconditional compilation
flags to allow you to createtwo versions of this program. One(the default) uses two signals (SIGUSR1 and SIGUSR2) and the
other (conditionally compiled as -DSINGLE) uses only onesignal (SIGUSR1)
When invoked the program reports its own process ID and then expects to read from standard input the process ID of the
process with which it will communicate.Subsequently,each line of input is treated as a separate message.For example:
% covertsigs
Own PID: 15310
14252
This is my first message
This is my second message
.
%
The name of theexecutableis covertsigs. Here 14252 is thefirst linetyped by the user which is the PID of the process to
communicate with.Then the messages areentered one-at-a-time. A line with a single period terminates the program (note
that it does not terminatetheexecution of the other process (14252) with which we werecommunicating).Thereceiving
process reports thereceived messages prefixing them with a ! exclamation mark symbol if it is confident it received it
correctly and with a ? question mark symbol if it has detected an error (yes it is possibleto haveerrors -- read on).For
example
% covertsigs
Own PID: 14252
15310
! This is my first message
! This is my second message
but it could have been (dueto errors in thefirst message):
% covertsigs
Own PID: 14252
15310
? ThIWE%@
! This is my second message
or any other combination that might results from errors and such.Thereason wecould havea messagein error is because,
as you will discover, thesignals are notalways reliableand also becauseit depends on how you decideto codethe messages
using signal(s).
In theinterest of readability, theexample presented above had one process sending and onereceiving. You areexpected
though to have,ateach process,a mix of messages received and messages sent. Consider for examplea session transcript
likethis:
% covertsigs
Own PID: 13333
13338
! Hi!
Hi to you too
! how's the weather
Fine
? same h3254dsg 453
Did you say "same here"
! yes
Essentially it is a two person chat channel (but generally of low speed and subject to errors).
Design Requirements
The most strict requirement is that the processes are notallowed to useany other form of communication between them
except for thespecified signals.
A performance-related requirement is thatyour throughput of delivering messages between the processes should be, on
average, 80 characters per minute or better.
Many aspects areleft under your own control.Each oneis a corresponding design decision thatyou need to explain and
report. You areexpected to report on at least thefollowing:
1. How do you code messages for the onesignal option (only SIGUSR1 used)?
2. How do you code messages for thetwo signals option (both SIGUSR1 and SIGUSR2 used)?
3. How do you represent message boundaries?
4. How do you check for errors?
5. Whaterrors may you not beableto catch?
6. How do you handletheinterleaving of input/output?
7. Is thereany other signal you had to use(and why)? -- such signal is of course notallowed for communication
8. How do you ensurethatyou do not spend unnecessary CPU cycles?
Deliverables
You should submityour assignmentas a singlecompressed archivefile(zip or tar.gz) containing:
The Makefile needed to compileyour program.The use of make and Makefile specifications will also bea requirement in
subsequentassignments.Theexecutable produced should be named covertsigs and your Makefile should at thevery
least providetargets covertsigs.single covertsigs.double and clean. Depending on whether you specified
covertsigs.single or covertsigs.double as thetarget, thecompilation will use(or not use) the -DSINGLE flag when
producing the covertsigs executable.
You must provideall of thesourcefiles needed to producetheexecutable. Remember that this must be C codeonly, using
the C99 style.
A file readme.md (plain text or Markdown markup) with your answers to the design questions. At theend of the readme.md
you must includea section describing how you balanced the work across thetwo group members. Also indicate whether
your code was tested (and running) on the official VM OR on the physical hosts in lab CSC 219.
Monday, January 7, 2019