From: mart Date: Wed, 11 Nov 2015 08:58:00 +0000 (+0100) Subject: veel code erbij gedaan X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=0bc421a9f086432789520a67ef47c146d2a21785;p=tt2015.git veel code erbij gedaan --- diff --git a/.gitignore b/.gitignore index 6d36477..ce15282 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ C:\\nppdf32Log\\debuglog.txt # andere binaries *.odt +*.pyc +sn.txt diff --git a/a2/1cases.tex b/a2/1cases.tex index b3ea384..71b630c 100644 --- a/a2/1cases.tex +++ b/a2/1cases.tex @@ -1,13 +1,11 @@ - \pagebreak -\begin{table} \subsection{Preflight checklist} - Before actual certification is commenced we perform a manual test using a checklist. If any of the checks fail we immediately reject the product. The checklist is given in the table below. +\begin{table} \begin{tabularx}{\linewidth}{| l | X|} \hline Check 1 & Get the SUT in a workable state. \\\hline diff --git a/a2/code/client/main.py b/a2/code/client/helloworld.py old mode 100644 new mode 100755 similarity index 56% rename from a2/code/client/main.py rename to a2/code/client/helloworld.py index 6d109db..593252c --- a/a2/code/client/main.py +++ b/a2/code/client/helloworld.py @@ -1,38 +1,26 @@ -from sender import Sender -import sys - -# before running this program, be sure to run the TCPServer -# also make sure to run the below command to prevent the OS from canceling our connection -# sudo iptables -A OUTPUT -p tcp --tcp-flags PSH PSH -j ACCEPT -# sudo iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP - -# for running tests, you may need to store information on the received sequence number for the server -# you can do that by defining new fields within the sender class/global variables to store such info - -# for non local communication, you can comment the raw sockets setting in sender.py (line 132) - -# run using sudo (!!!) from a command line terminal -# and don't mind/ignore eclipse's red markings. - -if __name__ == "__main__": - serverPort = 10000 - if len(sys.argv) > 1: - serverPort = int(sys.argv[1]) - sender = Sender(serverIP="127.0.0.1", networkInterface="lo", isLocal=True, serverPort=serverPort, waitTime=1, isVerbose=1) - # isLocal is True if the interface is a local one - response = sender.sendInput("S", 100, 100) - - # 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 - - # an example for the echo handling server - if sender.isTimeout == False: # in case something was received - sender.sendInput("A", 101, sender.lastSeqReceived + 1) # connection is established - sender.sendInput("A", 101, sender.lastSeqReceived + 1, data = "C") # send some data - sender.sendInput("A", 102, sender.lastSeqReceived + 1, data = "C") # send some data - sender.sendInput("FA", 103, sender.lastSeqReceived + 1) # close connection (the echo also closes) - sender.sendInput("RP", 104, 0) # reset connection - - sender.sendReset() # switch sender port +#!/usr/bin/python +from sender import Sender +import sys + +if __name__ == "__main__": + serverPort = 10000 + if len(sys.argv) > 1: + serverPort = int(sys.argv[1]) + sender = Sender(serverIP="127.0.0.1", networkInterface="lo", isLocal=True, serverPort=serverPort, waitTime=1, isVerbose=1) + # isLocal is True if the interface is a local one + response = sender.sendInput("S", 100, 100) + + # 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 + + # an example for the echo handling server + if sender.isTimeout == False: # in case something was received + sender.sendInput("A", 101, sender.lastSeqReceived + 1) # connection is established + sender.sendInput("A", 101, sender.lastSeqReceived + 1, data = "Hello world!") # send some data + sender.sendInput("FA", 103, sender.lastSeqReceived + 1) # close connection (the echo also closes) + sender.sendInput("RP", 104, 0) # reset connection + + sender.sendReset() # switch sender port + print 'Succes!' diff --git a/a2/code/client/sn.txt b/a2/code/client/sn.txt deleted file mode 100644 index 05f3e49..0000000 --- a/a2/code/client/sn.txt +++ /dev/null @@ -1 +0,0 @@ -20233 \ No newline at end of file diff --git a/a2/code/setup/iptables.sh b/a2/code/setup/iptables.sh new file mode 100755 index 0000000..6006919 --- /dev/null +++ b/a2/code/setup/iptables.sh @@ -0,0 +1,3 @@ +#!/bin/sh +iptables -A OUTPUT -p tcp --tcp-flags PSH PSH -j ACCEPT +iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP diff --git a/a2/tt2.tex b/a2/tt2.tex index 623c273..0ffb82d 100644 --- a/a2/tt2.tex +++ b/a2/tt2.tex @@ -4,16 +4,13 @@ \tableofcontents \newpage - \section{Tests} \input{1cases.tex} \section{Results} \input{2results.tex} -\newpage \nocite{*} %% weghalen bij daadwerkelijke cite \bibliographystyle{plain} \bibliography{tt2} - \end{document}