首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导CMPUT 379语言、c/c++编程设计调试、辅导c++程序 辅导Python编程|讲解数据库SQL
项目预算:
开发周期:
发布时间:
要求地区:
CMPUT 379, Assignment 2, Winter 2021
University of Alberta / Department of Computing Science
(sockets, pthreads, client-server, inotify, synchronization)
Objective
You are asked to implement a client/server application. Multiple clients connect to a single server. In this
assignment, the server acts as an intermediary among two kinds of clients. The first kind of client (observer client)
monitors a file or directory using the inotify facility (man inotify for more information) and reports to the
server all the changes noticed by inotify on the monitored file/directory. Multiple such clients, each monitoring
a different file or directory, and possibly at different hosts, can be connected to the server at any point in time.
The second kind of client (user client) refreshes the screen regularly (similarly to the top command) to display the
most recent inotify data reported by each one of the observer clients currently connected to the server.
All three roles (server, observer client, user client) are implemented by a single executable notapp) and the
specific role is controlled by the flags and arguments passed to it. Specifically:
server:
notapp -s -t
[-p
] [-l
]
observer client:
notapp -o
user client:
notapp -u
Where
indicates how frequently the server broadcasts to the user clients the most recent events of
its observer clients. The
can take values from 0.1 to 10 seconds. The
is the server port and it
is optional. If not provided, the system chooses a port for the server. This port (the chosen by the system) should
be printed by the server to stdout before it becomes a daemon process. The
is an optional log file
where the server keeps track of all the messages it received and any of the actions that it took. The log file is
meant mainly for debugging, so it has to be informative to you and the teaching assistants.
When starting as a client of either type (observer or user), the client connects to the server listening on port
of the host with
IP address. In the case of an observer client, the
indicates the file
or directory to monitor for all possible inotify events.
Observer Client Behavior
The observer is a producer of information and, as such, does not need to consume information coming from the
server. Rather, it provides information to the server. The observer monitors the file or directory indicated for all
2 / 4
possible inotify events, and it reports those events to the server. There is no strong requirement to use multiple
threads for an observer client (or any client for that matter), although one could use them to good advantage. At
a minimum, the first message from a client to the server should allow the server to distinguish whether a client is
an observer or a user client, and, if it is an observer client, what is the file or directory that the particuar observer
is monitoring. There are three requirements for observer clients: a) to send each inotify_event information as
soon as possible to the server, i.e., to not delay it unnecessarily, b) to annotate each such information with the
local timestamp when it happened (in microsecond accuracy, see man gettimeofday), and c) to gracefully
terminate and let the server know it terminated when either (i) the file or directory being monitored is removed,
or (ii) it receives a SIGINT signal. The observer client does not depend on any user terminal input, so it should be
possible to let it run as a background process. It should not produce output to stdout. Finally, for simplicity,
monitoring of directory should not be recursive.
User Client Behavior
The user client, after connecting to the server, periodically refreshes the screen and (assuming N observers are
connected to the server at that point) it displays the most recent inotify event sent by each of the N observers
to the server, sorted in order of timestamps. The output is one line for each of the N observers. The server,
recognizes (see comment for Observer Client Behavior) that it is talking to a user client. The server pushes to the
client, every
seconds, the updated list of most recent event from each of the observer clients.
Therefore, the user client is expected to refresh the screen with the most recent events once every
seconds. Note that N changes over time and, hence, there might be more, or fewer, lines from one instant to the
next. The user client is supposed to do minimal work, i.e., just the rendering of the information sent from the
server. The user client should terminate when receiving a control-C, but it should do so gracefully, by notifying
the server that it is terminating.
User Client Output Format
The format of the lines displayed by user clients follows the format of this example (with N=3). Upper left is upper
left of the terminal screen. Notice that they are sorted by timestamp with the most recent at the top:
TIME HOST MONITORED EVENT
1612142039.611365 192.168.0.3 myDir f.txt IN_ACCESS
1612142019.855106 192.168.0.10 /tmp src IN_CREATE IN_ISDIR
1612142000.471291 127.0.0.1 a.txt IN_ATTRIB
The time is in the format of seconds followed by a period followed by microseconds (consult man
gettimeofday). HOST is the IP address of the host on which the corresponding observer is running. MONITORED is
the monitored file or directory. In this example, the last observer in the list happens to be monitoring a file
(a.txt) while the two others are directories. The EVENT is the information conveyed in the event mask in human
readable form (see man inotify for the names). If the observer is monitoring a directory, then EVENT is prefixed
by the name of the relevant file or directory within the monitored directory (see name member in struct
inotify_event). In the above examples, someone changed an attribute (e.g., chmod) on a.txt; a subdirectory
named src was created within /tmp; file f.txt (which is inside directory myDir) was read.
3 / 4
Server Behavior
The server binds to the port, it becomes a daemon process, and waits for connections from the clients. In the
initial handshake with the client it has to determine whether a client is an observer or a user client. No
assumptions can be made that all observers (or any observer) connect first. Either kind of client might wish to
connect (or gracefully terminate the connection) to the server at any point in time. The server is responsible for
keeping track of the clients. It is a requirement that each new cleint connection to the server is handled by a
separate pthread. The thread should be terminated when the corresponding connection terminates.
The server works in the following fashion: a) it collects, as quickly as possible, data received from the observer
clients and updates a common data structure which stores the most recent event that came from each observer. If
a logfile was specified, the server also dumps the received events to the log file, in the order they are received. b)
The threads serving the user clients are periodically (with
period) sending the updated information
of this common data structure to their corresponding user clients, so that it can be rendered. It is expected that if
there are M user clients connected at the moment the periodic update is triggered, all M clients receive
consistent, i.e., identical, information. In other words, the threads serving the user clients "broadcast" the current
state of most recent events to all simultaneously connected user clients. It is expected that the server handles the
terminating clients in a graceful manner, i.e., without crashes or undue delays. Finally note that the common data
structure at the server may be accessed by multiple threads at the same time. You will need to use concurrency
control for its access.
There is no specific requirement for the protocol format between clients and server. However, you have to
document what is the protocol you use (what messages you are sending and/or expecting).
Refinement
A requirement is to add one more refinement to your code. There are two possible refinements from which you
can choose.
Server timestamps
The clocks of different hosts are not synchronized, therefore timestamps of observers from different hosts can be
inconsistent (e.g., something might arrive later from another host but have an earlier timestamp than a current
event on our host). Introduce a compilation flag that forces the server to ignore the timestamp associated with
the events sent from the observers and instead uses its own local (at the host where the server is running)
timestamps. These timestamps are of the time instant the server received the corresponding event.
Fresh info visualization
Between two "broadcasts" there might be more than one event from an observer. This is easily handled by having
the server store the most recent event ("overwriting" the previous event) coming from that observer. The
implication is that you might not see some of the events reported by the user clients if a more recent event for
the same observer has occurred within the interval. This is to be expected and it is correct. There could also be
intervals where no new events have been observed by one or more observers. In this case the user server will
broadcast (and the user client will render) the same most recent event information for the observers that had
nothing new. (And the new information for those observers who had more recent events.) Introduce a
4 / 4
compilation flag to add boldface font to the lines representing new recent event from the corresponding
observer.
Deliverables
The language of implementation is C. You are expected to deliver good quality, efficient, modular,
documented, code. That is, the quality of your code will be marked.
Your assignment should be submitted as a single compressed (zip or tar.gz) archive file. The archive should
contain all necessary source files as well as a Makefile. Calling make without any arguments should generate the
notapp executable. Your submission must include the DESIGN.md (plain text or markdown format) document
which: (a) describes your protocol between clients and server, and (b) indicates which refinement you
implemented. Refinement executables should be produced by issuing make notapp.time or make notapp.bold
(depending on which refinement you decided to implement).
In the lab machines, always remember to terminate any processes you have left running before leaving or
logging out your ssh session, and in general before you turn your attention to some other task. Generally,
ensure that you have not left any stray processes running on the physical machine before leaving. Violations of
this rule may be penalized with mark deductions. Furthermore, the system administrators have been given
permission to terminate such processes and to report to the instructor the users who left them running.
Monday, February 1st, 2021
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!