שלום לכולם
מישהו היה אתמול בראיון הזה
מה שאלו , איזה שאלת תיכנות הייתה ?? מה היו השלבים הבאים
אשמח אם ישתפו אותי תודה
ע"י: בוגר28
למישהו יש פיתרון?
אודה אם תוכלו לשתף
ע"י: 1_אורח_כללי
מישהו היה בראיון עם ראש צוות (אחרי המבחן המדובר) ויודע מה שואלים שם?
ע"י: אנה
יש אולי גם פתרון לשאלה?
תודה לכולם
ע"י: בוגר28
יש אולי גם פתרון לשאלה?
תודה לכולם
אם השגת פיתרון לשאלה אני אודה לך אם תוכלי לשתף
תודה מראש
ע"י: אנה
אולי את זוכרת מה שאלו במבחן השני והשלישי?
ע"י: 1_אורח_כללי
היי - הייתי שם בראיון לפני כשלושה שבועות.
מתבקשים לפתור שאלה על מחשב. אני מצרפת את הקובץ המתאר את השאלה כפי שניתן ביום הבחינה.
בהצלחה
Overview
Your assignment is to implement a function that verifies a protocol between A and B.
The protocol name is CPTPv1 (Check Point Testing Protocol version 1).
The function named do_test receives as an argument a message passing between A and
B (or between B and A) and its task is to indicate to the calling application (The function
is called from an application/program) whether this is a legitimate message (A legitimate
message must comply CPTPv1).
The calling application will call do_test for a large sequence of messages (each call
handles only one message).
You can think or imagine that this function could be used in some filtering device
located between A and B that validates the protocol between A and B. The device
captures all messages passing between A and B (and between B and A) and using your
implementation of do_test function decides whether the message is valid (in this case the
message would be forwarded to its destination) or invalid (in this case the device will
indicate to the administrator about an error and will drop the message).
Scoring is based on (in declining priority):
1. Security (Validity) - Your implementation of do_test must be 100% accurate. It
must categorize all invalid messages as invalid and all valid messages as valid. An
implementation that will not be 100% accurate will fail the test.
2. Styling – Your code should be structured and modular. Use clear remarks.
.
3. Performance – Your implementation of do_test will be evalutated using a test
program (the same test program will execute all candidate’s implementations on
the same computer). Performance is measured by number of messages tested per
second (or the average duration of processing a message in micro seconds).
In order to enable you to test your implementation before submitting your solution, a test
program that tests both the Security and the Performance of your code is available. The
MFC Project is organized in such a way that this program will be compiled with your
implementation of do_test. It is highly recommended to use this test program prior to
submitting your implementation.
Test Details
CPTPv1 protocol details
•
•
Protocol runs between A and B.
A is always the client and B is always the server. There is only one client (A) and
one server (B).
Each message is passed to do_test function using test_unit structure (see defs.h
header file) that contains information about the direction and a pointer to a nil
terminated string (array of char …) containing the message itself.
The following table describes the protocol:
•
•
Protocol Allowed message(s) in given state
State
Direction
Text
1
A to B
OPEN_CONNECTION
(Initial)
2
B to A
OPEN_CONNECTION_ACKED
3
A to B
One of:
LIST
GETFILE
LISTEN
GETALL
GEAR
LIFT
SAVE
SAVEALL
SAVETHEQUEEN
3
A to B
EXIT
4
B to A
Previous-state-match-name
{*} Previous-state-
match-name
Note:
1. Previous-state-match-
name means the last command
processed (in state 3)
2. Always a total of 2 white
spaces.
5
B to A
EXIT_ACKED
•
Given the protocol is at state x (described in Protocol State column) and it
receives a message that matches on of the messages that are allowed for the given
state (described in Allowed messages columns), then this message is defined as a
legitimate and the new state is defined in new-state column. In this case do_test
New
State
2
3
4
Example
OPEN_CONNECTION
OPEN_CONNECTION_ACKED
LIST
5
3
EXIT
LIST LIST
Or
LIST 0123z4b56aaaz2 LIST
1
EXIT_ACKED
has to return RET_VALID.
When match does not occur the return value should be RET_INVALID, and the
protocol moves to the initial state (1).
•
A communication example (20 messages) and expected results:
Number Direction Text
do_test
Notes
expected result
1
A to B
OPEN_CONNECTION
RET_VALID
2
B to A
OPEN_CONNECTION_ACKED RET_VALID
3
A to B
LIST
RET_VALID
4
B to A
LIST 0123z4b56aaaz2 LIST
RET_VALID
5
A to B
GEAR
RET_VALID
6
B to A
GEAR 1111 GEAR
RET_VALID
7
A to B
EXIT
RET_VALID
8
B to A
EXIT_ACKED
RET_VALID
9
A to B
OPEN_CONNECTION_ACKED RET_INVALID Message
out of
state and
in wrong
direction
10
A to B
OPEN_CONNECTION
RET_VALID
11
B to A
OPEN_CONNECTION_ACKED RET_VALID
12
A to B
LIST
RET_VALID
13
B to A
LIST 0123z4b5T6aaaz2 LIST
RET_INVALID Wrong char
in response
+ 2 spaces
between “
…2” and
the second
LIST.
15
B to A
LIST 0123z4b56aaaz2 LIST
RET_INVALID Message
out of state
16
A to B
GEAR
RET_INVALID Message
out of state
17
A to B
OPEN_CONNECTION
RET_VALID
18
B to A
OPEN_CONNECTION_ACKED RET_VALID
21
A to B
GEAR
RET_VALID
22
B to A
GEAR GEAR
RET_VALID
Note: In
this case 2
spaces are
required
19
A to B
GEAR
RET_VALID
20
B to A
GEAR GEAR
RET_INVALID Only 1
space
…
Instruction for do_test implementation and coding
•
•
Prototype of the function (given in defs.h header file) is:
int do_test(struct TestUnit *test_unit);
You are not allowed to change the prototype of the function.
Parameters:
test_unit - point to test_unit structure.
Important – Assume the memory pointed by test_unit is deallocated (free-d or
reused) after the application called do_test.
Returns values:
RET_VALID
RET_INVALID
•
•
•
More Notes:
o Use only the specified source files.
o You can modify defs.h and test.c files. You can’t modify main.c file.
o You can add/define as many functions as you like (You don’t need to
implement every thing in do_test, you can call other helper function that
you write…).
o The basic structure of do_test can’t be modified.
o If the program won't compile on instructors machine result your score will
be score penalized. Don’t modify the compiler setting and environment
given to you.
o The only allowed coding language is C.
Basic HOWTO about MFC
Project is already open.
Ctrl+F7, F7 – Compile, Build. (Both are located under Build Menu).
Ctrl+F5 – Runs the test program (shows validity test and performance test results). F1 –
Alt+F7 – Opens project’s setting. At Debug tab you can control Program arguments (file
name containing messages and number of test cycles).
How to submit your implementation?
Call the instructor he will copy defs.h and test.c files to the testing computer.
Tips
•
Before coding anything:
o Read the instructions and the example carefully.
o Spend time on designing/planning your solution.
Make use of the test program to validate your implementation and to test
performance. You can change program arguments to test specific files that you
•
can craft from the test file and control the number of cycles.
Once you have an implementation that works and returns correct results for all
messages, backup it before trying further to improve it.
You can use MSDN (Start > Programs > Microsoft Development Network >
MSDN Library …) for help about C standard functions etc.
You can debug your program if necessary.
•
•
•
ע"י: אנה
אני הולכת ביום שלישי ליום בחינות
משהו יכול לפרט מה שואלים?