diff --git a/.vs/INF1009/v15/.suo b/.vs/INF1009/v15/.suo index 043cf40..1c95f8d 100644 Binary files a/.vs/INF1009/v15/.suo and b/.vs/INF1009/v15/.suo differ diff --git a/.vs/INF1009/v15/Server/sqlite3/storage.ide b/.vs/INF1009/v15/Server/sqlite3/storage.ide index b0b338b..0b3a71a 100644 Binary files a/.vs/INF1009/v15/Server/sqlite3/storage.ide and b/.vs/INF1009/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/INF1009/v15/Server/sqlite3/storage.ide-wal b/.vs/INF1009/v15/Server/sqlite3/storage.ide-wal index 51a6e9d..ba85774 100644 Binary files a/.vs/INF1009/v15/Server/sqlite3/storage.ide-wal and b/.vs/INF1009/v15/Server/sqlite3/storage.ide-wal differ diff --git a/.vs/INF1009/v15/sqlite3/storage.ide b/.vs/INF1009/v15/sqlite3/storage.ide index 8256781..5713474 100644 Binary files a/.vs/INF1009/v15/sqlite3/storage.ide and b/.vs/INF1009/v15/sqlite3/storage.ide differ diff --git a/.vs/INF1009/v15/sqlite3/storage.ide-wal b/.vs/INF1009/v15/sqlite3/storage.ide-wal index 781cbf5..4af3930 100644 Binary files a/.vs/INF1009/v15/sqlite3/storage.ide-wal and b/.vs/INF1009/v15/sqlite3/storage.ide-wal differ diff --git a/INF1009/Form1.cs b/INF1009/Form1.cs index 0351a45..cb1c934 100644 --- a/INF1009/Form1.cs +++ b/INF1009/Form1.cs @@ -24,6 +24,7 @@ public partial class Form1 : Form private Thread networkWriteThread, transportWriteThread, transportReadThread, networkReadThread, processingThread; private const string S_lec = "s_lec.txt"; private string d_msg; + private string d_msgType; delegate void UIDisplayText(string text); public Form1() @@ -63,7 +64,7 @@ private void openThreads() private void buttonStart_Click(object sender, EventArgs e) { - + richTextBoxGen.Clear(); try { reset(); @@ -96,6 +97,7 @@ public void reset() private void buttonReset_Click(object sender, EventArgs e) { + nbTest = 1; transport.Stop(); rtbL_ecr.Clear(); rtbL_lec.Clear(); @@ -132,6 +134,7 @@ private void buttonGenerate_Click(object sender, EventArgs e) string dest = transport.setDestAddress(); int intDest = Int32.Parse(dest); string source = transport.setSourceAddress(intDest); + d_msgType = "GenTest"; d_msg = "N_CONNECT " + dest + " " + source + "\n" + "N_DATA test no.: " + nbTest + "\n" + @@ -143,16 +146,22 @@ private void buttonGenerate_Click(object sender, EventArgs e) private void buttonSend2File_Click(object sender, EventArgs e) { + if (d_msgType == "GenTest") + richTextBoxGen.AppendText("\n Test sent to file !"); + else if (d_msgType == "TestFile") + richTextBoxGen.AppendText("\n Test file sent !"); transport.Stop(); File.AppendAllText(S_lec, d_msg + Environment.NewLine); - - richTextBoxGen.Clear(); nbTest++; transport.Restart(); } private void buttonTest_Click(object sender, EventArgs e) { + richTextBoxGen.Clear(); + richTextBoxGen.AppendText("\n Test file loaded !"); + d_msgType = "TestFile"; + d_msg = "N_CONNECT 1 11\n" + "N_DATA Start testing INF1009\n" + "N_DISCONNECT 1 11\n" + diff --git a/INF1009/Network.cs b/INF1009/Network.cs index b00ac66..9e5d383 100644 --- a/INF1009/Network.cs +++ b/INF1009/Network.cs @@ -18,7 +18,7 @@ class Network private FileStream file2Transport; private StreamWriter writeFromTransport; private StreamWriter write2Transport; - private int respAddr, sentCount; + private int sentCount; byte[] sourceAddr; byte[] destAddr; byte[] outputNo; @@ -59,7 +59,6 @@ public void Start() outputNo = new byte[1]; newConnection(outputNo); - respAddr = rnd.Next(); pr = 0; receivedData = ""; disconnected = false; @@ -159,14 +158,53 @@ public void transportRead() else { if (transportNpdu.type == "N_CONNECT.req") - + { - msg = "N_CONNECT " + transportNpdu.destAddr + " " + transportNpdu.sourceAddr + " route: " + transportNpdu.routeAddr; + int intSource = int.Parse(transportNpdu.sourceAddr); + int intDest = int.Parse(transportNpdu.destAddr); + sourceAddr[0] = (byte)intSource; + destAddr[0] = (byte)intDest; + + if (intSource > 249 || intDest > 249) + { + transportNpdu.routeAddr = " Error, not found !"; + } + else + { + if (intSource >= 0 && intSource <= 99) + { + if (intDest >= 0 && intDest <= 99) + transportNpdu.routeAddr = "" + intDest; + else if (intDest >= 100 && intDest <= 199) + transportNpdu.routeAddr = "" + 255; + else if (intDest >= 200 && intDest <= 249) + transportNpdu.routeAddr = "" + 254; + } + else if (intSource >= 100 && intSource <= 199) + { + if (intDest >= 0 && intDest <= 99) + transportNpdu.routeAddr = "" + 250; + else if (intDest >= 100 && intDest <= 199) + transportNpdu.routeAddr = "" + intDest; + else if (intDest >= 200 && intDest <= 249) + transportNpdu.routeAddr = "" + 253; + } + else if (intSource >= 200 && intSource <= 249) + { + if (intDest >= 0 && intDest <= 99) + transportNpdu.routeAddr = "" + 251; + else if (intDest >= 100 && intDest <= 199) + transportNpdu.routeAddr = "" + 252; + else if (intDest >= 200 && intDest <= 249) + transportNpdu.routeAddr = "" + intDest; + } + + } + + msg = "N_CONNECT " + transportNpdu.destAddr + " " + transportNpdu.sourceAddr + " route:" + transportNpdu.routeAddr; writeFromTransport.WriteLine(msg); Form1._UI.write2L_lec(msg); - sourceAddr[0] = (byte)int.Parse(transportNpdu.sourceAddr); - destAddr[0] = (byte)int.Parse(transportNpdu.destAddr); if (sourceAddr[0] % 27 == 0 || int.Parse(transportNpdu.sourceAddr) > 249 || int.Parse(transportNpdu.destAddr) > 249) { disconnected = true; @@ -174,7 +212,6 @@ public void transportRead() npdu2Transport = new Npdu(); npdu2Transport.type = "N_DISCONNECT.ind"; - npdu2Transport.routeAddr = respAddr.ToString(); npdu2Transport.target = "00000010"; npdu2Transport.connection = "255"; network2Transport.Enqueue(npdu2Transport); @@ -185,7 +222,6 @@ public void transportRead() npdu2Transport = new Npdu(); npdu2Transport.type = "N_CONNECT.conf"; - npdu2Transport.routeAddr = respAddr.ToString(); npdu2Transport.sourceAddr = sourceAddr[0].ToString(); npdu2Transport.destAddr = destAddr[0].ToString(); npdu2Transport.connection = outputNo[0].ToString(); @@ -250,7 +286,6 @@ public void transportRead() npdu2Transport = new Npdu(); npdu2Transport.type = "N_DISCONNECT.ind"; - npdu2Transport.routeAddr = respAddr.ToString(); packet4Processing = Packet.encapsulateRelease(outputNo[0], sourceAddr[0], destAddr[0], true); string packetType = "release"; diff --git a/INF1009/Packet.cs b/INF1009/Packet.cs index af5a379..e5ef65e 100644 --- a/INF1009/Packet.cs +++ b/INF1009/Packet.cs @@ -268,7 +268,7 @@ public static PACKET decapBytes(byte[] received) currentPacket.dataArray = temp; } - + return currentPacket; } diff --git a/INF1009/Transport.cs b/INF1009/Transport.cs index c3382f0..07e711d 100644 --- a/INF1009/Transport.cs +++ b/INF1009/Transport.cs @@ -87,12 +87,10 @@ public void Stop() public void Restart() { end = false; - inputFile = new FileStream(S_lec, FileMode.OpenOrCreate, FileAccess.Read); reader = new StreamReader(inputFile); outputFile = new FileStream(S_ecr, FileMode.OpenOrCreate, FileAccess.Write); writer = new StreamWriter(outputFile); - resetFiles(); Start(); } @@ -154,51 +152,6 @@ public string setSourceAddress(int intDest) return result; } - /** - * Methode setRouteAddress definit une addresse de routage selon - * l'enonce de travail. Par contre cette adresse n'est pas utilise - * par le programme, la methode et la variable de routage ne - * servent pas, j'ai donc ecris la route dans une variable du Npdu - */ - private string setRouteAddress(string dest, string source) - { - string result = null; - - int intResult = -1; - int intSource = Int32.Parse(source); - int intDest = Int32.Parse(dest); - - if (intSource >= 0 && intSource <= 99) - { - if (intDest >= 0 && intDest <= 99) - intResult = intDest; - else if (intDest >= 100 && intDest <= 199) - intResult = 255; - else if (intDest >= 200 && intDest <= 249) - intResult = 254; - } - else if (intSource >= 100 && intSource <= 199) - { - if (intDest >= 0 && intDest <= 99) - intResult = 250; - else if (intDest >= 100 && intDest <= 199) - intResult = intDest; - else if (intDest >= 200 && intDest <= 249) - intResult = 253; - } - else if (intSource >= 200 && intSource <= 249) - { - if (intDest >= 0 && intDest <= 99) - intResult = 251; - else if (intDest >= 100 && intDest <= 199) - intResult = 252; - else if (intDest >= 200 && intDest <= 249) - intResult = intDest; - } - - result = result + intResult; - return result; - } /** * Methode networkWrite (ecrire_vers_reseau) qui lit le fichier s_lec.txt @@ -232,7 +185,7 @@ public void networkWrite() networkNNpdu.type = "N_CONNECT.req"; networkNNpdu.destAddr = settings[1]; networkNNpdu.sourceAddr = settings[2]; - networkNNpdu.routeAddr = setRouteAddress(settings[1], settings[2]); + networkNNpdu.routeAddr = ""; valid = true; } else if (settings[0] == "N_DATA") diff --git a/INF1009/bin/Debug/INF1009.exe b/INF1009/bin/Debug/INF1009.exe index 40844a5..c0dfdbd 100644 Binary files a/INF1009/bin/Debug/INF1009.exe and b/INF1009/bin/Debug/INF1009.exe differ diff --git a/INF1009/bin/Debug/INF1009.pdb b/INF1009/bin/Debug/INF1009.pdb index bfa485e..80b2b5b 100644 Binary files a/INF1009/bin/Debug/INF1009.pdb and b/INF1009/bin/Debug/INF1009.pdb differ diff --git a/INF1009/bin/Debug/l_ecr.txt b/INF1009/bin/Debug/l_ecr.txt index f0e179e..793d6c7 100644 --- a/INF1009/bin/Debug/l_ecr.txt +++ b/INF1009/bin/Debug/l_ecr.txt @@ -1,17 +1,23 @@ -N_CONNECT 1 11 route: 1 +N_CONNECT 1 11 route:1 N_DATA Start testing INF1009 -N_CONNECT 47 15 route: 47 +N_CONNECT 47 15 route:47 N_DATA negative Acknoledgment -N_CONNECT 200 27 route: 254 -N_CONNECT 200 500 route: -1 -N_CONNECT 9 19 route: 9 +N_DISCONNECT 47 +N_CONNECT 200 27 route:254 +N_CONNECT 200 500 route: Error, not found ! +N_CONNECT 9 19 route:9 N_DATA multiple of 19 - no awnser N_DISCONNECT 9 -N_CONNECT 12 13 route: 12 -N_CONNECT 58 217 route: 251 -N_DATA This is the last test, this program was written for the recognition of the achievements of Patrick Duhaime for the course INF1009 ... -N_DISCONNECT 58 -e INF1009 ... +N_CONNECT 12 13 route:12 + 43 route:84 +N_DATA test no.: 8 +N_DISCONNECT 84 +N_CONNECT 1 11 route:1 +N_DATA Start testing INF1009 + achievements of Patrick Duhaime for the course INF1009 ... N_DISCONNECT 58 -d quid est quod in hac causa maxime homines admirentur et reprehendant meum consilium, cum ego idem antea multa decreverim, que magis ad hominis dignitatem quam ad rei publicae necessitatem pertinerent? Supplicationem quindecim dierum decrevi sententia mea +N_CONNECT 118 207 route:252 +N_DATA test no.: 2 +N_DISCONNECT 118 +t meum consilium, cum ego idem antea multa decreverim, que magis ad hominis dignitatem quam ad rei publicae necessitatem pertinerent? Supplicationem quindecim dierum decrevi sententia mea N_DISCONNECT 58 diff --git a/INF1009/bin/Debug/l_lec.txt b/INF1009/bin/Debug/l_lec.txt index 91a5635..a804dbd 100644 --- a/INF1009/bin/Debug/l_lec.txt +++ b/INF1009/bin/Debug/l_lec.txt @@ -1,29 +1,28 @@ N_CONNECT dest Address :1 source Address: 11 N_DATA transferring network data N_CONNECT dest Address :47 source Address: 15 +N_DISCONNECT Closed by Client N_DATA transferring network data N_DATA transferring network data N_DISCONNECT Closed by Client N_DISCONNECT Closed by Client -N_CONNECT dest Address :58 source Address: 217 -N_DATA transferring network data -N_DATA transferring network data -N_DATA transferring network data -N_DATA transferring network data +data +N_DISCONNECT Closed by Client +N_CONNECT dest Address :248 source Address: 88 N_DATA transferring network data N_DATA transferring network data N_DISCONNECT Closed by Client -TA transferring network data -N_DATA transferring network data +N_CONNECT dest Address :183 source Address: 232 N_DATA transferring network data N_DATA transferring network data N_DISCONNECT Closed by Client -ATA transferring network data +N_CONNECT dest Address :84 source Address: 43 N_DATA transferring network data -N_DISCONNECT Closed by Client -ta N_DATA transferring network data +N_DISCONNECT Closed by Client +N_CONNECT dest Address :1 source Address: 11 N_DATA transferring network data + transferring network data N_DATA transferring network data N_DATA transferring network data N_DATA transferring network data diff --git a/INF1009/bin/Debug/s_ecr.txt b/INF1009/bin/Debug/s_ecr.txt index 6373969..72e8f27 100644 --- a/INF1009/bin/Debug/s_ecr.txt +++ b/INF1009/bin/Debug/s_ecr.txt @@ -1,14 +1,16 @@ -connection: 5 Connection established -connection: 5 dest Address: 1 source Address: 11 -connection: 3 Connection established -connection: 3 dest Address: 47 source Address: 15 -connection: 7 Connection established -connection: 7 disconnected Closed by Client +connection: 1 Connection established +connection: 1 dest Address: 1 source Address: 11 +connection: 6 Connection established +connection: 6 dest Address: 47 source Address: 15 +connection: 6 disconnected Closed by Client connection: 0 Connection established + + connection: 0 disconnected Closed by Client -lient -connection: 1 Connection established -connection: 1 disconnected Closed by Client +connection: 5 Connection established +connection: 5 disconnected Closed by Client +ient +: 0 disconnected Closed by Client connection: 2 Connection established connection: 2 dest Address: 58 source Address: 217 connection: 2 disconnected Closed by Client diff --git a/INF1009/obj/Debug/INF1009.exe b/INF1009/obj/Debug/INF1009.exe index 40844a5..c0dfdbd 100644 Binary files a/INF1009/obj/Debug/INF1009.exe and b/INF1009/obj/Debug/INF1009.exe differ diff --git a/INF1009/obj/Debug/INF1009.pdb b/INF1009/obj/Debug/INF1009.pdb index bfa485e..80b2b5b 100644 Binary files a/INF1009/obj/Debug/INF1009.pdb and b/INF1009/obj/Debug/INF1009.pdb differ