From a3248380f2503b9a390be5626a14a1e112069305 Mon Sep 17 00:00:00 2001 From: charlie Date: Sun, 20 Dec 2015 23:23:30 +0100 Subject: [PATCH] generate grapvis from gast model --- a3/code/dotgen/graph.dot | 65 +++ a3/code/dotgen/tcpmodel.icl | 100 +++++ a3/code/dotgen/tcpmodel.prj | 760 ++++++++++++++++++++++++++++++++++++ a3/code/tcpmodel.icl | 57 ++- 4 files changed, 968 insertions(+), 14 deletions(-) create mode 100644 a3/code/dotgen/graph.dot create mode 100644 a3/code/dotgen/tcpmodel.icl create mode 100644 a3/code/dotgen/tcpmodel.prj diff --git a/a3/code/dotgen/graph.dot b/a3/code/dotgen/graph.dot new file mode 100644 index 0000000..143c598 --- /dev/null +++ b/a3/code/dotgen/graph.dot @@ -0,0 +1,65 @@ +digraph TCPModel { +label="TCPModel" +rankdir=LR +size="50,6!" +bgcolor=lightsteelblue +ordering="out" +outputorder="nodesfirst" +4[fillcolor=grey90,fontcolor=black,label="Listen",style="filled",shape=doublecircle,fontname="Helvetica",fontsize=11,fixedsize=true,width=1,height=1] +4->2[label="ACK/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +4->2[label="DATA/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +4->2[label="FIN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +4->2[label="RST/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +4->5[label="SYN/[SYN,ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +0[fillcolor=grey90,fontcolor=black,label="Awaiting Close",style="filled",shape=circle,fontname="Helvetica",fontsize=11,fixedsize=true,width=1,height=1] +0->1[label="ACK/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +0->2[label="DATA/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +0->2[label="FIN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +0->2[label="RST/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +0->2[label="SYN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +1[fillcolor=blue,fontcolor=white,label="Closed",style="filled",shape=circle,fontname="Helvetica",fontsize=11,fixedsize=true,width=1,height=1] +1->1[label="ACK/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +1->1[label="DATA/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +1->1[label="FIN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +1->1[label="RST/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +1->1[label="SYN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +2[fillcolor=blue,fontcolor=white,label="Connection Error",style="filled",shape=circle,fontname="Helvetica",fontsize=11,fixedsize=true,width=1,height=1] +2->2[label="ACK/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +2->2[label="DATA/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +2->2[label="FIN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +2->2[label="RST/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +2->2[label="SYN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3[fillcolor=grey90,fontcolor=black,label="Established",style="filled",shape=circle,fontname="Helvetica",fontsize=11,fixedsize=true,width=1,height=1] +3->2[label="ACK/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->3[label="DATA/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->3[label="DATA/[DATA]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->6[label="DATA/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->0[label="FIN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->1[label="FIN/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->2[label="RST/[DATA]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->2[label="RST/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->2[label="RST/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->2[label="SYN/[DATA]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->2[label="SYN/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +3->2[label="SYN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +5[fillcolor=grey90,fontcolor=black,label="Received SYN",style="filled",shape=circle,fontname="Helvetica",fontsize=11,fixedsize=true,width=1,height=1] +5->3[label="ACK/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +5->3[label="DATA/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +5->1[label="FIN/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +5->4[label="RST/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +5->2[label="SYN/[SYN,ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6[fillcolor=grey90,fontcolor=black,label="Waiting",style="filled",shape=circle,fontname="Helvetica",fontsize=11,fixedsize=true,width=1,height=1] +6->3[label="ACK/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="DATA/[DATA]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="DATA/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="DATA/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="FIN/[DATA]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="FIN/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="FIN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="RST/[DATA]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="RST/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="RST/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="SYN/[DATA]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="SYN/[ACK]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +6->2[label="SYN/[]",fontname="Helvetica",fontsize=11,labelfontname="Helvetica",labelfontsize=11,color=black,arrowsize=1.2] +} diff --git a/a3/code/dotgen/tcpmodel.icl b/a3/code/dotgen/tcpmodel.icl new file mode 100644 index 0000000..2b73c25 --- /dev/null +++ b/a3/code/dotgen/tcpmodel.icl @@ -0,0 +1,100 @@ +module tcpmodel + +import gast, ESMSpec, Graphviz + +derive bimap [] +derive gEq State +derive gLess State +derive genShow State +derive ggen Input +derive gEq Input +derive genShow Input +derive gEq Output +derive genShow Output + +/* connection settings */ +hostIP = "192.168.0.14" +hostPort = 1203 + +/* states */ +:: State = Listen | ReceivedSYN | Established | Waiting | Closed | WaitClose | ConnectionError + +instance render State where + render Listen = "Listen" + render ReceivedSYN = "Received SYN" + render Established = "Established" + render Waiting = "Waiting" + render Closed = "Closed" + render WaitClose = "Awaiting Close" + render ConnectionError = "Connection Error" + +/* input (received from client) */ +:: Input = InSYN | InACK | InDATA | InRST | InFIN + +instance render Input where + render InSYN = "SYN" + render InACK = "ACK" + render InDATA = "DATA" + render InRST = "RST" + render InFIN = "FIN" + +/* output (sent to client) */ +:: Output = OutSYN | OutACK | OutDATA | OutFIN + +instance render Output where + render OutSYN = "SYN" + render OutACK = "ACK" + render OutDATA = "DATA" + render OutFIN = "FIN" + +/* state transitions */ +stateTrans :: State Input -> [Trans Output State] +stateTrans Listen InSYN = [Pt [OutSYN, OutACK] ReceivedSYN] +stateTrans Listen InFIN = [Pt [] ConnectionError] +stateTrans Listen InACK = [Pt [] ConnectionError] +stateTrans Listen InDATA = [Pt [] ConnectionError] +stateTrans Listen InRST = [Pt [] ConnectionError] + +stateTrans ReceivedSYN InSYN = [Pt [OutSYN,OutACK] ConnectionError] +stateTrans ReceivedSYN InRST = [Pt [] Listen] +stateTrans ReceivedSYN InACK = [Pt [] Established] +stateTrans ReceivedSYN InFIN = [Pt [OutACK] Closed] +stateTrans ReceivedSYN InDATA = [Pt [OutACK] Established] + +stateTrans Established InSYN = [Pt [] ConnectionError, Pt [OutACK] ConnectionError, Pt [OutDATA] ConnectionError] // connection error returns whatever it wants? +stateTrans Established InDATA = [Pt [OutACK] Waiting, Pt [OutDATA] Established, Pt [] Established] // last one resend? +stateTrans Established InRST = [Pt [] ConnectionError, Pt [OutACK] ConnectionError, Pt [OutDATA] ConnectionError] // connection error returns whatever it wants? +stateTrans Established InFIN = [Pt [OutACK] Closed, Pt [] WaitClose] +stateTrans Established InACK = [Pt [] ConnectionError] + +stateTrans Waiting InACK = [Pt [] Established] +stateTrans Waiting _ = [Pt [] ConnectionError, Pt [OutACK] ConnectionError, Pt [OutDATA] ConnectionError] + +stateTrans WaitClose InACK = [Pt [OutACK] Closed] +stateTrans WaitClose _ = [Pt [] ConnectionError] + +stateTrans Closed _ = [Pt [] Closed] +stateTrans ConnectionError _ = [Pt [] ConnectionError] + +/* state machine thingy */ +esm :: ESM State Input Output +esm = {s_0 = Listen, d_F = stateTrans, out = \_ _ . [], pred = \_ . []} + +/* build transitions */ +automaton = addTransitions 50 esm [Listen] [InSYN] {trans = [], issues = []} + +/* build graph */ +graph = mkDigraph "TCPModel" (automaton, Listen, [], [Closed,ConnectionError], [], []) + +/* write list of strings to file */ +instance <<< [String] where + (<<<) file [] = file + (<<<) file [x:xs] = file <<< x <<< xs + +/* testing program */ +Start world + # (_, file, world) = fopen "graph.dot" FWriteText world + # file = file <<< printDigraph graph + # (_, world) = fclose file world + = world + diff --git a/a3/code/dotgen/tcpmodel.prj b/a3/code/dotgen/tcpmodel.prj new file mode 100644 index 0000000..227aacf --- /dev/null +++ b/a3/code/dotgen/tcpmodel.prj @@ -0,0 +1,760 @@ +Version: 1.4 +Global + ProjectRoot: . + Target: Gast + Exec: {Project}\tcpmodel.exe + CodeGen + CheckStacks: False + CheckIndexes: True + Application + HeapSize: 2097152 + StackSize: 512000 + ExtraMemory: 81920 + IntialHeapSize: 204800 + HeapSizeMultiplier: 4096 + ShowExecutionTime: False + ShowGC: False + ShowStackSize: False + MarkingCollector: False + StandardRuntimeEnv: True + Profile + Memory: False + MemoryMinimumHeapSize: 0 + Time: False + Stack: False + Output + Output: ShowConstructors + Font: Courier + FontSize: 9 + WriteStdErr: False + Link + LinkMethod: Static + GenerateRelocations: False + GenerateLinkMap: False + LinkResources: False + ResourceSource: + GenerateDLL: False + ExportedNames: + Paths + Path: {Project} + Path: {Application}\Libraries\Gast + Path: {Application}\Libraries\WrapDebug + Path: {Application}\Libraries\MersenneTwister + Path: {Application}\Libraries\TCPIP + Precompile: + Postlink: +MainModule + Name: tcpmodel + Dir: {Project} + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False +OtherModules + Module + Name: ESMSpec + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: Graphviz + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: confSM + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: gast + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: gen + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: genLibTest + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: stdProperty + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: testable + Dir: {Application}\Libraries\Gast + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: MersenneTwister + Dir: {Application}\Libraries\MersenneTwister + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenBimap + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenCompress + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenEq + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenFMap + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenHylo + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenLexOrd + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenLib + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenMap + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenMapSt + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenMonad + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenParse + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenPrint + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenReduce + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: GenZip + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: _Array + Dir: {Application}\Libraries\Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdArray + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdBool + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdChar + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdCharList + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdClass + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdDebug + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdEnum + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdEnv + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdFile + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdFunc + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdGeneric + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdInt + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdList + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdMisc + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdOrdList + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdOverloaded + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdReal + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdString + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdTuple + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: _SystemArray + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: _SystemEnum + Dir: {Application}\Libraries\StdEnv + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdArrayExtensions + Dir: {Application}\Libraries\StdLib + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdLib + Dir: {Application}\Libraries\StdLib + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdLibMisc + Dir: {Application}\Libraries\StdLib + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdListExtensions + Dir: {Application}\Libraries\StdLib + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: StdMaybe + Dir: {Application}\Libraries\StdLib + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False diff --git a/a3/code/tcpmodel.icl b/a3/code/tcpmodel.icl index 439dde8..cf9cd89 100644 --- a/a3/code/tcpmodel.icl +++ b/a3/code/tcpmodel.icl @@ -12,45 +12,66 @@ derive gEq Output derive genShow Output /* connection settings */ -hostIP = "127.0.0.1" +hostIP = "192.168.0.14" hostPort = 1203 /* states */ -:: State = Listen | ReceivedSYN | Established | Waiting | Closed +:: State = Listen | ReceivedSYN | Established | Waiting | Closed | WaitClose | ConnectionError + +instance == State where + (==) Listen Listen = True + (==) ReceivedSYN ReceivedSYN = True + (==) Established Established = True + (==) Waiting Waiting = True + (==) Closed Closed = True + (==) WaitClose WaitClose = True + (==) ConnectionError ConnectionError = True + (==) _ _ = False /* input (received from client) */ -:: Input = InSYN | InACK | InRST | InFIN | InUserData +:: Input = InSYN | InACK | InDATA | InRST | InFIN instance toString Input where toString InSYN = "SYN" toString InACK = "ACK" toString InRST = "RST" toString InFIN = "FIN" - toString InUserData = "DATA " + toString InDATA = "DATA" /* output (sent to client) */ -:: Output = OutSYN | OutACK | OutFIN +:: Output = OutSYN | OutACK | OutDATA | OutFIN toOutput :: String -> [Output] toOutput "SYN-ACK" = [OutSYN, OutACK] -toOutput _ = [] +toOutput "ACK" = [OutACK] +toOutput "DATA" = [OutDATA] +toOutput "TO" = [] /* state transitions */ stateTrans :: State Input -> [Trans Output State] stateTrans Listen InSYN = [Pt [OutSYN, OutACK] ReceivedSYN] -stateTrans Listen _ = [Pt [] Listen] +stateTrans Listen InFIN = [Pt [] ConnectionError] +stateTrans Listen InACK = [Pt [] ConnectionError] +stateTrans Listen InDATA = [Pt [] ConnectionError] +stateTrans Listen InRST = [Pt [] ConnectionError] +stateTrans ReceivedSYN InSYN = [Pt [OutSYN,OutACK] ConnectionError] stateTrans ReceivedSYN InRST = [Pt [] Listen] stateTrans ReceivedSYN InACK = [Pt [] Established] -stateTrans ReceivedSYN _ = [Pt [] ReceivedSYN] +stateTrans ReceivedSYN InFIN = [Pt [OutACK] Closed] +stateTrans ReceivedSYN InDATA = [Pt [OutACK] Established] -stateTrans Established InACK = [Pt [OutACK] Established] -stateTrans Established InUserData = [Pt [OutACK] Waiting] -stateTrans Established InFIN = [Pt [OutACK] Closed] -stateTrans Established _ = [Pt [] Established] +stateTrans Established InSYN = [Pt [] ConnectionError, Pt [OutACK] ConnectionError, Pt [OutDATA] ConnectionError] // connection error returns whatever it wants? +stateTrans Established InDATA = [Pt [OutACK] Waiting, Pt [OutDATA] Established, Pt [] Established] // last one resend? +stateTrans Established InRST = [Pt [] ConnectionError, Pt [OutACK] ConnectionError, Pt [OutDATA] ConnectionError] // connection error returns whatever it wants? +stateTrans Established InFIN = [Pt [OutACK] Closed, Pt [] WaitClose] +stateTrans Established InACK = [Pt [] ConnectionError] stateTrans Waiting InACK = [Pt [] Established] -stateTrans Waiting _ = [Pt [] Waiting] +stateTrans Waiting _ = [Pt [] ConnectionError, Pt [OutACK] ConnectionError, Pt [OutDATA] ConnectionError] + +stateTrans WaitClose InACK = [Pt [OutACK] Closed] +stateTrans WaitClose _ = [Pt [] ConnectionError] /* sut state */ :: *SutState :== (StringSChannel, StringRChannel, *World) @@ -68,6 +89,14 @@ reset (s, r, world) # (s, world) = send "SUT-RESET" s world = (s, r, world) +/* all endstates */ +endstate :: [State] -> Bool +endstate sts = isMember Closed sts || isMember ConnectionError sts + +/* testing options */ +options = [Nsequences 10000, Stop endstate] + +/* testing program */ Start world /* open console */ # (console, world) = stdio world @@ -83,7 +112,7 @@ Start world # (_, file, world) = fopen "testOut.txt" FWriteText world /* perform testing */ # st = (toStringSChannel con.sChannel, toStringRChannel con.rChannel, world) - # ((_, _, world), console, file) = testConfSM [] stateTrans Listen adapter st reset console file + # ((_, _, world), console, file) = testConfSM options stateTrans Listen adapter st reset console file /* close connection */ /* close files */ # (_, world) = fclose file world -- 2.20.1