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