red ipv ref gefixed.
[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 To cover the TCP specification as complete as possible while still maintaining
89 a feasible test suite the tests are divided into equivalence partitions. Below
90 these partitions are given.
91
92 \begin{enumerate}
93 \item \emph{Number of segments} in request~\footnote{A request is
94 considered establishing a connection (handshake) and a number of
95 payload segments}
96 \begin{enumerate}
97 \item 0 payload segments
98 \item 1 payload segments
99 \item n=small payload segments (1 byte)
100 \item n=big payload segments (65495 bytes)
101 \end{enumerate}
102 \item \emph{source port}
103 \begin{enumerate}
104 \item Correct
105 \item Incorrect
106 \end{enumerate}
107 \item \emph{destination port}
108 \begin{enumerate}
109 \item Correct
110 \item Incorrect
111 \end{enumerate}
112 \item Bit errors in \emph{payload}
113 \begin{enumerate}
114 \item Correct payload
115 \item Payload with bit flips that do not show in checksum
116 \item Payload with bit flips that do show in checksum
117 \end{enumerate}
118 \item \emph{checksum}
119 \begin{enumerate}
120 \item Correct
121 \item Incorrect
122 \end{enumerate}
123 \item \emph{Segment order}
124 \begin{enumerate}
125 \item Correct
126 \item Out of order
127 \item Missing Segments
128 \end{enumerate}
129 \end{enumerate}
130
131 These partitions were chosen since they correspond to key parts of the TCP
132 specification. A single request consists of a number of packets that sent a
133 to the \emph{echo-server} and back. The TCP specification state that such a
134 transaction requires the following messages.
135
136 \begin{center}
137 Script $-$ SYN $A$ $\rightarrow$ SUT \\
138 Script $\leftarrow$ SYN-ACK $(A+1)$ $B$ $-$ SUT \\
139 Script $-$ ACK $(A+1)$ $(B+1)$ $\rightarrow$ SUT \\
140 Script $-$ ACK-PUSH $(A+1)$ $(B+2)$ \emph{msg} $\rightarrow$ SUT \\
141 Script $\leftarrow$ ACK $(A+2+msg_{length})$ $(B+3)$ $-$ SUT \\
142 Script $\leftarrow$ ACK-PUSH $(A+2+msg_{length})$ $(B+3)$ \emph{msg} $-$ SUT
143 \end{center}
144
145 %
146 % één na laatste packket, moet dit B+3 of B+2 zijn?
147 %
148
149 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
150 source or destination port set to an incorrect value should not be regarded
151 as segments belonging to the connection by the SUT.
152
153 TCP uses a \emph{checksum} to catch any error introduced in headers, when this
154 checksum does not match the actual computed checksum the SUT should
155 disregard the received segment.
156
157 The TCP checksum is also an inherently weak one, as it is simply the
158 bitwise negation of the addition, in ones complement arithmetic,
159 of all 16 bit words in the header and data of the segment (excluding the
160 checksum itself). Therefore any \emph{bit error} where the ones complement value
161 of one word
162 increases by one, and the value of another decreases by one, is undetected.
163 The SUT should exhibit the same behavior and accept packets where these type
164 of bit errors occur.
165
166 TCP guarantees that segments are delivered \emph{in order}
167 ,even when they are received
168 out of order and that missing segments are resend. The SUT should
169 exhibit the same behavior. If segments are received out of order it should
170 either reassemble them when the missing packet has arrived or request them to
171 be resend when the Missing segments should be re-requested (by ACK-ing
172 the correct sequence number).
173
174 \bigskip
175
176 Partitions 2 to 6 are tested using pairwise testing to keep the number of test
177 cases feasible. The pairs are then all *except some where it does not make sense
178 to do so) tested with the different request sizes of partition 1.
179
180 This is expressed in Table~\ref{tbl:testpairs}. In this table the first five
181 columns represent the different options for the partitions 2 to 6 of the above
182 enumeration. The last four columns are the different number segments as
183 described in the partition 1 of the above enumeration. These cells identify
184 individual test cases by a number. An \xmark in the cell indicates that this
185 test case can not be created as it is not possible with that number of segments
186 (eg. sending segments out of order when the number of segments is 1).
187
188 \setcounter{TCC}{1}
189 \begin{table}[H]
190 \centering
191 \begin{tabular}{|l|l|l|l|l|l||l|l|l|l|}
192 \hline
193 & \multicolumn{9}{c|}{\textbf{Partition}}\\
194 \hline
195 & 4 & 5 & 3 & 6 & 2 & 1a & 1b & 1c & 1d\\
196 \hline\hline
197 \multirow{9}{*}{Instance}
198 & a & a & a & a & a & \doTCC & \doTCC & \doTCC & \doTCC\\
199 & a & b & b & c & b & \xmark & \xmark & \doTCC & \doTCC\\
200 & c & a & b & a & b & \xmark & \xmark & \doTCC & \doTCC\\
201 & c & b & a & c & a & \xmark & \xmark & \doTCC & \doTCC\\
202 & b & a & b & c & a & \xmark & \xmark & \doTCC & \doTCC\\
203 & b & b & a & b & b & \xmark & \xmark & \doTCC & \doTCC\\
204 & c & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\
205 & b & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\
206 & a & b & b & b & a & \xmark & \xmark & \doTCC & \doTCC\\
207 \hline
208 \end{tabular}
209 \caption{Combinations of test cases}
210 \label{tbl:testpairs}
211 \end{table}
212
213 \subsection{Quality, completeness and coverage of tests}
214
215 The network packets used in testing are constructed from prerecorded, known to
216 be correct, network traffic. These packets are then modified with well used and
217 field tested tools. Due to this the chance of errors in the test cases is quite
218 low. However, no formal proof of correctness of the test cases is present, this
219 means that any defects found might not be the result of a fault in the SUT.
220 Therefore detected defects should only indicate there is a high chance that
221 there is a fault in the SUT and can not result directly in the conclusion that
222 there actually is one.
223
224 \bigskip
225
226 Due to the nature of black-box testing coverage of the code in the
227 implementation of the SUT is unknown. However completeness of the tests over
228 the specification of the SUT can be assessed.
229
230 \bigskip
231
232 Due to the clear and exhaustive specification of TCP the completeness of the
233 test suite can be clearly assessed.
234
235 As always, $100\%$ completeness is not feasible, therefore test cases are
236 carefully selected to cover the most interesting parts of the TCP specification
237 to ensure a complete but feasible test suite.
238
239 To further increase the coverage of the test suites tests are randomized. The
240 tests which test the handling of \emph{bit errors}, changes in the \emph{packet
241 order} and \emph{dropped packets} randomize where they introduce an error. The
242 test suite runs these tests multiple times to increase the likelihood that they
243 discover a fault which is only present when an error occurs in a certain
244 position.
245
246 To further decrease the number of tests needed test cases are divided into
247 equivalence partitions and the combination of cases as described in
248 Table~\ref{tbl:testpairs} ensures that all partitions are
249 covered and the number of individual tests is still feasible.
250
251
252 %
253 % wat ik ook probeer ik krijg de eerste collum
254 % zijn tekst niet verticaal gecentered
255 %
256
257
258 \subsection{Test suite}
259
260 Before executing the test suite the test environment has to be initialized.
261
262 \begin{enumerate}
263 \item Boot the vm using VirtualBox.
264 \item Setup iptables by executing \texttt{\# code/iptables.sh}
265 \item Navigate to the working directory by running
266 \texttt{\$ cd /home/student/tt2015}
267 \item Start the echo server by running
268 \texttt{\# cd code/server \&\& Java Main}
269 \end{enumerate}
270
271 \subsubsection{Preflight checks}
272 The we do the preflight checks as defined in Table~\ref{tbl:preflight}.
273
274 \subsubsection{Test Cases}
275 If the SUT passes the preflight checks the actual test cases can be executed.
276 Table~\ref{tbl:testcases} shows the expected results of each of the test cases
277 described in Table~\ref{tbl:testpairs}.
278
279 \setcounter{TCC}{1}
280 \begin{table}[H]
281 \centering
282 \begin{tabular}{|l|p{.7\linewidth}|}
283 \hline
284 Test number & Expected results\\
285 \hline\hline
286 \doTCC & An ACK\# of the send sequence number + 1.\\ \hline
287 \doTCC & An ACK\# of the sequence number of the last send segment + the
288 size of the payload of that segment.\\ \hline
289 \doTCC & An ACK\# of the sequence number of the last send segment + the
290 size of the payload of that segment.\\ \hline
291 \doTCC & An ACK\# of the sequence number of the last send segment + the
292 size of the payload of that segment.\\ \hline
293 \doTCC & The ACK\# for the SEQ\# of the first segments which is
294 corrupted is received for each consecutive segment send.\\
295 $\vdots$ & \\
296 \setcounter{TCC}{14}
297 \doTCC & The ACK\# for the SEQ\# of the first segments which is
298 corrupted is received for each consecutive segment send.\\ \hline
299 \doTCC & The segment is not attributed to the current connection
300 and therefore no ACK\# is received. \\ \hline
301 \doTCC & The ACK\# for the SEQ\# of the first segments which is
302 corrupted is received for each consecutive segment send.\\ \hline
303 \doTCC & The ACK\# for the SEQ\# of the first segments which is
304 corrupted is received for each consecutive segment send.\\ \hline
305 \doTCC & The segment is not attributed to the current connection
306 and therefore no ACK\# is received. \\ \hline
307 \doTCC & The ACK\# for the SEQ\# of the first segments which is
308 corrupted is received for each consecutive segment send.\\ \hline
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 ACK\# for the SEQ\# of the first segments which is
312 corrupted is received for each consecutive segment send.\\ \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 \end{tabular}
316 \caption{Expected results of test cases}
317 \label{tbl:testcases}
318 \end{table}
319
320 % Bij Ramons afwezigheid
321 % Paul Vitero (linkerkant lange gang)
322 % verdieping Mercator
323
324
325 %\begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|}
326 %\hline
327 %Nr & 1 \\\hline
328 %Title & Single valid request with 1byte payload. \\\hline
329 %Input & Generated packets. \\\hline
330 %Expected output & Packets echoed back by Echo-Server. \\\hline
331 %\multirow{2}{*}{Course of action}
332 %& 1. Use the steps listed above in order to start the SUT. \\
333 %& 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline
334 %Valid trace & Verify that the script prints 'Success'. \\\hline
335 %\hline
336 %
337 %Nr & 2 \\\hline
338 %Title & Single valid request with 65495bytes payload. \\\hline
339 %Input & Generated packets. \\\hline
340 %Expected output & Packets echoed back by Echo-Server. \\\hline
341 %\multirow{2}{*}{Course of action}
342 %& 1. Use the steps listed above in order to start the SUT. \\
343 %& 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline
344 %Valid trace & Verify that the script prints 'Success'. \\\hline
345 %\hline
346 %
347 %Nr & 3 \\\hline
348 %Title & 5 valid requests with 1byte payload. \\\hline
349 %Input & Generated packets. \\\hline
350 %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline
351 %\multirow{2}{*}{Course of action}
352 %& 1. Use the steps listed above in order to start the SUT. \\
353 %& 2. Execute the script by running \texttt{\# code/client/tests/3.py} \\\hline
354 %Valid trace & Verify that the script prints 'Success'. \\\hline
355 %\hline
356 %
357 %Nr & 4 \\\hline
358 %Title & 5 valid requests with 65495bytes payload. \\\hline
359 %Input & Generated packets with 65495bytes payload. \\\hline
360 %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline
361 %\multirow{2}{*}{Course of action}
362 %& 1. Use the steps listed above in order to start the SUT. \\
363 %& 2. Execute the script by running \texttt{\# code/client/tests/4.py} \\\hline
364 %Valid trace & Verify that the script prints 'Success'. \\\hline
365 %\hline
366 %
367 %Nr & 5 \\\hline
368 %Title & 5 valid requests with 1byte payload sent out of order. \\\hline
369 %Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline
370 %Expected output & All requests sent up to and including
371 %the swapped packet with the lowest sequence number, the remaining packets are dropped. \\\hline
372 %\multirow{2}{*}{Course of action}
373 %& 1. Use the steps listed above in order to start the SUT. \\
374 %& 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline
375 %Valid trace & Verify that the script prints 'Success'. \\\hline
376 %\hline
377 %
378 %Nr & 6 \\\hline
379 %Title & Request with corrupted source port. \\\hline
380 %Input & Generated packets with 1byte payload, in these packets the source port number is increased by one. \\\hline
381 %Expected output & - \\\hline
382 %\multirow{2}{*}{Course of action}
383 %& 1. Use the steps listed above in order to start the SUT. \\
384 %& 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline
385 %Valid trace & Verify that the script prints 'Success'. \\\hline
386 %\hline
387 %
388 %
389 %Nr & 6 \\\hline
390 %Title & Request with corrupted destination port. \\\hline
391 %Input & Generated packets with 1byte payload, in these packets the destination port number is increased by one. \\\hline
392 %Expected output & - \\\hline
393 %\multirow{2}{*}{Course of action}
394 %& 1. Use the steps listed above in order to start the SUT. \\
395 %& 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline
396 %Valid trace & Verify that the script prints 'Success'. \\\hline
397 %\hline
398 %
399 %\end{longtable}
400
401 %\begin{tabularx}{\linewidth}{| l | X|}
402 %\hline
403 %Nr & 1 \\\hline
404 %Title & Single valid request. \\\hline
405 %Input & Pcap file with prerecorded valid packets. \\\hline
406 %Expected output & Pcap file with valid response to request. \\\hline
407 %Course of action & \begin{enumerate}
408 % \item Execute \emph{./scripts/tests/case1-single-valid.sh}
409 % \item Load \emph{output/case1.pcap} with ...
410 %\end{enumerate} \\\hline
411 %Valid trace & \begin{enumerate}
412 % \item \textbf{Hier packets benoemen?}
413 %\end{enumerate} \\\hline
414 %\end{tabularx}
415 %
416 %\begin{tabularx}{\linewidth}{| l | X|}
417 % \hline
418 % Nr & 2 \\\hline
419 %Title & Single request with corrupted checksum. \\\hline
420 % Input & Pcap file used as \emph{test-case 1} input. \\\hline
421 % Expected output & No response from SUT, logs with rejected packets. \\\hline
422 % Course of action & \begin{enumerate}
423 % \item Load input pcap file into ....
424 % \item Corrupt checksum of loaded packets.
425 % \item Save resulting packets as pcap file.
426 % \item Load new pcap file into ...
427 % \item Replay new pcap file.
428 % \item Record SUT response using...
429 % \item Extract log with rejected packets.
430 % \item Save recorded packets as a pcap file.
431 % \item Analyze packets in resulting file.
432 % \end{enumerate} \\\hline
433 % Valid trace & \begin{enumerate}
434 % \item \textbf{Aangeven welke packets corrupted zijn?}
435 % \end{enumerate} \\\hline
436 %\end{tabularx}
437 %\end{table}