From 29f7409053932da5c991fa7adfc1467e26b6d7bd Mon Sep 17 00:00:00 2001 From: Dion Date: Wed, 11 Nov 2015 17:26:46 +0100 Subject: [PATCH 01/16] eindversie dag des niet werkende scapy --- a2/1cases.tex | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/a2/1cases.tex b/a2/1cases.tex index 79da29d..78ae168 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -291,6 +291,28 @@ Before every test case use the following steps to initialize the testing environ & 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline + + Nr & 6 \\\hline + Title & Request with corrupted source port. \\\hline + Input & Generated packets with 1byte payload, in these packets the source port number is increased by one. \\\hline + Expected output & - \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + + Nr & 6 \\\hline + Title & Request with corrupted destination port. \\\hline + Input & Generated packets with 1byte payload, in these packets the destination port number is increased by one. \\\hline + Expected output & - \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + \end{longtable} %\begin{tabularx}{\linewidth}{| l | X|} -- 2.20.1 From f332d78e82a391ad322fca496065e3002553d606 Mon Sep 17 00:00:00 2001 From: pimjager Date: Wed, 11 Nov 2015 17:57:50 +0100 Subject: [PATCH 02/16] Add results table --- a2/1cases.tex | 189 ++++++++++++++++++++++++++++++++---------------- a2/preamble.tex | 3 + 2 files changed, 129 insertions(+), 63 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index 21048a1..d84752a 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -161,7 +161,7 @@ Partitions 2 to 6 are tested using pairwise testing to keep the number of test cases feasible. The pairs are then all *except some where it does not make sense to do so) tested with the different request sizes of partition 1. -This is expressed in Table~\ref{table:testpairs}. In this table the first five +This is expressed in Table~\ref{tbl:testpairs}. In this table the first five columns represent the different options for the partitions 2 to 6 of the above enumeration. The last four columns are the different number segments as described in the partition 1 of the above enumeration. These cells identify @@ -169,9 +169,7 @@ individual test cases by a number. An \xmark in the cell indicates that this test case can not be created as it is not possible with that number of segments (eg. sending segments out of order when the number of segments is 1). -\newcounter{TCC} \setcounter{TCC}{1} -\newcommand{\doTCC}{\theTCC \stepcounter{TCC}} \begin{table}[H] \centering \begin{tabular}{|l|l|l|l|l|l||l|l|l|l|} @@ -191,9 +189,9 @@ test case can not be created as it is not possible with that number of segments & b & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\ & a & b & b & b & a & \xmark & \xmark & \doTCC & \doTCC\\ \hline -\end{tabular} + \end{tabular} \caption{Combinations of test cases} -\label{table:testpairs} +\label{tbl:testpairs} \end{table} \subsection{Quality, completeness and coverage of tests} @@ -231,7 +229,7 @@ position. To further decrease the number of tests needed test cases are divided into equivalence partitions and the combination of cases as described in -Table~\ref{table:testpairs} ensures that all partitions are +Table~\ref{tbl:testpairs} ensures that all partitions are covered and the number of individual tests is still feasible. @@ -241,70 +239,135 @@ covered and the number of individual tests is still feasible. % -\subsection{Test cases} +\subsection{Test suite} -Before every test case use the following steps to initialize the testing environment. +Before executing the test suite the test environment has to be initialized. \begin{enumerate} \item Boot the vm using VirtualBox. \item Setup iptables by executing \texttt{\# code/iptables.sh} - \item Navigate to the working directory by running \texttt{\$ cd /home/student/tt2015} - \item Start the echo server by running \texttt{\# cd code/server \&\& java Main} + \item Navigate to the working directory by running + \texttt{\$ cd /home/student/tt2015} + \item Start the echo server by running + \texttt{\# cd code/server \&\& Java Main} \end{enumerate} -\begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|} - \hline - Nr & 1 \\\hline - Title & Single valid request with 1byte payload. \\\hline - Input & Generated packets. \\\hline - Expected output & Packets echoed back by Echo-Server. \\\hline - \multirow{2}{*}{Course of action} - & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline - Valid trace & Verify that the script prints 'Success'. \\\hline - \hline - - Nr & 2 \\\hline - Title & Single valid request with 65495bytes payload. \\\hline - Input & Generated packets. \\\hline - Expected output & Packets echoed back by Echo-Server. \\\hline - \multirow{2}{*}{Course of action} - & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline - Valid trace & Verify that the script prints 'Success'. \\\hline - \hline - - Nr & 3 \\\hline - Title & 5 valid requests with 1byte payload. \\\hline - Input & Generated packets. \\\hline - Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline - \multirow{2}{*}{Course of action} - & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/3.py} \\\hline - Valid trace & Verify that the script prints 'Success'. \\\hline - \hline - - Nr & 4 \\\hline - Title & 5 valid requests with 65495bytes payload. \\\hline - Input & Generated packets with 65495bytes payload. \\\hline - Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline - \multirow{2}{*}{Course of action} - & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/4.py} \\\hline - Valid trace & Verify that the script prints 'Success'. \\\hline - \hline - - Nr & 5 \\\hline - Title & 5 valid requests with 1byte payload sent out of order. \\\hline - Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline - Expected output & All requests sent up to and including - the swapped packet with the lowest sequence number, the remaining packets are dropped. \\\hline - \multirow{2}{*}{Course of action} - & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline - Valid trace & Verify that the script prints 'Success'. \\\hline - \hline -\end{longtable} +\subsubsection{Preflight checks} +The we do the preflight checks as defined in Table~\ref{tbl:preflight}. + +\subsubsection{Test Cases} +If the SUT passes the preflight checks the actual test cases can be executed. +Table~\ref{tbl:testcases} shows the expected results of each of the test cases +described in Table~\ref{table:testpairs}. + +\setcounter{TCC}{1} +\begin{table}[H] + \centering + \begin{tabular}{|l|p{.7\linewidth}|} + \hline + Test number & Expected results\\ + \hline\hline + \doTCC & An ACK\# of the send sequence number + 1.\\ \hline + \doTCC & An ACK\# of the sequence number of the last send segment + the + size of the payload of that segment.\\ \hline + \doTCC & An ACK\# of the sequence number of the last send segment + the + size of the payload of that segment.\\ \hline + \doTCC & An ACK\# of the sequence number of the last send segment + the + size of the payload of that segment.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ + $\vdots$ & \\ + \setcounter{TCC}{14} + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The segment is not attributed to the current connection + and therefore no ACK\# is received. \\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The segment is not attributed to the current connection + and therefore no ACK\# is received. \\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \hline + \end{tabular} +\caption{Expected results of test cases} +\label{table:preflightresults} +\end{table} + +% Bij Ramons aanwezigheid +% Paul Vitero (linkerkant lange gang) +% verdieping Mercator + +%Before every test case use the following steps to initialize the testing environment. +% +%\begin{enumerate} + %\item Boot the vm using VirtualBox. + %\item Setup iptables by executing \texttt{\# code/iptables.sh} + %\item Navigate to the working directory by running \texttt{\$ cd /home/student/tt2015} + %\item Start the echo server by running \texttt{\# cd code/server \&\& java Main} +%\end{enumerate} +% +%\begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|} + %\hline + %Nr & 1 \\\hline + %Title & Single valid request with 1byte payload. \\\hline + %Input & Generated packets. \\\hline + %Expected output & Packets echoed back by Echo-Server. \\\hline + %\multirow{2}{*}{Course of action} + %& 1. Use the steps listed above in order to start the SUT. \\ + %& 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline + %Valid trace & Verify that the script prints 'Success'. \\\hline + %\hline +% + %Nr & 2 \\\hline + %Title & Single valid request with 65495bytes payload. \\\hline + %Input & Generated packets. \\\hline + %Expected output & Packets echoed back by Echo-Server. \\\hline + %\multirow{2}{*}{Course of action} + %& 1. Use the steps listed above in order to start the SUT. \\ + %& 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline + %Valid trace & Verify that the script prints 'Success'. \\\hline + %\hline +% + %Nr & 3 \\\hline + %Title & 5 valid requests with 1byte payload. \\\hline + %Input & Generated packets. \\\hline + %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline + %\multirow{2}{*}{Course of action} + %& 1. Use the steps listed above in order to start the SUT. \\ + %& 2. Execute the script by running \texttt{\# code/client/tests/3.py} \\\hline + %Valid trace & Verify that the script prints 'Success'. \\\hline + %\hline +% + %Nr & 4 \\\hline + %Title & 5 valid requests with 65495bytes payload. \\\hline + %Input & Generated packets with 65495bytes payload. \\\hline + %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline + %\multirow{2}{*}{Course of action} + %& 1. Use the steps listed above in order to start the SUT. \\ + %& 2. Execute the script by running \texttt{\# code/client/tests/4.py} \\\hline + %Valid trace & Verify that the script prints 'Success'. \\\hline + %\hline +% + %Nr & 5 \\\hline + %Title & 5 valid requests with 1byte payload sent out of order. \\\hline + %Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline + %Expected output & All requests sent up to and including + %the swapped packet with the lowest sequence number, the remaining packets are dropped. \\\hline + %\multirow{2}{*}{Course of action} + %& 1. Use the steps listed above in order to start the SUT. \\ + %& 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline + %Valid trace & Verify that the script prints 'Success'. \\\hline + %\hline +%\end{longtable} %\begin{tabularx}{\linewidth}{| l | X|} %\hline diff --git a/a2/preamble.tex b/a2/preamble.tex index 4afe3a3..aa5dacd 100644 --- a/a2/preamble.tex +++ b/a2/preamble.tex @@ -12,6 +12,9 @@ \usepackage{amsfonts} \newcommand{\xmark}{\texttt{\textbf{x}}} +\newcounter{TCC} +\newcommand{\doTCC}{\theTCC \stepcounter{TCC}} + \lstset{% breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace breaklines=true, % sets automatic line breaking -- 2.20.1 From 13c34f3024b2d53d099413a54543db407bcf859e Mon Sep 17 00:00:00 2001 From: mart Date: Fri, 13 Nov 2015 20:09:17 +0100 Subject: [PATCH 03/16] nu wel werkende code nadat het kapot was gemaakt --- a2/code/client/gen.py | 1 + 1 file changed, 1 insertion(+) diff --git a/a2/code/client/gen.py b/a2/code/client/gen.py index 4dc28d1..1e3bc20 100755 --- a/a2/code/client/gen.py +++ b/a2/code/client/gen.py @@ -48,6 +48,7 @@ def test(corruptDestinationPort, corruptSourcePort, numpackets, payloadsize, out else: sender.senderPort = oldSourcePort sender.sendInput("A", seq, sender.lastSeqReceived + 1, None) # send some data + sender.sendInput("PA", seq, sender.lastSeqReceived + 1, m) # send some data print 'response: ', sender.sendInput("FA", ownSeqnr, sender.lastSeqReceived + 1) # close connection (the echo also closes) print 'response: ', sender.sendInput("RP", ownSeqnr+1, 0) # reset connection -- 2.20.1 From c1bee8c922255c3df4a064ecce42bae489ccadd0 Mon Sep 17 00:00:00 2001 From: pimjager Date: Sat, 14 Nov 2015 14:35:44 +0100 Subject: [PATCH 04/16] Fixed refrences --- a2/1cases.tex | 8 +++----- a2/2results.tex | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index ce1031d..4bd81ff 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -82,8 +82,7 @@ results to asses whether or not the SUT has passed the test. The implementation of the SUT is tested using black box testing techniques. A series of tests asses the correctness of the implementation with regards to the -TCP specification. These tests are specified in Table~\textbf{referentie naar -tests-tabel}. The test cases aim to cover the most interesting parts of the TCP +TCP specification. These tests are specified in Table~\ref{tbl:testpairs}. The test cases aim to cover the most interesting parts of the TCP specification. To cover the TCP specification as complete as possible while still maintaining @@ -260,7 +259,7 @@ The we do the preflight checks as defined in Table~\ref{tbl:preflight}. \subsubsection{Test Cases} If the SUT passes the preflight checks the actual test cases can be executed. Table~\ref{tbl:testcases} shows the expected results of each of the test cases -described in Table~\ref{table:testpairs}. +described in Table~\ref{tbl:testpairs}. \setcounter{TCC}{1} \begin{table}[H] @@ -298,10 +297,9 @@ described in Table~\ref{table:testpairs}. corrupted is received for each consecutive segment send.\\ \hline \doTCC & The ACK\# for the SEQ\# of the first segments which is corrupted is received for each consecutive segment send.\\ \hline - \hline \end{tabular} \caption{Expected results of test cases} -\label{table:preflightresults} +\label{tbl:testcases} \end{table} % Bij Ramons afwezigheid diff --git a/a2/2results.tex b/a2/2results.tex index 7c1bca0..871ab78 100644 --- a/a2/2results.tex +++ b/a2/2results.tex @@ -1,5 +1,10 @@ \subsection{Preflight checklist} +Execution of the preflight checklist of Table~\red{tbl:preflight} + + +\subsection{Test cases} + % %\textbf{TODO: DEZE TABEL WEL UPDATEN!!} % -- 2.20.1 From 19ce2bec8e6684693c31620b26ebf1cd6366f7b0 Mon Sep 17 00:00:00 2001 From: charlie Date: Sat, 14 Nov 2015 14:45:04 +0100 Subject: [PATCH 05/16] request defined --- a2/1cases.tex | 17 ++++++++++++++++- a2/code/client/gen.py | 0 a2/code/client/helloworld.py | 0 a2/code/setup/iptables.sh | 0 4 files changed, 16 insertions(+), 1 deletion(-) mode change 100755 => 100644 a2/code/client/gen.py mode change 100755 => 100644 a2/code/client/helloworld.py mode change 100755 => 100644 a2/code/setup/iptables.sh diff --git a/a2/1cases.tex b/a2/1cases.tex index bcea37f..7b90350 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -130,7 +130,22 @@ these partitions are given. \end{enumerate} These partitions were chosen since they correspond to key parts of the TCP -specification. +specification. A single request consists of a number of packets that sent a +to the \emph{echo-server} and back. The TCP specification state that such a +transaction requires the following messages. + +\begin{center} + Script $-$ SYN $A$ $\rightarrow$ SUT \\ + Script $\leftarrow$ SYN-ACK $(A+1)$ $B$ $-$ SUT \\ + Script $-$ ACK $(A+1)$ $(B+1)$ $\rightarrow$ SUT \\ + Script $-$ ACK-PUSH $(A+1)$ $(B+2)$ \emph{msg} $\rightarrow$ SUT \\ + Script $\leftarrow$ ACK $(A+2+msg_{length})$ $(B+3)$ $-$ SUT \\ + Script $\leftarrow$ ACK-PUSH $(A+2+msg_{length})$ $(B+3)$ \emph{msg} $-$ SUT +\end{center} + +% +% één na laatste packket, moet dit B+3 of B+2 zijn? +% 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 source or destination port set to an incorrect value should not be regarded diff --git a/a2/code/client/gen.py b/a2/code/client/gen.py old mode 100755 new mode 100644 diff --git a/a2/code/client/helloworld.py b/a2/code/client/helloworld.py old mode 100755 new mode 100644 diff --git a/a2/code/setup/iptables.sh b/a2/code/setup/iptables.sh old mode 100755 new mode 100644 -- 2.20.1 From f0657da1ab399a97b0cd9255f5c6688fcd6128bd Mon Sep 17 00:00:00 2001 From: charlie Date: Sat, 14 Nov 2015 14:49:24 +0100 Subject: [PATCH 06/16] red ipv ref gefixed. --- a2/2results.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/a2/2results.tex b/a2/2results.tex index 871ab78..6eff9db 100644 --- a/a2/2results.tex +++ b/a2/2results.tex @@ -1,6 +1,6 @@ \subsection{Preflight checklist} -Execution of the preflight checklist of Table~\red{tbl:preflight} +Execution of the preflight checklist of Table~\ref{tbl:preflight} \subsection{Test cases} -- 2.20.1 From 329237bfbd3b357103d6f8c4e15f40c7b8da7dd0 Mon Sep 17 00:00:00 2001 From: pimjager Date: Sat, 14 Nov 2015 14:51:30 +0100 Subject: [PATCH 07/16] Framework voor results toegevoegd --- a2/2results.tex | 65 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/a2/2results.tex b/a2/2results.tex index 871ab78..4e685ed 100644 --- a/a2/2results.tex +++ b/a2/2results.tex @@ -1,9 +1,72 @@ \subsection{Preflight checklist} -Execution of the preflight checklist of Table~\red{tbl:preflight} +Execution of the preflight checklist of Table~\ref{tbl:preflight} yields the +following results: +\begin{table}[H] + \centering + \begin{tabular}{|l|l|} + \hline + Check \# & result \\ \hline \hline + 1 & RESULT\\ \hline + 2 & RESULT\\ \hline + 3 & RESULT\\ \hline + 4 & RESULT\\ \hline + 5 & RESULT\\ \hline + \end{tabular} +\caption{Results of the preflight checks} +\label{tbl:preflightresults} +\end{table} \subsection{Test cases} +Comparing the results of the execution of the test cases of +Table~\ref{tbl:testpairs} with the expected results of those test cases specified in +Table~\ref{tbl:testcases} yields the following results: + +\setcounter{TCC}{1} +\begin{table}[H] + \centering + \begin{tabular}{|l|l|} + \hline + Test case \# & result \\ \hline \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \doTCC & RESULT\\ \hline + \end{tabular} +\caption{Results of the test cases} +\label{tbl:testcasesresults} +\end{table} + +\subsection{Result} +To pass the test the SUT has to pass all the specified test cases ( +Table~\ref{tbl:tpreflight} and Table~\ref{tbl:testpairs}). As can be seen in +Table~\ref{tbl:preflightresults} and Table~\ref{tbl:testcasesresults} this is +%not %remove first % in case of any failure +the case. Therefore the SUT has PASSED/FAILED this test. +%This failure is due to the failure of the test case(s) 1,2,3,n as specified +%where the SUT failed to behave in the expected way by... %behavior dat SUT wel +%%liet zien % %\textbf{TODO: DEZE TABEL WEL UPDATEN!!} -- 2.20.1 From db1fbfe4d6cc82426a0b96f51baaeddfafa67ed5 Mon Sep 17 00:00:00 2001 From: pimjager Date: Sat, 14 Nov 2015 16:47:38 +0100 Subject: [PATCH 08/16] Add description of what is tested --- a2/1cases.tex | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index d339dfa..14900c9 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -85,6 +85,16 @@ series of tests asses the correctness of the implementation with regards to the TCP specification. These tests are specified in Table~\ref{tbl:testpairs}. The test cases aim to cover the most interesting parts of the TCP specification. +In this test suite the behavior of the outwards (network) interface of the SUT +is assessed. This is, the behavior of the SUT as +observed by another system on the network trying to communicate with (a system +running on the same host as the SUT using) the SUT. This is achieved by running +man +echo-server on the system which runs the SUT (a virtual machine) which +echos back all messages received to the sender. The test scripts will send +packets to the echo-server and then checks the received +response to asses whether or not the SUT is preforming as expected. + To cover the TCP specification as complete as possible while still maintaining a feasible test suite the tests are divided into equivalence partitions. Below these partitions are given. @@ -129,18 +139,7 @@ these partitions are given. \end{enumerate} These partitions were chosen since they correspond to key parts of the TCP -specification. A single request consists of a number of packets that sent a -to the \emph{echo-server} and back. The TCP specification state that such a -transaction requires the following messages. - -\begin{center} - Script $-$ SYN $A$ $\rightarrow$ SUT \\ - Script $\leftarrow$ SYN-ACK $(A+1)$ $B$ $-$ SUT \\ - Script $-$ ACK $(A+1)$ $(B+1)$ $\rightarrow$ SUT \\ - Script $-$ ACK-PUSH $(A+1)$ $(B+2)$ \emph{msg} $\rightarrow$ SUT \\ - Script $\leftarrow$ ACK $(A+2+msg_{length})$ $(B+3)$ $-$ SUT \\ - Script $\leftarrow$ ACK-PUSH $(A+2+msg_{length})$ $(B+3)$ \emph{msg} $-$ SUT -\end{center} +specification. % % één na laatste packket, moet dit B+3 of B+2 zijn? @@ -164,13 +163,26 @@ The SUT should exhibit the same behavior and accept packets where these type of bit errors occur. TCP guarantees that segments are delivered \emph{in order} -,even when they are received +, even when they are received out of order and that missing segments are resend. The SUT should exhibit the same behavior. If segments are received out of order it should either reassemble them when the missing packet has arrived or request them to be resend when the Missing segments should be re-requested (by ACK-ing the correct sequence number). +A single request consists of a number of packets that sent a +to the \emph{echo-server} and back. The TCP specification state that such a +transaction requires the following messages. + +\begin{center} + Script $-$ SYN $A$ $\rightarrow$ SUT \\ + Script $\leftarrow$ SYN-ACK $(A+1)$ $B$ $-$ SUT \\ + Script $-$ ACK $(A+1)$ $(B+1)$ $\rightarrow$ SUT \\ + Script $-$ ACK-PUSH $(A+1)$ $(B+2)$ \emph{msg} $\rightarrow$ SUT \\ + Script $\leftarrow$ ACK $(A+2+msg_{length})$ $(B+3)$ $-$ SUT \\ + Script $\leftarrow$ ACK-PUSH $(A+2+msg_{length})$ $(B+3)$ \emph{msg} $-$ SUT +\end{center} + \bigskip Partitions 2 to 6 are tested using pairwise testing to keep the number of test -- 2.20.1 From 86989d796ff012fb0a8b803fe46758b202010194 Mon Sep 17 00:00:00 2001 From: charlie Date: Sat, 14 Nov 2015 20:47:32 +0100 Subject: [PATCH 09/16] Expected result en test-case table matchen nu. 11 test-cases totaal nu. Verhaal over transactie iets uitgebreid. --- a2/1cases.tex | 243 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 147 insertions(+), 96 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index 14900c9..b785956 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -170,18 +170,27 @@ either reassemble them when the missing packet has arrived or request them to be resend when the Missing segments should be re-requested (by ACK-ing the correct sequence number). -A single request consists of a number of packets that sent a -to the \emph{echo-server} and back. The TCP specification state that such a +A single request consists of a number of packets that are sent +to the \emph{echo-server} and back. The TCP specification states that such a transaction requires the following messages. -\begin{center} +\begin{flushleft} Script $-$ SYN $A$ $\rightarrow$ SUT \\ Script $\leftarrow$ SYN-ACK $(A+1)$ $B$ $-$ SUT \\ Script $-$ ACK $(A+1)$ $(B+1)$ $\rightarrow$ SUT \\ Script $-$ ACK-PUSH $(A+1)$ $(B+2)$ \emph{msg} $\rightarrow$ SUT \\ Script $\leftarrow$ ACK $(A+2+msg_{length})$ $(B+3)$ $-$ SUT \\ Script $\leftarrow$ ACK-PUSH $(A+2+msg_{length})$ $(B+3)$ \emph{msg} $-$ SUT -\end{center} +\end{flushleft} + +% +% RS ook? FIN? +% + +When the \emph{SUT} has received the ACK containing the message it's passed +trough to the \emph{echo-server}. The \emph{echo-server} will proceed by ordering +the \emph{SUT} to respond by sending the exact same message. When this happens +the \emph{SUT} has to construct the last packet in the transaction listed above. \bigskip @@ -302,28 +311,31 @@ described in Table~\ref{tbl:testpairs}. size of the payload of that segment.\\ \hline \doTCC & An ACK\# of the sequence number of the last send segment + the size of the payload of that segment.\\ \hline + \doTCC & An ACK\# of the sequence number of the swapped packet with the lowest sequence number. \\ \hline \doTCC & The ACK\# for the SEQ\# of the first segments which is corrupted is received for each consecutive segment send.\\ $\vdots$ & \\ - \setcounter{TCC}{14} - \doTCC & The ACK\# for the SEQ\# of the first segments which is - corrupted is received for each consecutive segment send.\\ \hline - \doTCC & The segment is not attributed to the current connection - and therefore no ACK\# is received. \\ \hline - \doTCC & The ACK\# for the SEQ\# of the first segments which is - corrupted is received for each consecutive segment send.\\ \hline - \doTCC & The ACK\# for the SEQ\# of the first segments which is - corrupted is received for each consecutive segment send.\\ \hline - \doTCC & The segment is not attributed to the current connection - and therefore no ACK\# is received. \\ \hline + \setcounter{TCC}{10} \doTCC & The ACK\# for the SEQ\# of the first segments which is corrupted is received for each consecutive segment send.\\ \hline - \doTCC & The ACK\# for the SEQ\# of the first segments which is - corrupted is received for each consecutive segment send.\\ \hline - \doTCC & The ACK\# for the SEQ\# of the first segments which is - corrupted is received for each consecutive segment send.\\ \hline - \doTCC & The ACK\# for the SEQ\# of the first segments which is - corrupted is received for each consecutive segment send.\\ \hline + \doTCC & An ACK\# of the sequence number of the last send segment + the + size of the payload of that segment.\\ \hline +% \doTCC & The segment is not attributed to the current connection +% and therefore no ACK\# is received. \\ \hline +% \doTCC & The ACK\# for the SEQ\# of the first segments which is +% corrupted is received for each consecutive segment send.\\ \hline +% \doTCC & The ACK\# for the SEQ\# of the first segments which is +% corrupted is received for each consecutive segment send.\\ \hline +% \doTCC & The segment is not attributed to the current connection +% and therefore no ACK\# is received. \\ \hline +% \doTCC & The ACK\# for the SEQ\# of the first segments which is +% corrupted is received for each consecutive segment send.\\ \hline +% \doTCC & The ACK\# for the SEQ\# of the first segments which is +% corrupted is received for each consecutive segment send.\\ \hline +% \doTCC & The ACK\# for the SEQ\# of the first segments which is +% corrupted is received for each consecutive segment send.\\ \hline +% \doTCC & The ACK\# for the SEQ\# of the first segments which is +% corrupted is received for each consecutive segment send.\\ \hline \end{tabular} \caption{Expected results of test cases} \label{tbl:testcases} @@ -334,81 +346,120 @@ described in Table~\ref{tbl:testpairs}. % verdieping Mercator -%\begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|} - %\hline - %Nr & 1 \\\hline - %Title & Single valid request with 1byte payload. \\\hline - %Input & Generated packets. \\\hline - %Expected output & Packets echoed back by Echo-Server. \\\hline - %\multirow{2}{*}{Course of action} - %& 1. Use the steps listed above in order to start the SUT. \\ - %& 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline - %Valid trace & Verify that the script prints 'Success'. \\\hline - %\hline -% - %Nr & 2 \\\hline - %Title & Single valid request with 65495bytes payload. \\\hline - %Input & Generated packets. \\\hline - %Expected output & Packets echoed back by Echo-Server. \\\hline - %\multirow{2}{*}{Course of action} - %& 1. Use the steps listed above in order to start the SUT. \\ - %& 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline - %Valid trace & Verify that the script prints 'Success'. \\\hline - %\hline -% - %Nr & 3 \\\hline - %Title & 5 valid requests with 1byte payload. \\\hline - %Input & Generated packets. \\\hline - %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline - %\multirow{2}{*}{Course of action} - %& 1. Use the steps listed above in order to start the SUT. \\ - %& 2. Execute the script by running \texttt{\# code/client/tests/3.py} \\\hline - %Valid trace & Verify that the script prints 'Success'. \\\hline - %\hline -% - %Nr & 4 \\\hline - %Title & 5 valid requests with 65495bytes payload. \\\hline - %Input & Generated packets with 65495bytes payload. \\\hline - %Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline - %\multirow{2}{*}{Course of action} - %& 1. Use the steps listed above in order to start the SUT. \\ - %& 2. Execute the script by running \texttt{\# code/client/tests/4.py} \\\hline - %Valid trace & Verify that the script prints 'Success'. \\\hline - %\hline -% - %Nr & 5 \\\hline - %Title & 5 valid requests with 1byte payload sent out of order. \\\hline - %Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline - %Expected output & All requests sent up to and including - %the swapped packet with the lowest sequence number, the remaining packets are dropped. \\\hline - %\multirow{2}{*}{Course of action} - %& 1. Use the steps listed above in order to start the SUT. \\ - %& 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline - %Valid trace & Verify that the script prints 'Success'. \\\hline - %\hline -% - %Nr & 6 \\\hline - %Title & Request with corrupted source port. \\\hline - %Input & Generated packets with 1byte payload, in these packets the source port number is increased by one. \\\hline - %Expected output & - \\\hline - %\multirow{2}{*}{Course of action} - %& 1. Use the steps listed above in order to start the SUT. \\ - %& 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline - %Valid trace & Verify that the script prints 'Success'. \\\hline - %\hline -% -% - %Nr & 6 \\\hline - %Title & Request with corrupted destination port. \\\hline - %Input & Generated packets with 1byte payload, in these packets the destination port number is increased by one. \\\hline - %Expected output & - \\\hline - %\multirow{2}{*}{Course of action} - %& 1. Use the steps listed above in order to start the SUT. \\ - %& 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline - %Valid trace & Verify that the script prints 'Success'. \\\hline - %\hline -% -%\end{longtable} +\begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|} + \hline + Nr & 1 \\\hline + Title & Single valid request with 1byte payload. \\\hline + Input & Generated packets. \\\hline + Expected output & Packets echoed back by Echo-Server. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 2 \\\hline + Title & Single valid request with 65495bytes payload. \\\hline + Input & Generated packets. \\\hline + Expected output & Packets echoed back by Echo-Server. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 3 \\\hline + Title & 5 valid requests with 1byte payload. \\\hline + Input & Generated packets. \\\hline + Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/3.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 4 \\\hline + Title & 5 valid requests with 65495bytes payload. \\\hline + Input & Generated packets with 65495bytes payload. \\\hline + Expected output & Packets echoed back by Echo-Server, in the same order as the client sent them. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/4.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 5 \\\hline + Title & 5 valid requests with 1byte payload sent out of order. \\\hline + Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline + Expected output & All requests sent up to and including + the swapped packet with the lowest sequence number, the remaining packets are ropped. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 6 \\\hline + Title & Request with corrupted source port. \\\hline + Input & Generated packets with 1byte payload, in these packets the source port Number is increased by one. \\\hline + 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 + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + + Nr & 7 \\\hline + Title & Request with corrupted destination port. \\\hline + Input & Generated packets with 1byte payload, in these packets the destination port number is increased by one. \\\hline + Expected output & The packets will never reach the Echo-server resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/7.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 8 \\\hline + Title & Request with corrupted source address. \\\hline + Input & Generated packets with 1byte payload, in these packets the source address is replaced with 255.255.255.255. \\\hline + Expected output & The Echo-server will receive packet and is unable to respond with a ACK resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/8.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 9 \\\hline + Title & Request with corrupted destination address. \\\hline + Input & Generated packets with 1byte payload, in these packets the destination address is replaced with 255.255.255.255. \\\hline + Expected output & The packets will never reach the Echo-server resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/9.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 10 \\\hline + Title & Request with corrupted payload detectable by checksum. \\\hline + Input & Generated packets with 1byte payload, in these packets one byte is increased by 1 after the checksum has been calculated. \\\hline + Expected output & The \emph{SUT} will drop packets before sending them resulting in a runtime error of the test script. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/10.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 11 \\\hline + Title & Request with corrupted payload undetectable by checksum. \\\hline + 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 + Expected output & Echo-server receives the corrupted segment. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/11.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + +\end{longtable} %\begin{tabularx}{\linewidth}{| l | X|} %\hline -- 2.20.1 From 4c4cdd5d71d9e6b8a010ac56ad3d3c6b54faaa87 Mon Sep 17 00:00:00 2001 From: charlie Date: Sun, 15 Nov 2015 17:00:59 +0100 Subject: [PATCH 10/16] push om beneden achter de pc F1 te kunnen kijken. --- a2/1cases.tex | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index b785956..28fa599 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -304,6 +304,7 @@ described in Table~\ref{tbl:testpairs}. \hline Test number & Expected results\\ \hline\hline + \doTCC & An ACK\# of the sequence number of the SYN packet + 1. \\ \hline \doTCC & An ACK\# of the send sequence number + 1.\\ \hline \doTCC & An ACK\# of the sequence number of the last send segment + the size of the payload of that segment.\\ \hline @@ -348,26 +349,37 @@ described in Table~\ref{tbl:testpairs}. \begin{longtable}{|p{.2\linewidth}|p{.8\linewidth}|} \hline + Nr & 1 \\\hline - Title & Single valid request with 1byte payload. \\\hline + Title & Connect to the \emph{echo-server} without sending a payload. \\\hline Input & Generated packets. \\\hline - Expected output & Packets echoed back by Echo-Server. \\\hline + Expected output & \emph{Echo-server} accepts the connection. \\\hline \multirow{2}{*}{Course of action} - & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline Nr & 2 \\\hline - Title & Single valid request with 65495bytes payload. \\\hline + Title & Single valid request with 1byte payload. \\\hline Input & Generated packets. \\\hline Expected output & Packets echoed back by Echo-Server. \\\hline \multirow{2}{*}{Course of action} - & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/1.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline +% Nr & 3 \\\hline +% Title & Single valid request with 65495bytes payload. \\\hline +% Input & Generated packets. \\\hline +% Expected output & Packets echoed back by Echo-Server. \\\hline +% \multirow{2}{*}{Course of action} +% & 1. Use the steps listed above in order to start the SUT. \\ +% & 2. Execute the script by running \texttt{\# code/client/tests/2.py} \\\hline +% Valid trace & Verify that the script prints 'Success'. \\\hline +% \hline + Nr & 3 \\\hline Title & 5 valid requests with 1byte payload. \\\hline Input & Generated packets. \\\hline @@ -389,7 +401,7 @@ described in Table~\ref{tbl:testpairs}. \hline Nr & 5 \\\hline - Title & 5 valid requests with 1byte payload sent out of order. \\\hline + Title & 5 valid requests with 1byte payload with corrupted source port, destination port and checksum. The second segment is omitted in order to simulate a packet drop on the client side. \\\hline Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline Expected output & All requests sent up to and including the swapped packet with the lowest sequence number, the remaining packets are ropped. \\\hline -- 2.20.1 From 131c22ec196a998e14902e8127216c7a09b63119 Mon Sep 17 00:00:00 2001 From: Charlie Gerhardus Date: Sun, 15 Nov 2015 18:33:15 +0100 Subject: [PATCH 11/16] tc 1 t/m 11 klopt nu. --- a2/1cases.tex | 79 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 8 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index 28fa599..e9ffe8f 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -220,7 +220,7 @@ test case can not be created as it is not possible with that number of segments & a & b & b & c & b & \xmark & \xmark & \doTCC & \doTCC\\ & c & a & b & a & b & \xmark & \xmark & \doTCC & \doTCC\\ & c & b & a & c & a & \xmark & \xmark & \doTCC & \doTCC\\ - & b & a & b & c & a & \xmark & \xmark & \doTCC & \doTCC\\ + & b & a & b & c & a & \xmark & \xmark & \xmark & \doTCC\\ & b & b & a & b & b & \xmark & \xmark & \doTCC & \doTCC\\ & c & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\ & b & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\ @@ -401,26 +401,89 @@ described in Table~\ref{tbl:testpairs}. \hline Nr & 5 \\\hline - Title & 5 valid requests with 1byte payload with corrupted source port, destination port and checksum. The second segment is omitted in order to simulate a packet drop on the client side. \\\hline + Title & 5 requests with 1byte payload with corrupted source port, destination port and checksum. The second segment is omitted in order to simulate a packet drop on the client side. \\\hline Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline - Expected output & All requests sent up to and including - the swapped packet with the lowest sequence number, the remaining packets are ropped. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ & 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline - + Nr & 6 \\\hline - Title & Request with corrupted source port. \\\hline - Input & Generated packets with 1byte payload, in these packets the source port Number is increased by one. \\\hline - 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 + Title & 5 requests with 65495byte payload with corrupted source port, destination port and checksum. The second segment is omitted in order to simulate a packet drop on the client side. \\\hline + Input & Generated packets with 65495byte payload, second generated packet is removed. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ & 2. Execute the script by running \texttt{\# code/client/tests/6.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline + %% HIER + + Nr & 7 \\\hline + Title & 5 requests with 1byte corrupted payload, corrupted source and destination port. \\\hline + Input & Generated packets with 1byte payload, in these packets the payload byte, source and destination ports are increased by one. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/7.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 8 \\\hline + Title & 5 requests with 65495byte corrupted payload, corrupted source and destination port. \\\hline + Input & Generated packets with 65495byte payload, in these packets one of the payload bytes, source and destination ports are increased by one. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/8.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + + Nr & 9 \\\hline + Title & 5 requests with 1byte corrupted payload, invalid checksum and the second packet is dropped. \\\hline + Input & Generated packets with 1byte payload, in these packets the payload byte and checksum are increased by one. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/9.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 10 \\\hline + Title & 5 requests with 65495byte corrupted payload, invalid checksum and the second packet is dropped. \\\hline + Input & Generated packets with 65495byte payload, in these packets one of the payload bytes and the checksum are increased by one. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/10.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + Nr & 11 \\\hline + Title & 5 requests with 65495byte corrupted payload that doesn't show up in checksum and corrupted destination port. The second packet is dropped. \\\hline + Input & Generated packets with 65495byte payload, in these packets one 16bit word in the payload is increased by 1 and another 16bit word is decreased by 1. The destination port is also increase by one and the second packet is removed. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/11.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline + + + + Nr & 6 \\\hline + Title & 5 requests with 1byte payload with corrupted source port, destination port and checksum. The second segment is omitted in order to simulate a packet drop on the client side. \\\hline + Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline Nr & 7 \\\hline Title & Request with corrupted destination port. \\\hline -- 2.20.1 From 60f999428fcc82cb4fc291daa2bd2db5bc279fe4 Mon Sep 17 00:00:00 2001 From: mart Date: Sun, 15 Nov 2015 18:35:38 +0100 Subject: [PATCH 12/16] generatie van testkazen erbij, alleen results nog --- .gitignore | 11 +------- a2/code/client/gen.py | 59 +++++++++++++++++++++++++++++---------- a2/code/setup/iptables.sh | 0 3 files changed, 46 insertions(+), 24 deletions(-) mode change 100644 => 100755 a2/code/setup/iptables.sh diff --git a/.gitignore b/.gitignore index ce15282..b828972 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,3 @@ -tt.fmt -tt.aux -tt.bbl -tt.blg -tt.log -tt.out -tt.toc -tt.pdf -*.eps - # LaTeX temporary files *.aux *.log @@ -49,4 +39,5 @@ C:\\nppdf32Log\\debuglog.txt # andere binaries *.odt *.pyc +[0-9][0-9].py sn.txt diff --git a/a2/code/client/gen.py b/a2/code/client/gen.py index 1e3bc20..0a8da3a 100644 --- a/a2/code/client/gen.py +++ b/a2/code/client/gen.py @@ -4,15 +4,24 @@ import sys import random import string -def test(corruptDestinationPort, corruptSourcePort, numpackets, payloadsize, outOfOrder, serverPort): +def test( + corruptDestinationPort, + corruptSourcePort, + numSegments, + payloadSize, + outOfOrder, + expectedResult, + serverPort): msgs = [] ownSeqnr = 101 # Make the messages - for _ in range(numpackets): - #msgs.append((ownSeqnr, ''.join(random.choice(string.ascii_letters) for _ in range(payloadsize)))) - msgs.append((ownSeqnr, ''.join(random.choice(string.ascii_letters) for _ in range(payloadsize)))) - ownSeqnr += payloadsize + for _ in range(numSegments): + msgs.append(( + ownSeqnr, + ''.join(random.choice(string.ascii_letters) for _ in + range(payloadSize)))) + ownSeqnr += payloadSize # Out of order if outOfOrder and len(msgs) > 1: @@ -21,7 +30,13 @@ def test(corruptDestinationPort, corruptSourcePort, numpackets, payloadsize, out msgs[indexes[0]], msgs[indexes[1]] = msgs[indexes[1]], msgs[indexes[0]] print msgs - sender = Sender(serverIP="127.0.0.1", networkInterface="lo", isLocal=True, serverPort=serverPort, waitTime=1, isVerbose=0) + sender = Sender( + serverIP="127.0.0.1", + networkInterface="lo", + isLocal=True, + serverPort=serverPort, + waitTime=1, + isVerbose=0) # isLocal is True if the interface is a local one response = sender.sendInput("S", 100, 100) @@ -33,9 +48,11 @@ def test(corruptDestinationPort, corruptSourcePort, numpackets, payloadsize, out # an example for the echo handling server if sender.isTimeout == False: # in case something was received #print 'swapped {} {}'.format(indexes[0], indexes[1]) - corruptDestinationPort = -1 if not corruptDestinationPort else random.randint(0, len(msgs)) + corruptDestinationPort = \ + -1 if not corruptDestinationPort else random.randint(0, len(msgs)) oldDestinationPort = sender.serverPort - corruptSourcePort = -1 if not corruptSourcePort else random.randint(0, len(msgs)) + corruptSourcePort = \ + -1 if not corruptSourcePort else random.randint(0, len(msgs)) oldSourcePort = sender.senderPort for i, (seq, m) in enumerate(msgs): if i == corruptDestinationPort: @@ -47,18 +64,32 @@ def test(corruptDestinationPort, corruptSourcePort, numpackets, payloadsize, out sender.senderPort = sender.senderPort+1 else: sender.senderPort = oldSourcePort - sender.sendInput("A", seq, sender.lastSeqReceived + 1, None) # send some data - sender.sendInput("PA", seq, sender.lastSeqReceived + 1, m) # send some data + print sender.sendInput("A", seq, sender.lastSeqReceived + 1, None) + print sender.sendInput("PA", seq, sender.lastSeqReceived + 1, m) - print 'response: ', sender.sendInput("FA", ownSeqnr, sender.lastSeqReceived + 1) # close connection (the echo also closes) - print 'response: ', sender.sendInput("RP", ownSeqnr+1, 0) # reset connection + print sender.sendInput("FA", ownSeqnr, sender.lastSeqReceived + 1) + print sender.sendInput("RP", ownSeqnr+1, 0) sender.sendReset() # switch sender port print 'Succes!' - if __name__ == '__main__': serverPort = 10000 if len(sys.argv) > 1: serverPort = int(sys.argv[1]) - test(corruptDestinationPort=False, corruptSourcePort=False, numpackets=2, payloadsize=1, outOfOrder=False, serverPort=serverPort) + tcs = [ + {'expectedResult': [], + 'numSegments': 0, + 'corruptDestinationPort': False, + 'corruptSourcePort': False, + 'payloadSize': 0, + 'outOfOrder': False}, + ] + for i, d in enumerate(tcs, 1): + with open('{:02d}.py'.format(i), 'w') as f: + f.write("""\ +#!/usr/bin/python +import gen +gen.test({}, serverPort={}) +""".format(', '.join('{}={}'.format(k, v) for k, v in d.items()), serverPort)) + print 'Testkaas {} geschreven'.format(i) diff --git a/a2/code/setup/iptables.sh b/a2/code/setup/iptables.sh old mode 100644 new mode 100755 -- 2.20.1 From 98ef6ab052169e417e5c9fc88cfed41a98b72225 Mon Sep 17 00:00:00 2001 From: Charlie Gerhardus Date: Sun, 15 Nov 2015 19:00:21 +0100 Subject: [PATCH 13/16] tc 12 t/m 18 kloppen nu ook. --- a2/1cases.tex | 84 +++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index e9ffe8f..fde211c 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -221,9 +221,9 @@ test case can not be created as it is not possible with that number of segments & c & a & b & a & b & \xmark & \xmark & \doTCC & \doTCC\\ & c & b & a & c & a & \xmark & \xmark & \doTCC & \doTCC\\ & b & a & b & c & a & \xmark & \xmark & \xmark & \doTCC\\ - & b & b & a & b & b & \xmark & \xmark & \doTCC & \doTCC\\ + & b & b & a & b & b & \xmark & \xmark & \xmark & \doTCC\\ & c & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\ - & b & b & b & a & b & \xmark & \doTCC & \doTCC & \doTCC\\ + & b & b & b & a & b & \xmark & \xmark & \xmark & \doTCC\\ & a & b & b & b & a & \xmark & \xmark & \doTCC & \doTCC\\ \hline \end{tabular} @@ -473,67 +473,79 @@ described in Table~\ref{tbl:testpairs}. Valid trace & Verify that the script prints 'Success'. \\\hline \hline - - - Nr & 6 \\\hline - Title & 5 requests with 1byte payload with corrupted source port, destination port and checksum. The second segment is omitted in order to simulate a packet drop on the client side. \\\hline - Input & Generated packets with 1byte payload, two packets are swapped in position. \\\hline + + Nr & 12 \\\hline + Title & 5 requests with 65495byte corrupted payload that doesn't show up in checksum and corrupted source port and checksum. The 2nd and 3rd packets are swapped. \\\hline + Input & Generated packets with 65495byte payload, in these packets one 16bit word in the payload, the source port and checksum are increased by one. A different 16bit word in the payload is decreased by one. The 2nd and 3rd packets are swapped in order to simulate a out-of-order transmission. \\\hline Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/5.py} \\\hline + & 2. Execute the script by running \texttt{\# code/client/tests/12.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline + - Nr & 7 \\\hline - Title & Request with corrupted destination port. \\\hline - Input & Generated packets with 1byte payload, in these packets the destination port number is increased by one. \\\hline - Expected output & The packets will never reach the Echo-server resulting in a connection time-out. \\\hline + Nr & 13 \\\hline + Title & Single request with 1byte corrupted payload and corrupted source port, destination port and checksum. \\\hline + Input & Generated packet with 1byte payload, in this packet one byte in the payload, the source port and checksum are increased by one. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/7.py} \\\hline + & 2. Execute the script by running \texttt{\# code/client/tests/13.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline - - Nr & 8 \\\hline - Title & Request with corrupted source address. \\\hline - Input & Generated packets with 1byte payload, in these packets the source address is replaced with 255.255.255.255. \\\hline - Expected output & The Echo-server will receive packet and is unable to respond with a ACK resulting in a connection time-out. \\\hline + + Nr & 14 \\\hline + Title & 5 requests with 1byte corrupted payload and corrupted source port, destination port and checksum. \\\hline + Input & Generated packets with 1byte payload, in these packet one byte in the payload, the source port and checksum are increased by one. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/8.py} \\\hline + & 2. Execute the script by running \texttt{\# code/client/tests/14.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline - Nr & 9 \\\hline - Title & Request with corrupted destination address. \\\hline - Input & Generated packets with 1byte payload, in these packets the destination address is replaced with 255.255.255.255. \\\hline - Expected output & The packets will never reach the Echo-server resulting in a connection time-out. \\\hline + Nr & 15 \\\hline + Title & 5 requests with 65495byte corrupted payload and corrupted source port, destination port and checksum. \\\hline + Input & Generated packets with 65495byte payload, in these packets one byte in the payload, the source port and checksum are increased by one. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/9.py} \\\hline + & 2. Execute the script by running \texttt{\# code/client/tests/15.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline - - Nr & 10 \\\hline - Title & Request with corrupted payload detectable by checksum. \\\hline - Input & Generated packets with 1byte payload, in these packets one byte is increased by 1 after the checksum has been calculated. \\\hline - Expected output & The \emph{SUT} will drop packets before sending them resulting in a runtime error of the test script. \\\hline + + Nr & 16 \\\hline + Title & 5 requests with 65495byte corrupted payload that doesn't show up in the checksum, corrupted source port, destination port and checksum. \\\hline + Input & Generated packets with 65495byte payload, in these packets one 16bit word in the payload, the source port and checksum are increased by one. Another 16bit word in the payload is decreased by 1. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/10.py} \\\hline + & 2. Execute the script by running \texttt{\# code/client/tests/16.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline \hline - Nr & 11 \\\hline - Title & Request with corrupted payload undetectable by checksum. \\\hline - 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 - Expected output & Echo-server receives the corrupted segment. \\\hline + + Nr & 17 \\\hline + Title & 5 requests with 1byte payload, corrupted destination port and checksum. The 2nd and 3rd packets are swapped \\\hline + Input & Generated packets with 1byte payload, in these packets the destination port and checksum are increased by one. The 2nd and 3rd packets are swapped in order to simulate an out-of-order transmission. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline \multirow{2}{*}{Course of action} & 1. Use the steps listed above in order to start the SUT. \\ - & 2. Execute the script by running \texttt{\# code/client/tests/11.py} \\\hline + & 2. Execute the script by running \texttt{\# code/client/tests/17.py} \\\hline Valid trace & Verify that the script prints 'Success'. \\\hline - + \hline + + + Nr & 18 \\\hline + Title & 5 requests with 65495byte payload, corrupted destination port and checksum. The 2nd and 3rd packets are swapped \\\hline + Input & Generated packets with 65495byte payload, in these packets the destination port and checksum are increased by one. The 2nd and 3rd packets are swapped in order to simulate an out-of-order transmission. \\\hline + Expected output & All packets are dropped resulting in a connection time-out. \\\hline + \multirow{2}{*}{Course of action} + & 1. Use the steps listed above in order to start the SUT. \\ + & 2. Execute the script by running \texttt{\# code/client/tests/18.py} \\\hline + Valid trace & Verify that the script prints 'Success'. \\\hline + \hline \end{longtable} %\begin{tabularx}{\linewidth}{| l | X|} -- 2.20.1 From 708cbba91d7d4e943522fa2f11814a077da23015 Mon Sep 17 00:00:00 2001 From: mart Date: Sun, 15 Nov 2015 19:07:18 +0100 Subject: [PATCH 14/16] update generatiescirpt --- a2/code/client/gen.py | 52 +++++++++++++++++++++++++++++----------- a2/code/client/sender.py | 2 +- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/a2/code/client/gen.py b/a2/code/client/gen.py index 0a8da3a..500d0ed 100644 --- a/a2/code/client/gen.py +++ b/a2/code/client/gen.py @@ -5,13 +5,13 @@ import random import string def test( - corruptDestinationPort, - corruptSourcePort, - numSegments, - payloadSize, - outOfOrder, expectedResult, - serverPort): + numSegments=0, + corruptDestinationPort=False, + corruptSourcePort=False, + outOfOrder=False, + payloadSize=1, + serverPort=1000): msgs = [] ownSeqnr = 101 @@ -22,13 +22,13 @@ def test( ''.join(random.choice(string.ascii_letters) for _ in range(payloadSize)))) ownSeqnr += payloadSize + results = ([], msgs[:]) # Out of order if outOfOrder and len(msgs) > 1: indexes = range(0, len(msgs)) random.shuffle(indexes) msgs[indexes[0]], msgs[indexes[1]] = msgs[indexes[1]], msgs[indexes[0]] - print msgs sender = Sender( serverIP="127.0.0.1", @@ -39,11 +39,12 @@ def test( isVerbose=0) # isLocal is True if the interface is a local one response = sender.sendInput("S", 100, 100) + results[0].append(response) # triggers the response SA _ 101 if the server is listening on the specified port # if the server isn't listening, there are no responses - print sender.lastAckReceived - print sender.isTimeout +# print sender.lastAckReceived +# print sender.isTimeout # an example for the echo handling server if sender.isTimeout == False: # in case something was received @@ -64,13 +65,14 @@ def test( sender.senderPort = sender.senderPort+1 else: sender.senderPort = oldSourcePort - print sender.sendInput("A", seq, sender.lastSeqReceived + 1, None) - print sender.sendInput("PA", seq, sender.lastSeqReceived + 1, m) + results[0].append(sender.sendInput("A", seq, sender.lastSeqReceived + 1, None)) + results[0].append(sender.sendInput("PA", seq, sender.lastSeqReceived + 1, m)) - print sender.sendInput("FA", ownSeqnr, sender.lastSeqReceived + 1) - print sender.sendInput("RP", ownSeqnr+1, 0) + results[0].append(sender.sendInput("FA", ownSeqnr, sender.lastSeqReceived + 1)) + results[0].append(sender.sendInput("RP", ownSeqnr+1, 0)) sender.sendReset() # switch sender port + print 'compare results with expected results' print 'Succes!' if __name__ == '__main__': @@ -78,11 +80,33 @@ if __name__ == '__main__': if len(sys.argv) > 1: serverPort = int(sys.argv[1]) tcs = [ +#Case 1 {'expectedResult': [], 'numSegments': 0, 'corruptDestinationPort': False, 'corruptSourcePort': False, - 'payloadSize': 0, + 'payloadSize': 1, + 'outOfOrder': False}, +#Case 2 + {'expectedResult': [], + 'numSegments': 1, + 'corruptDestinationPort': False, + 'corruptSourcePort': False, + 'payloadSize': 1, + 'outOfOrder': False}, +#Case 3 + {'expectedResult': [], + 'numSegments': 5, + 'corruptDestinationPort': False, + 'corruptSourcePort': False, + 'payloadSize': 1, + 'outOfOrder': False}, +#Case 4 + {'expectedResult': [], + 'numSegments': 5, + 'corruptDestinationPort': False, + 'corruptSourcePort': False, + 'payloadSize': 65495, 'outOfOrder': False}, ] for i, d in enumerate(tcs, 1): diff --git a/a2/code/client/sender.py b/a2/code/client/sender.py index 0af62d1..f80bd4b 100644 --- a/a2/code/client/sender.py +++ b/a2/code/client/sender.py @@ -1,6 +1,6 @@ from scapy.all import * -verbose = 1 +verbose = 0 def vb_print(msg): global verbose -- 2.20.1 From db5267384b3e4f38e19507abe804d1dee2354394 Mon Sep 17 00:00:00 2001 From: Charlie Gerhardus Date: Sun, 15 Nov 2015 19:09:28 +0100 Subject: [PATCH 15/16] expected results tabel klopt nu ook. --- a2/1cases.tex | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/a2/1cases.tex b/a2/1cases.tex index fde211c..03a030e 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -304,7 +304,6 @@ described in Table~\ref{tbl:testpairs}. \hline Test number & Expected results\\ \hline\hline - \doTCC & An ACK\# of the sequence number of the SYN packet + 1. \\ \hline \doTCC & An ACK\# of the send sequence number + 1.\\ \hline \doTCC & An ACK\# of the sequence number of the last send segment + the size of the payload of that segment.\\ \hline @@ -312,31 +311,24 @@ described in Table~\ref{tbl:testpairs}. size of the payload of that segment.\\ \hline \doTCC & An ACK\# of the sequence number of the last send segment + the size of the payload of that segment.\\ \hline - \doTCC & An ACK\# of the sequence number of the swapped packet with the lowest sequence number. \\ \hline \doTCC & The ACK\# for the SEQ\# of the first segments which is corrupted is received for each consecutive segment send.\\ $\vdots$ & \\ - \setcounter{TCC}{10} + \setcounter{TCC}{12} \doTCC & The ACK\# for the SEQ\# of the first segments which is corrupted is received for each consecutive segment send.\\ \hline - \doTCC & An ACK\# of the sequence number of the last send segment + the - size of the payload of that segment.\\ \hline -% \doTCC & The segment is not attributed to the current connection -% and therefore no ACK\# is received. \\ \hline -% \doTCC & The ACK\# for the SEQ\# of the first segments which is -% corrupted is received for each consecutive segment send.\\ \hline -% \doTCC & The ACK\# for the SEQ\# of the first segments which is -% corrupted is received for each consecutive segment send.\\ \hline -% \doTCC & The segment is not attributed to the current connection -% and therefore no ACK\# is received. \\ \hline -% \doTCC & The ACK\# for the SEQ\# of the first segments which is -% corrupted is received for each consecutive segment send.\\ \hline -% \doTCC & The ACK\# for the SEQ\# of the first segments which is -% corrupted is received for each consecutive segment send.\\ \hline -% \doTCC & The ACK\# for the SEQ\# of the first segments which is -% corrupted is received for each consecutive segment send.\\ \hline -% \doTCC & The ACK\# for the SEQ\# of the first segments which is -% corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The segment is not attributed to the current connection + and therefore no ACK\# is received. \\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline + \doTCC & The ACK\# for the SEQ\# of the first segments which is + corrupted is received for each consecutive segment send.\\ \hline \end{tabular} \caption{Expected results of test cases} \label{tbl:testcases} -- 2.20.1 From 741a6f2f35674d8adf89124bfacdef3ee0491c47 Mon Sep 17 00:00:00 2001 From: mart Date: Sun, 15 Nov 2015 20:44:23 +0100 Subject: [PATCH 16/16] testcases erin --- a2/code/client/gen.py | 147 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 136 insertions(+), 11 deletions(-) diff --git a/a2/code/client/gen.py b/a2/code/client/gen.py index 500d0ed..790c1c1 100644 --- a/a2/code/client/gen.py +++ b/a2/code/client/gen.py @@ -7,6 +7,7 @@ import string def test( expectedResult, numSegments=0, + dropNthPacket=-1, corruptDestinationPort=False, corruptSourcePort=False, outOfOrder=False, @@ -26,9 +27,10 @@ def test( # Out of order if outOfOrder and len(msgs) > 1: - indexes = range(0, len(msgs)) - random.shuffle(indexes) - msgs[indexes[0]], msgs[indexes[1]] = msgs[indexes[1]], msgs[indexes[0]] + msgs[1], msgs[2] = msgs[2], msgs[1] +# indexes = range(0, len(msgs)) +# random.shuffle(indexes) +# msgs[indexes[0]], msgs[indexes[1]] = msgs[indexes[1]], msgs[indexes[0]] sender = Sender( serverIP="127.0.0.1", @@ -65,15 +67,21 @@ def test( sender.senderPort = sender.senderPort+1 else: sender.senderPort = oldSourcePort - results[0].append(sender.sendInput("A", seq, sender.lastSeqReceived + 1, None)) + if i == dropNthPacket: + continue + #results[0].append(sender.sendInput("A", seq, sender.lastSeqReceived + 1, None)) results[0].append(sender.sendInput("PA", seq, sender.lastSeqReceived + 1, m)) results[0].append(sender.sendInput("FA", ownSeqnr, sender.lastSeqReceived + 1)) results[0].append(sender.sendInput("RP", ownSeqnr+1, 0)) sender.sendReset() # switch sender port - print 'compare results with expected results' - print 'Succes!' + result = [r[2] for r in results[0]] + if result == expectedResult: + print 'Success' + else: + print 'Fail' + print '{} not equal to\n{}'.format(result, expectedResult) if __name__ == '__main__': serverPort = 10000 @@ -81,39 +89,156 @@ if __name__ == '__main__': serverPort = int(sys.argv[1]) tcs = [ #Case 1 - {'expectedResult': [], + {'expectedResult': [101, 102, 'm'], 'numSegments': 0, 'corruptDestinationPort': False, 'corruptSourcePort': False, 'payloadSize': 1, + 'dropNthPacket': -1, 'outOfOrder': False}, #Case 2 - {'expectedResult': [], + {'expectedResult': [101, 102, 103, 'm'], 'numSegments': 1, 'corruptDestinationPort': False, 'corruptSourcePort': False, 'payloadSize': 1, + 'dropNthPacket': -1, 'outOfOrder': False}, #Case 3 - {'expectedResult': [], + {'expectedResult': [101, 102, 103, 104, 105, 106, 107, 'm'], 'numSegments': 5, 'corruptDestinationPort': False, 'corruptSourcePort': False, 'payloadSize': 1, + 'dropNthPacket': -1, 'outOfOrder': False}, #Case 4 - {'expectedResult': [], + {'expectedResult': [101, 65596, 65596, 131091, 196586, 262081, 327576, 327577], 'numSegments': 5, 'corruptDestinationPort': False, 'corruptSourcePort': False, 'payloadSize': 65495, + 'dropNthPacket': -1, 'outOfOrder': False}, +#Case 5 + {'expectedResult': [101, 102, 'm', 103, 103, 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 1, + 'dropNthPacket': -1, + 'outOfOrder': True}, +#Case 6 + {'expectedResult': [101, 65596, 65596, 131091, 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 65495, + 'dropNthPacket': 2, + 'outOfOrder': False}, +#Case 7 + {'expectedResult': [101, 'm', 101, 'm', 'm', 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 1, + 'dropNthPacket': -1, + 'outOfOrder': False}, +#Case 8 + {'expectedResult': [101, 'm', 101, 'm', 'm', 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 65495, + 'dropNthPacket': -1, + 'outOfOrder': False}, +#Case 9 + {'expectedResult': [101, 102, 103, 103, 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': False, + 'corruptSourcePort': False, + 'payloadSize': 1, + 'dropNthPacket': 2, + 'outOfOrder': False}, +#Case 10 + {'expectedResult': [101, 65596, 131091, 131091, 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': False, + 'corruptSourcePort': False, + 'payloadSize': 65495, + 'dropNthPacket': 2, + 'outOfOrder': False}, +#Case 11 + {'expectedResult': [101, 65596, 65596, 'm', 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': False, + 'payloadSize': 65495, + 'dropNthPacket': 2, + 'outOfOrder': False}, +#Case 12 + {'expectedResult': [101, 65596, 65596, 65596, 131091, 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': False, + 'corruptSourcePort': True, + 'payloadSize': 65495, + 'dropNthPacket': -1, + 'outOfOrder': True}, +#Case 13 + {'expectedResult': [101, 'm', 'm', 'm'], + 'numSegments': 1, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 1, + 'dropNthPacket': -1, + 'outOfOrder': False}, +#Case 14 + {'expectedResult': [101, 102, 103, 104, 'm', 104, 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 1, + 'dropNthPacket': -1, + 'outOfOrder': False}, +#Case 15 + {'expectedResult': [101, 65596, 'm', 65596, 'm', 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 65495, + 'dropNthPacket': -1, + 'outOfOrder': False}, +#Case 16 + {'expectedResult': [101, 65596, 65596, 131091, 196586, 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': True, + 'payloadSize': 65495, + 'dropNthPacket': -1, + 'outOfOrder': False}, +#Case 17 + {'expectedResult': [101, 'm', 101, 'm', 'm', 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': False, + 'payloadSize': 1, + 'dropNthPacket': -1, + 'outOfOrder': True}, +#Case 18 + {'expectedResult': [101, 65596, 65596, 'm', 'm', 'm', 'm', 'm'], + 'numSegments': 5, + 'corruptDestinationPort': True, + 'corruptSourcePort': False, + 'payloadSize': 65495, + 'dropNthPacket': -1, + 'outOfOrder': True} ] for i, d in enumerate(tcs, 1): with open('{:02d}.py'.format(i), 'w') as f: f.write("""\ #!/usr/bin/python import gen +print 'Test number: {}' gen.test({}, serverPort={}) -""".format(', '.join('{}={}'.format(k, v) for k, v in d.items()), serverPort)) +""".format(i, ', '.join('{}={}'.format(k, v) for k, v in d.items()), serverPort)) print 'Testkaas {} geschreven'.format(i) -- 2.20.1