14900c941fd95e4de6fd702b26a07ff7c4c6389f
[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 sent a
174 to the \emph{echo-server} and back. The TCP specification state that such a
175 transaction requires the following messages.
176
177 \begin{center}
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{center}
185
186 \bigskip
187
188 Partitions 2 to 6 are tested using pairwise testing to keep the number of test
189 cases feasible. The pairs are then all *except some where it does not make sense
190 to do so) tested with the different request sizes of partition 1.
191
192 This is expressed in Table~\ref{tbl:testpairs}. In this table the first five
193 columns represent the different options for the partitions 2 to 6 of the above
194 enumeration. The last four columns are the different number segments as
195 described in the partition 1 of the above enumeration. These cells identify
196 individual test cases by a number. An \xmark in the cell indicates that this
197 test case can not be created as it is not possible with that number of segments
198 (eg. sending segments out of order when the number of segments is 1).
199
200 \setcounter{TCC}{1}
201 \begin{table}[H]
202 \centering
203 \begin{tabular}{|l|l|l|l|l|l||l|l|l|l|}
204 \hline
205 & \multicolumn{9}{c|}{\textbf{Partition}}\\
206 \hline
207 & 4 & 5 & 3 & 6 & 2 & 1a & 1b & 1c & 1d\\
208 \hline\hline
209 \multirow{9}{*}{Instance}
210 & a & a & a & a & a & \doTCC & \doTCC & \doTCC & \doTCC\\
211 & a & b & b & c & b & \xmark & \xmark & \doTCC & \doTCC\\
212 & c & a & b & a & b & \xmark & \xmark & \doTCC & \doTCC\\
213 & c & b & a & c & a & \xmark & \xmark & \doTCC & \doTCC\\
214 & b & a & b & c & a & \xmark & \xmark & \doTCC & \doTCC\\
215 & b & b & a & b & b & \xmark & \xmark & \doTCC & \doTCC\\
216 & c & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\
217 & b & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\
218 & a & b & b & b & a & \xmark & \xmark & \doTCC & \doTCC\\
219 \hline
220 \end{tabular}
221 \caption{Combinations of test cases}
222 \label{tbl:testpairs}
223 \end{table}
224
225 \subsection{Quality, completeness and coverage of tests}
226
227 The network packets used in testing are constructed from prerecorded, known to
228 be correct, network traffic. These packets are then modified with well used and
229 field tested tools. Due to this the chance of errors in the test cases is quite
230 low. However, no formal proof of correctness of the test cases is present, this
231 means that any defects found might not be the result of a fault in the SUT.
232 Therefore detected defects should only indicate there is a high chance that
233 there is a fault in the SUT and can not result directly in the conclusion that
234 there actually is one.
235
236 \bigskip
237
238 Due to the nature of black-box testing coverage of the code in the
239 implementation of the SUT is unknown. However completeness of the tests over
240 the specification of the SUT can be assessed.
241
242 \bigskip
243
244 Due to the clear and exhaustive specification of TCP the completeness of the
245 test suite can be clearly assessed.
246
247 As always, $100\%$ completeness is not feasible, therefore test cases are
248 carefully selected to cover the most interesting parts of the TCP specification
249 to ensure a complete but feasible test suite.
250
251 To further increase the coverage of the test suites tests are randomized. The
252 tests which test the handling of \emph{bit errors}, changes in the \emph{packet
253 order} and \emph{dropped packets} randomize where they introduce an error. The
254 test suite runs these tests multiple times to increase the likelihood that they
255 discover a fault which is only present when an error occurs in a certain
256 position.
257
258 To further decrease the number of tests needed test cases are divided into
259 equivalence partitions and the combination of cases as described in
260 Table~\ref{tbl:testpairs} ensures that all partitions are
261 covered and the number of individual tests is still feasible.
262
263
264 %
265 % wat ik ook probeer ik krijg de eerste collum
266 % zijn tekst niet verticaal gecentered
267 %
268
269
270 \subsection{Test suite}
271
272 Before executing the test suite the test environment has to be initialized.
273
274 \begin{enumerate}
275 \item Boot the vm using VirtualBox.
276 \item Setup iptables by executing \texttt{\# code/iptables.sh}
277 \item Navigate to the working directory by running
278 \texttt{\$ cd /home/student/tt2015}
279 \item Start the echo server by running
280 \texttt{\# cd code/server \&\& Java Main}
281 \end{enumerate}
282
283 \subsubsection{Preflight checks}
284 The we do the preflight checks as defined in Table~\ref{tbl:preflight}.
285
286 \subsubsection{Test Cases}
287 If the SUT passes the preflight checks the actual test cases can be executed.
288 Table~\ref{tbl:testcases} shows the expected results of each of the test cases
289 described in Table~\ref{tbl:testpairs}.
290
291 \setcounter{TCC}{1}
292 \begin{table}[H]
293 \centering
294 \begin{tabular}{|l|p{.7\linewidth}|}
295 \hline
296 Test number & Expected results\\
297 \hline\hline
298 \doTCC & An ACK\# of the send sequence number + 1.\\ \hline
299 \doTCC & An ACK\# of the sequence number of the last send segment + the
300 size of the payload of that segment.\\ \hline
301 \doTCC & An ACK\# of the sequence number of the last send segment + the
302 size of the payload of that segment.\\ \hline
303 \doTCC & An ACK\# of the sequence number of the last send segment + the
304 size of the payload of that segment.\\ \hline
305 \doTCC & The ACK\# for the SEQ\# of the first segments which is
306 corrupted is received for each consecutive segment send.\\
307 $\vdots$ & \\
308 \setcounter{TCC}{14}
309 \doTCC & The ACK\# for the SEQ\# of the first segments which is
310 corrupted is received for each consecutive segment send.\\ \hline
311 \doTCC & The segment is not attributed to the current connection
312 and therefore no ACK\# is received. \\ \hline
313 \doTCC & The ACK\# for the SEQ\# of the first segments which is
314 corrupted is received for each consecutive segment send.\\ \hline
315 \doTCC & The ACK\# for the SEQ\# of the first segments which is
316 corrupted is received for each consecutive segment send.\\ \hline
317 \doTCC & The segment is not attributed to the current connection
318 and therefore no ACK\# is received. \\ \hline
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 & The ACK\# for the SEQ\# of the first segments which is
322 corrupted is received for each consecutive segment send.\\ \hline
323 \doTCC & The ACK\# for the SEQ\# of the first segments which is
324 corrupted is received for each consecutive segment send.\\ \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 \end{tabular}
328 \caption{Expected results of test cases}
329 \label{tbl:testcases}
330 \end{table}
331
332 % Bij Ramons afwezigheid
333 % Paul Vitero (linkerkant lange gang)
334 % verdieping Mercator
335
336
337 %\begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|}
338 %\hline
339 %Nr & 1 \\\hline
340 %Title & Single valid request with 1byte payload. \\\hline
341 %Input & Generated packets. \\\hline
342 %Expected output & Packets echoed back by Echo-Server. \\\hline
343 %\multirow{2}{*}{Course of action}
344 %& 1. Use the steps listed above in order to start the SUT. \\
345 %& 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline
346 %Valid trace & Verify that the script prints 'Success'. \\\hline
347 %\hline
348 %
349 %Nr & 2 \\\hline
350 %Title & Single valid request with 65495bytes payload. \\\hline
351 %Input & Generated packets. \\\hline
352 %Expected output & Packets echoed back by Echo-Server. \\\hline
353 %\multirow{2}{*}{Course of action}
354 %& 1. Use the steps listed above in order to start the SUT. \\
355 %& 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline
356 %Valid trace & Verify that the script prints 'Success'. \\\hline
357 %\hline
358 %
359 %Nr & 3 \\\hline
360 %Title & 5 valid requests with 1byte payload. \\\hline
361 %Input & Generated packets. \\\hline
362 %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline
363 %\multirow{2}{*}{Course of action}
364 %& 1. Use the steps listed above in order to start the SUT. \\
365 %& 2. Execute the script by running \texttt{\# code/client/tests/3.py} \\\hline
366 %Valid trace & Verify that the script prints 'Success'. \\\hline
367 %\hline
368 %
369 %Nr & 4 \\\hline
370 %Title & 5 valid requests with 65495bytes payload. \\\hline
371 %Input & Generated packets with 65495bytes payload. \\\hline
372 %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline
373 %\multirow{2}{*}{Course of action}
374 %& 1. Use the steps listed above in order to start the SUT. \\
375 %& 2. Execute the script by running \texttt{\# code/client/tests/4.py} \\\hline
376 %Valid trace & Verify that the script prints 'Success'. \\\hline
377 %\hline
378 %
379 %Nr & 5 \\\hline
380 %Title & 5 valid requests with 1byte payload sent out of order. \\\hline
381 %Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline
382 %Expected output & All requests sent up to and including
383 %the swapped packet with the lowest sequence number, the remaining packets are dropped. \\\hline
384 %\multirow{2}{*}{Course of action}
385 %& 1. Use the steps listed above in order to start the SUT. \\
386 %& 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline
387 %Valid trace & Verify that the script prints 'Success'. \\\hline
388 %\hline
389 %
390 %Nr & 6 \\\hline
391 %Title & Request with corrupted source port. \\\hline
392 %Input & Generated packets with 1byte payload, in these packets the source port number is increased by one. \\\hline
393 %Expected output & - \\\hline
394 %\multirow{2}{*}{Course of action}
395 %& 1. Use the steps listed above in order to start the SUT. \\
396 %& 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline
397 %Valid trace & Verify that the script prints 'Success'. \\\hline
398 %\hline
399 %
400 %
401 %Nr & 6 \\\hline
402 %Title & Request with corrupted destination port. \\\hline
403 %Input & Generated packets with 1byte payload, in these packets the destination port number is increased by one. \\\hline
404 %Expected output & - \\\hline
405 %\multirow{2}{*}{Course of action}
406 %& 1. Use the steps listed above in order to start the SUT. \\
407 %& 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline
408 %Valid trace & Verify that the script prints 'Success'. \\\hline
409 %\hline
410 %
411 %\end{longtable}
412
413 %\begin{tabularx}{\linewidth}{| l | X|}
414 %\hline
415 %Nr & 1 \\\hline
416 %Title & Single valid request. \\\hline
417 %Input & Pcap file with prerecorded valid packets. \\\hline
418 %Expected output & Pcap file with valid response to request. \\\hline
419 %Course of action & \begin{enumerate}
420 % \item Execute \emph{./scripts/tests/case1-single-valid.sh}
421 % \item Load \emph{output/case1.pcap} with ...
422 %\end{enumerate} \\\hline
423 %Valid trace & \begin{enumerate}
424 % \item \textbf{Hier packets benoemen?}
425 %\end{enumerate} \\\hline
426 %\end{tabularx}
427 %
428 %\begin{tabularx}{\linewidth}{| l | X|}
429 % \hline
430 % Nr & 2 \\\hline
431 %Title & Single request with corrupted checksum. \\\hline
432 % Input & Pcap file used as \emph{test-case 1} input. \\\hline
433 % Expected output & No response from SUT, logs with rejected packets. \\\hline
434 % Course of action & \begin{enumerate}
435 % \item Load input pcap file into ....
436 % \item Corrupt checksum of loaded packets.
437 % \item Save resulting packets as pcap file.
438 % \item Load new pcap file into ...
439 % \item Replay new pcap file.
440 % \item Record SUT response using...
441 % \item Extract log with rejected packets.
442 % \item Save recorded packets as a pcap file.
443 % \item Analyze packets in resulting file.
444 % \end{enumerate} \\\hline
445 % Valid trace & \begin{enumerate}
446 % \item \textbf{Aangeven welke packets corrupted zijn?}
447 % \end{enumerate} \\\hline
448 %\end{tabularx}
449 %\end{table}