b785956458bffdcaf30f37c7155ab02d5b9486ac
[tt2015.git] / a2 / 1cases.tex
1 \subsection{Preflight checklist}
2 Before actual certification is commenced we perform a manual test using a
3 checklist.
4 If any of the checks fail we immediately reject the product.
5 The checklist is given in the table below. All commands in \texttt{monospace}
6 are to be run in a terminal. Commands prefixed with a \texttt{\#} should be run
7 with root permissions. Commands prefixed with a \texttt{\$} should be run with
8 user permissions.
9
10 \begin{longtable}{|l|rp{.8\linewidth}|}
11 \hline
12 Check 1 & \multicolumn{2}{l|}{Get the SUT in a workable state.}\\
13 \hline
14 \multirow{3}{*}{Course of action}
15 & 1. & Import the VirtualBox image into VirtualBox.\\
16 & 2. & Boot the vm.\\
17 & 3. & Verify the SUT booted successfully and the network modules are
18 loaded.\\
19 \hline
20 Passed & \multicolumn{2}{l|}{\textit{Yes/No}}\\
21 \hline\hline
22 Check 2 & \multicolumn{2}{l|}{Verify the SUT is complete.}\\
23 \hline
24 \multirow{5}{*}{Course of action}
25 & 1. & Boot the SUT as in \emph{Check 1}.\\
26 & 2. & Verify the loopback device exists by running
27 \texttt{\$ ifconfig}.\\
28 & 3. & Verify the \emph{echo-server} is present on the system by running
29 \texttt{\$ file code/server/Main.java}\\
30 & 4. & Verify \emph{Scapy} is present on the system by running
31 \texttt{\$ scapy}.\\
32 & 5. & Verify all scripts used for testing are present on the system.\\
33 \hline
34 Passed & \multicolumn{2}{l|}{\textit{Yes/No}}\\
35 \hline\hline
36 Check 3 & \multicolumn{2}{l|}{Initialize the testing environment..}\\
37 \hline
38 \multirow{6}{*}{Course of action}
39 & 1. & Boot the SUT as in \emph{Check 1}.\\
40 & 2. & Setup iptables by executing
41 \texttt{\# code/iptables.sh}~\footnote{The IPTables script ensures
42 that the OS does not drop packets due to an the unknown source.}\\
43 & 3. & Navigate to the working directory by running
44 \texttt{\$ cd /home/student/tt2015}\\
45 & 4. & Compile the echo server by running
46 \texttt{\# cd code/server \&\& make}\\
47 & 5. & Start the echo server by running
48 \texttt{\# cd code/server \&\& java Main}\\
49 & 6. & Generate all test cases by running
50 \texttt{\$ python code/client/gen.py}\\
51 \hline
52 Passed & \multicolumn{2}{l|}{\textit{Yes/No}}\\
53 \hline\hline
54 Check 4 & \multicolumn{2}{l|}{Test the tool environment.}\\
55 \hline
56 \multirow{3}{*}{Course of action}
57 & 1. & Initialize the SUT as in \emph{Check 3}\\
58 & 2. & Execute the test script by running
59 \texttt{\# code/client/helloworld.py}\\
60 & 3. & Verify the console displays a success message.\\
61 \hline
62 Passed & \multicolumn{2}{l|}{\textit{Yes/No}}\\
63 \hline\hline
64 Check 5 & \multicolumn{2}{l|}{All test inputs and scripts are present.}\\
65 \hline
66 \multirow{2}{*}{Course of action}
67 & 1. & Boot the SUT as in \emph{Check 1}.\\
68 & 2. & Verify that the test generation script is present by running
69 \texttt{\$ file code/client/test.py}\\
70 \hline
71 Passed & \multicolumn{2}{l|}{\textit{Yes/No}}\\
72 \hline
73 \caption{Preflight checklist\label{tbl:preflight}}
74 \end{longtable}
75
76 \subsection{Testing of SUT}
77 The SUT is a series of services for other computer programs with no end-user
78 facing interface. Therefore the SUT will be tested solely by calling it's
79 services through various automated scripts. An automated test suite will be
80 available which executes all these automated scripts and aggregates their
81 results to asses whether or not the SUT has passed the test.
82
83 The implementation of the SUT is tested using black box testing techniques. A
84 series of tests asses the correctness of the implementation with regards to the
85 TCP specification. These tests are specified in Table~\ref{tbl:testpairs}. The test cases aim to cover the most interesting parts of the TCP
86 specification.
87
88 In this test suite the behavior of the outwards (network) interface of the SUT
89 is assessed. This is, the behavior of the SUT as
90 observed by another system on the network trying to communicate with (a system
91 running on the same host as the SUT using) the SUT. This is achieved by running
92 man
93 echo-server on the system which runs the SUT (a virtual machine) which
94 echos back all messages received to the sender. The test scripts will send
95 packets to the echo-server and then checks the received
96 response to asses whether or not the SUT is preforming as expected.
97
98 To cover the TCP specification as complete as possible while still maintaining
99 a feasible test suite the tests are divided into equivalence partitions. Below
100 these partitions are given.
101
102 \begin{enumerate}
103 \item \emph{Number of segments} in request~\footnote{A request is
104 considered establishing a connection (handshake) and a number of
105 payload segments}
106 \begin{enumerate}
107 \item 0 payload segments
108 \item 1 payload segments
109 \item n=small payload segments (1 byte)
110 \item n=big payload segments (65495 bytes)
111 \end{enumerate}
112 \item \emph{source port}
113 \begin{enumerate}
114 \item Correct
115 \item Incorrect
116 \end{enumerate}
117 \item \emph{destination port}
118 \begin{enumerate}
119 \item Correct
120 \item Incorrect
121 \end{enumerate}
122 \item Bit errors in \emph{payload}
123 \begin{enumerate}
124 \item Correct payload
125 \item Payload with bit flips that do not show in checksum
126 \item Payload with bit flips that do show in checksum
127 \end{enumerate}
128 \item \emph{checksum}
129 \begin{enumerate}
130 \item Correct
131 \item Incorrect
132 \end{enumerate}
133 \item \emph{Segment order}
134 \begin{enumerate}
135 \item Correct
136 \item Out of order
137 \item Missing Segments
138 \end{enumerate}
139 \end{enumerate}
140
141 These partitions were chosen since they correspond to key parts of the TCP
142 specification.
143
144 %
145 % één na laatste packket, moet dit B+3 of B+2 zijn?
146 %
147
148 TCP segments are send over a TCP connection from a \emph{source} to a \emph{destination port}. Therefore segments which are received that have a
149 source or destination port set to an incorrect value should not be regarded
150 as segments belonging to the connection by the SUT.
151
152 TCP uses a \emph{checksum} to catch any error introduced in headers, when this
153 checksum does not match the actual computed checksum the SUT should
154 disregard the received segment.
155
156 The TCP checksum is also an inherently weak one, as it is simply the
157 bitwise negation of the addition, in ones complement arithmetic,
158 of all 16 bit words in the header and data of the segment (excluding the
159 checksum itself). Therefore any \emph{bit error} where the ones complement value
160 of one word
161 increases by one, and the value of another decreases by one, is undetected.
162 The SUT should exhibit the same behavior and accept packets where these type
163 of bit errors occur.
164
165 TCP guarantees that segments are delivered \emph{in order}
166 , even when they are received
167 out of order and that missing segments are resend. The SUT should
168 exhibit the same behavior. If segments are received out of order it should
169 either reassemble them when the missing packet has arrived or request them to
170 be resend when the Missing segments should be re-requested (by ACK-ing
171 the correct sequence number).
172
173 A single request consists of a number of packets that are sent
174 to the \emph{echo-server} and back. The TCP specification states that such a
175 transaction requires the following messages.
176
177 \begin{flushleft}
178 Script $-$ SYN $A$ $\rightarrow$ SUT \\
179 Script $\leftarrow$ SYN-ACK $(A+1)$ $B$ $-$ SUT \\
180 Script $-$ ACK $(A+1)$ $(B+1)$ $\rightarrow$ SUT \\
181 Script $-$ ACK-PUSH $(A+1)$ $(B+2)$ \emph{msg} $\rightarrow$ SUT \\
182 Script $\leftarrow$ ACK $(A+2+msg_{length})$ $(B+3)$ $-$ SUT \\
183 Script $\leftarrow$ ACK-PUSH $(A+2+msg_{length})$ $(B+3)$ \emph{msg} $-$ SUT
184 \end{flushleft}
185
186 %
187 % RS ook? FIN?
188 %
189
190 When the \emph{SUT} has received the ACK containing the message it's passed
191 trough to the \emph{echo-server}. The \emph{echo-server} will proceed by ordering
192 the \emph{SUT} to respond by sending the exact same message. When this happens
193 the \emph{SUT} has to construct the last packet in the transaction listed above.
194
195 \bigskip
196
197 Partitions 2 to 6 are tested using pairwise testing to keep the number of test
198 cases feasible. The pairs are then all *except some where it does not make sense
199 to do so) tested with the different request sizes of partition 1.
200
201 This is expressed in Table~\ref{tbl:testpairs}. In this table the first five
202 columns represent the different options for the partitions 2 to 6 of the above
203 enumeration. The last four columns are the different number segments as
204 described in the partition 1 of the above enumeration. These cells identify
205 individual test cases by a number. An \xmark in the cell indicates that this
206 test case can not be created as it is not possible with that number of segments
207 (eg. sending segments out of order when the number of segments is 1).
208
209 \setcounter{TCC}{1}
210 \begin{table}[H]
211 \centering
212 \begin{tabular}{|l|l|l|l|l|l||l|l|l|l|}
213 \hline
214 & \multicolumn{9}{c|}{\textbf{Partition}}\\
215 \hline
216 & 4 & 5 & 3 & 6 & 2 & 1a & 1b & 1c & 1d\\
217 \hline\hline
218 \multirow{9}{*}{Instance}
219 & a & a & a & a & a & \doTCC & \doTCC & \doTCC & \doTCC\\
220 & a & b & b & c & b & \xmark & \xmark & \doTCC & \doTCC\\
221 & c & a & b & a & b & \xmark & \xmark & \doTCC & \doTCC\\
222 & c & b & a & c & a & \xmark & \xmark & \doTCC & \doTCC\\
223 & b & a & b & c & a & \xmark & \xmark & \doTCC & \doTCC\\
224 & b & b & a & b & b & \xmark & \xmark & \doTCC & \doTCC\\
225 & c & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\
226 & b & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\
227 & a & b & b & b & a & \xmark & \xmark & \doTCC & \doTCC\\
228 \hline
229 \end{tabular}
230 \caption{Combinations of test cases}
231 \label{tbl:testpairs}
232 \end{table}
233
234 \subsection{Quality, completeness and coverage of tests}
235
236 The network packets used in testing are constructed from prerecorded, known to
237 be correct, network traffic. These packets are then modified with well used and
238 field tested tools. Due to this the chance of errors in the test cases is quite
239 low. However, no formal proof of correctness of the test cases is present, this
240 means that any defects found might not be the result of a fault in the SUT.
241 Therefore detected defects should only indicate there is a high chance that
242 there is a fault in the SUT and can not result directly in the conclusion that
243 there actually is one.
244
245 \bigskip
246
247 Due to the nature of black-box testing coverage of the code in the
248 implementation of the SUT is unknown. However completeness of the tests over
249 the specification of the SUT can be assessed.
250
251 \bigskip
252
253 Due to the clear and exhaustive specification of TCP the completeness of the
254 test suite can be clearly assessed.
255
256 As always, $100\%$ completeness is not feasible, therefore test cases are
257 carefully selected to cover the most interesting parts of the TCP specification
258 to ensure a complete but feasible test suite.
259
260 To further increase the coverage of the test suites tests are randomized. The
261 tests which test the handling of \emph{bit errors}, changes in the \emph{packet
262 order} and \emph{dropped packets} randomize where they introduce an error. The
263 test suite runs these tests multiple times to increase the likelihood that they
264 discover a fault which is only present when an error occurs in a certain
265 position.
266
267 To further decrease the number of tests needed test cases are divided into
268 equivalence partitions and the combination of cases as described in
269 Table~\ref{tbl:testpairs} ensures that all partitions are
270 covered and the number of individual tests is still feasible.
271
272
273 %
274 % wat ik ook probeer ik krijg de eerste collum
275 % zijn tekst niet verticaal gecentered
276 %
277
278
279 \subsection{Test suite}
280
281 Before executing the test suite the test environment has to be initialized.
282
283 \begin{enumerate}
284 \item Boot the vm using VirtualBox.
285 \item Setup iptables by executing \texttt{\# code/iptables.sh}
286 \item Navigate to the working directory by running
287 \texttt{\$ cd /home/student/tt2015}
288 \item Start the echo server by running
289 \texttt{\# cd code/server \&\& Java Main}
290 \end{enumerate}
291
292 \subsubsection{Preflight checks}
293 The we do the preflight checks as defined in Table~\ref{tbl:preflight}.
294
295 \subsubsection{Test Cases}
296 If the SUT passes the preflight checks the actual test cases can be executed.
297 Table~\ref{tbl:testcases} shows the expected results of each of the test cases
298 described in Table~\ref{tbl:testpairs}.
299
300 \setcounter{TCC}{1}
301 \begin{table}[H]
302 \centering
303 \begin{tabular}{|l|p{.7\linewidth}|}
304 \hline
305 Test number & Expected results\\
306 \hline\hline
307 \doTCC & An ACK\# of the send sequence number + 1.\\ \hline
308 \doTCC & An ACK\# of the sequence number of the last send segment + the
309 size of the payload of that segment.\\ \hline
310 \doTCC & An ACK\# of the sequence number of the last send segment + the
311 size of the payload of that segment.\\ \hline
312 \doTCC & An ACK\# of the sequence number of the last send segment + the
313 size of the payload of that segment.\\ \hline
314 \doTCC & An ACK\# of the sequence number of the swapped packet with the lowest sequence number. \\ \hline
315 \doTCC & The ACK\# for the SEQ\# of the first segments which is
316 corrupted is received for each consecutive segment send.\\
317 $\vdots$ & \\
318 \setcounter{TCC}{10}
319 \doTCC & The ACK\# for the SEQ\# of the first segments which is
320 corrupted is received for each consecutive segment send.\\ \hline
321 \doTCC & An ACK\# of the sequence number of the last send segment + the
322 size of the payload of that segment.\\ \hline
323 % \doTCC & The segment is not attributed to the current connection
324 % and therefore no ACK\# is received. \\ \hline
325 % \doTCC & The ACK\# for the SEQ\# of the first segments which is
326 % corrupted is received for each consecutive segment send.\\ \hline
327 % \doTCC & The ACK\# for the SEQ\# of the first segments which is
328 % corrupted is received for each consecutive segment send.\\ \hline
329 % \doTCC & The segment is not attributed to the current connection
330 % and therefore no ACK\# is received. \\ \hline
331 % \doTCC & The ACK\# for the SEQ\# of the first segments which is
332 % corrupted is received for each consecutive segment send.\\ \hline
333 % \doTCC & The ACK\# for the SEQ\# of the first segments which is
334 % corrupted is received for each consecutive segment send.\\ \hline
335 % \doTCC & The ACK\# for the SEQ\# of the first segments which is
336 % corrupted is received for each consecutive segment send.\\ \hline
337 % \doTCC & The ACK\# for the SEQ\# of the first segments which is
338 % corrupted is received for each consecutive segment send.\\ \hline
339 \end{tabular}
340 \caption{Expected results of test cases}
341 \label{tbl:testcases}
342 \end{table}
343
344 % Bij Ramons afwezigheid
345 % Paul Vitero (linkerkant lange gang)
346 % verdieping Mercator
347
348
349 \begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|}
350 \hline
351 Nr & 1 \\\hline
352 Title & Single valid request with 1byte payload. \\\hline
353 Input & Generated packets. \\\hline
354 Expected output & Packets echoed back by Echo-Server. \\\hline
355 \multirow{2}{*}{Course of action}
356 & 1. Use the steps listed above in order to start the SUT. \\
357 & 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline
358 Valid trace & Verify that the script prints 'Success'. \\\hline
359 \hline
360
361 Nr & 2 \\\hline
362 Title & Single valid request with 65495bytes payload. \\\hline
363 Input & Generated packets. \\\hline
364 Expected output & Packets echoed back by Echo-Server. \\\hline
365 \multirow{2}{*}{Course of action}
366 & 1. Use the steps listed above in order to start the SUT. \\
367 & 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline
368 Valid trace & Verify that the script prints 'Success'. \\\hline
369 \hline
370
371 Nr & 3 \\\hline
372 Title & 5 valid requests with 1byte payload. \\\hline
373 Input & Generated packets. \\\hline
374 Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline
375 \multirow{2}{*}{Course of action}
376 & 1. Use the steps listed above in order to start the SUT. \\
377 & 2. Execute the script by running \texttt{\# code/client/tests/3.py} \\\hline
378 Valid trace & Verify that the script prints 'Success'. \\\hline
379 \hline
380
381 Nr & 4 \\\hline
382 Title & 5 valid requests with 65495bytes payload. \\\hline
383 Input & Generated packets with 65495bytes payload. \\\hline
384 Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline
385 \multirow{2}{*}{Course of action}
386 & 1. Use the steps listed above in order to start the SUT. \\
387 & 2. Execute the script by running \texttt{\# code/client/tests/4.py} \\\hline
388 Valid trace & Verify that the script prints 'Success'. \\\hline
389 \hline
390
391 Nr & 5 \\\hline
392 Title & 5 valid requests with 1byte payload sent out of order. \\\hline
393 Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline
394 Expected output & All requests sent up to and including
395 the swapped packet with the lowest sequence number, the remaining packets are ropped. \\\hline
396 \multirow{2}{*}{Course of action}
397 & 1. Use the steps listed above in order to start the SUT. \\
398 & 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline
399 Valid trace & Verify that the script prints 'Success'. \\\hline
400 \hline
401
402 Nr & 6 \\\hline
403 Title & Request with corrupted source port. \\\hline
404 Input & Generated packets with 1byte payload, in these packets the source port Number is increased by one. \\\hline
405 Expected output & The Echo server will receive the packet but is not able to respond with a ACK, this will result in a connection time out. \\\hline
406 \multirow{2}{*}{Course of action}
407 & 1. Use the steps listed above in order to start the SUT. \\
408 & 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline
409 Valid trace & Verify that the script prints 'Success'. \\\hline
410 \hline
411
412
413 Nr & 7 \\\hline
414 Title & Request with corrupted destination port. \\\hline
415 Input & Generated packets with 1byte payload, in these packets the destination port number is increased by one. \\\hline
416 Expected output & The packets will never reach the Echo-server resulting in a connection time-out. \\\hline
417 \multirow{2}{*}{Course of action}
418 & 1. Use the steps listed above in order to start the SUT. \\
419 & 2. Execute the script by running \texttt{\# code/client/tests/7.py} \\\hline
420 Valid trace & Verify that the script prints 'Success'. \\\hline
421 \hline
422
423 Nr & 8 \\\hline
424 Title & Request with corrupted source address. \\\hline
425 Input & Generated packets with 1byte payload, in these packets the source address is replaced with 255.255.255.255. \\\hline
426 Expected output & The Echo-server will receive packet and is unable to respond with a ACK resulting in a connection time-out. \\\hline
427 \multirow{2}{*}{Course of action}
428 & 1. Use the steps listed above in order to start the SUT. \\
429 & 2. Execute the script by running \texttt{\# code/client/tests/8.py} \\\hline
430 Valid trace & Verify that the script prints 'Success'. \\\hline
431 \hline
432
433 Nr & 9 \\\hline
434 Title & Request with corrupted destination address. \\\hline
435 Input & Generated packets with 1byte payload, in these packets the destination address is replaced with 255.255.255.255. \\\hline
436 Expected output & The packets will never reach the Echo-server resulting in a connection time-out. \\\hline
437 \multirow{2}{*}{Course of action}
438 & 1. Use the steps listed above in order to start the SUT. \\
439 & 2. Execute the script by running \texttt{\# code/client/tests/9.py} \\\hline
440 Valid trace & Verify that the script prints 'Success'. \\\hline
441 \hline
442
443 Nr & 10 \\\hline
444 Title & Request with corrupted payload detectable by checksum. \\\hline
445 Input & Generated packets with 1byte payload, in these packets one byte is increased by 1 after the checksum has been calculated. \\\hline
446 Expected output & The \emph{SUT} will drop packets before sending them resulting in a runtime error of the test script. \\\hline
447 \multirow{2}{*}{Course of action}
448 & 1. Use the steps listed above in order to start the SUT. \\
449 & 2. Execute the script by running \texttt{\# code/client/tests/10.py} \\\hline
450 Valid trace & Verify that the script prints 'Success'. \\\hline
451 \hline
452
453 Nr & 11 \\\hline
454 Title & Request with corrupted payload undetectable by checksum. \\\hline
455 Input & Generated packets with 1byte payload, in these packets one 16bit word is increased by 1 and an other 16bit word is decreased by 1, after the checksum has been calculated. \\\hline
456 Expected output & Echo-server receives the corrupted segment. \\\hline
457 \multirow{2}{*}{Course of action}
458 & 1. Use the steps listed above in order to start the SUT. \\
459 & 2. Execute the script by running \texttt{\# code/client/tests/11.py} \\\hline
460 Valid trace & Verify that the script prints 'Success'. \\\hline
461
462 \end{longtable}
463
464 %\begin{tabularx}{\linewidth}{| l | X|}
465 %\hline
466 %Nr & 1 \\\hline
467 %Title & Single valid request. \\\hline
468 %Input & Pcap file with prerecorded valid packets. \\\hline
469 %Expected output & Pcap file with valid response to request. \\\hline
470 %Course of action & \begin{enumerate}
471 % \item Execute \emph{./scripts/tests/case1-single-valid.sh}
472 % \item Load \emph{output/case1.pcap} with ...
473 %\end{enumerate} \\\hline
474 %Valid trace & \begin{enumerate}
475 % \item \textbf{Hier packets benoemen?}
476 %\end{enumerate} \\\hline
477 %\end{tabularx}
478 %
479 %\begin{tabularx}{\linewidth}{| l | X|}
480 % \hline
481 % Nr & 2 \\\hline
482 %Title & Single request with corrupted checksum. \\\hline
483 % Input & Pcap file used as \emph{test-case 1} input. \\\hline
484 % Expected output & No response from SUT, logs with rejected packets. \\\hline
485 % Course of action & \begin{enumerate}
486 % \item Load input pcap file into ....
487 % \item Corrupt checksum of loaded packets.
488 % \item Save resulting packets as pcap file.
489 % \item Load new pcap file into ...
490 % \item Replay new pcap file.
491 % \item Record SUT response using...
492 % \item Extract log with rejected packets.
493 % \item Save recorded packets as a pcap file.
494 % \item Analyze packets in resulting file.
495 % \end{enumerate} \\\hline
496 % Valid trace & \begin{enumerate}
497 % \item \textbf{Aangeven welke packets corrupted zijn?}
498 % \end{enumerate} \\\hline
499 %\end{tabularx}
500 %\end{table}