diff --git a/.vs/INF1009/v15/.suo b/.vs/INF1009/v15/.suo index 1c95f8d..56ecb7d 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 0b3a71a..92aca49 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-shm b/.vs/INF1009/v15/Server/sqlite3/storage.ide-shm index f7e2767..22cf84c 100644 Binary files a/.vs/INF1009/v15/Server/sqlite3/storage.ide-shm and b/.vs/INF1009/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/INF1009/v15/Server/sqlite3/storage.ide-wal b/.vs/INF1009/v15/Server/sqlite3/storage.ide-wal index ba85774..b7eaa58 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 5713474..4b85c6d 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-shm b/.vs/INF1009/v15/sqlite3/storage.ide-shm index 683a822..baed4a7 100644 Binary files a/.vs/INF1009/v15/sqlite3/storage.ide-shm and b/.vs/INF1009/v15/sqlite3/storage.ide-shm differ diff --git a/.vs/INF1009/v15/sqlite3/storage.ide-wal b/.vs/INF1009/v15/sqlite3/storage.ide-wal index 4af3930..0321236 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 cb1c934..ef1da74 100644 --- a/INF1009/Form1.cs +++ b/INF1009/Form1.cs @@ -166,7 +166,7 @@ private void buttonTest_Click(object sender, EventArgs e) "N_DATA Start testing INF1009\n" + "N_DISCONNECT 1 11\n" + "N_CONNECT 47 15\n" + - "N_DATA negative Acknoledgment\n" + + "N_DATA negative Acknoledgment\n" + "N_DISCONNECT 47 15\n" + "N_CONNECT 200 27\n" + "N_DATA declined by Network\n" + @@ -175,7 +175,7 @@ private void buttonTest_Click(object sender, EventArgs e) "N_DATA declined by Network - no route\n" + "N_DISCONNECT 200 500\n" + "N_CONNECT 9 19\n" + - "N_DATA multiple of 19 - no awnser\n" + + "N_DATA no awnser\n" + "N_DISCONNECT 9 19\n" + "N_CONNECT 12 13\n" + "N_DATA multiple of 13 - connection declined by destination\n" + diff --git a/INF1009/Network.cs b/INF1009/Network.cs index 9e5d383..55db01c 100644 --- a/INF1009/Network.cs +++ b/INF1009/Network.cs @@ -86,44 +86,42 @@ public void transportWrite() byte[] received = (byte[])packetProcessing2Network.Dequeue(); PACKET receivedPacket = Packet.decapBytes(received); Npdu _4Transport = Packet.decapPacket(receivedPacket); - if (_4Transport.type == "WrongPacketFormat") - { - msg = "Wrong Packet Format"; - } - else if (_4Transport.type == "NACK") - { - msg = "NACK negative Acknowledgment :" + receivedPacket.packetType.ToString(); - rejected = true; - } - else if (_4Transport.type == "ACK") - { - msg = "ACK positive Acknowledgment :" + receivedPacket.packetType.ToString(); - accepted = true; - } - else if(_4Transport.type == "N_DISCONNECT.ind") - { - msg = "N_DISCONNECT " + _4Transport.target; - network2Transport.Enqueue(_4Transport); - accepted = true; - disconnected = true; - } - else if(_4Transport.type == "N_CONNECT.ind") - { - msg = "N_CONNECT dest Address :" + _4Transport.destAddr + " source Address: " + _4Transport.sourceAddr; - network2Transport.Enqueue(_4Transport); - accepted = true; - } - else if(_4Transport.type == "N_DATA.ind") + + switch (_4Transport.type) { - msg = "N_DATA transferring network data"; - receivedData += _4Transport.data; - if (!_4Transport.flag) - { + case "WrongPacketFormat": + msg = "Wrong Packet Format"; + break; + case "release": + msg = "released packet: " + receivedPacket.packetType.ToString(); + rejected = true; + break; + + case "N_DISCONNECT.ind": + msg = "N_DISCONNECT " + _4Transport.target; + network2Transport.Enqueue(_4Transport); + accepted = true; + disconnected = true; + break; + case "N_CONNECT.ind": + msg = "N_CONNECT dest Address :" + _4Transport.destAddr + " source Address: " + _4Transport.sourceAddr; + network2Transport.Enqueue(_4Transport); + accepted = true; + break; + case "N_DATA.ind": + msg = "N_DATA transferring network data"; + receivedData += _4Transport.data; + if (!_4Transport.flag) + { _4Transport.data = receivedData; network2Transport.Enqueue(_4Transport); - } + } + break; + default: + break; } + write2Transport.WriteLine(msg); Form1._UI.write2L_ecr(msg); } @@ -227,9 +225,8 @@ public void transportRead() npdu2Transport.connection = outputNo[0].ToString(); network2Transport.Enqueue(npdu2Transport); - packet4Processing = Packet.encapsulateRequest(outputNo[0], sourceAddr[0], destAddr[0]); - string packetType = "request"; - byte[] sending = Packet.encapsulateBytes(packet4Processing, packetType); + packet4Processing = Packet.encapsulateRequest(outputNo[0], sourceAddr[0], destAddr[0]); + byte[] sending = Packet.encapsulateBytes(packet4Processing, "request"); sentCount = 0; rejected = false; diff --git a/INF1009/Packet.cs b/INF1009/Packet.cs index e5ef65e..b7c3ae0 100644 --- a/INF1009/Packet.cs +++ b/INF1009/Packet.cs @@ -224,6 +224,11 @@ public static byte[] encapsulateBytes(PACKET currentPacket, string type) sending[0] = currentPacket.connectionNumber; sending[1] = currentPacket.target; break; + case "NACK": + sending = new byte[2]; + sending[0] = currentPacket.connectionNumber; + sending[1] = currentPacket.target ; + break; default: sending = new byte[0]; break; diff --git a/INF1009/Processing.cs b/INF1009/Processing.cs index 1b71332..16a75b5 100644 --- a/INF1009/Processing.cs +++ b/INF1009/Processing.cs @@ -72,8 +72,8 @@ public void networkRead() BitArray defectBits = new BitArray(new byte[] { defect }); byte temp = Packet.ConvertToByte(ps); - BitArray leps = new BitArray(new byte[] { temp }); - if (Packet.isEqualBitArrays(defectBits, leps)) + BitArray current = new BitArray(new byte[] { temp }); + if (Packet.isEqualBitArrays(defectBits, current)) { returnPacket = Packet.encapsulateAcknowledge(packetFromNetwork[0], Packet.ConvertToByte(pr), false); packet2Network = Packet.encapsulateBytes(returnPacket, "NACK"); @@ -90,7 +90,7 @@ public void networkRead() else { returnPacket = Packet.encapsulateAcknowledge(packetFromNetwork[0], Packet.ConvertToByte(pr), false); - packet2Network = Packet.encapsulateBytes(returnPacket, "NACK"); + packet2Network = Packet.encapsulateBytes(returnPacket, "release"); packetProcessing2Network.Enqueue(packet2Network); } @@ -113,6 +113,13 @@ public void networkRead() packetProcessing2Network.Enqueue(packet2Network); } + else + { + returnPacket = Packet.encapsulateRelease(packetFromNetwork[0], packetFromNetwork[2], packetFromNetwork[3], true); + packet2Network = Packet.encapsulateBytes(returnPacket, "release"); + + packetProcessing2Network.Enqueue(packet2Network); + } } else if (packetFromNetwork.Length == 5) { diff --git a/INF1009/bin/Debug/INF1009.exe b/INF1009/bin/Debug/INF1009.exe index c0dfdbd..4d5b027 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 80b2b5b..640a874 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 793d6c7..f8313f0 100644 --- a/INF1009/bin/Debug/l_ecr.txt +++ b/INF1009/bin/Debug/l_ecr.txt @@ -1,22 +1,19 @@ N_CONNECT 1 11 route:1 N_DATA Start testing INF1009 +N_DISCONNECT 1 N_CONNECT 47 15 route:47 N_DATA negative Acknoledgment 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 - 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_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 ... +uhaime for the course INF1009 ... N_DISCONNECT 58 -N_CONNECT 118 207 route:252 +_DISCONNECT 58 + 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 diff --git a/INF1009/bin/Debug/l_lec.txt b/INF1009/bin/Debug/l_lec.txt index a804dbd..d4f1a79 100644 --- a/INF1009/bin/Debug/l_lec.txt +++ b/INF1009/bin/Debug/l_lec.txt @@ -1,22 +1,24 @@ N_CONNECT dest Address :1 source Address: 11 N_DATA transferring network data +N_DATA transferring network data +N_DISCONNECT Closed by Client 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 -data +N_CONNECT dest Address :58 source Address: 217 +ONNECT Closed by Client + by Client +SCONNECT Closed by Client N_DISCONNECT Closed by Client -N_CONNECT dest Address :248 source Address: 88 +network data +NACK negative Acknowledgment :255 N_DATA transferring network data N_DATA transferring network data -N_DISCONNECT Closed by Client -N_CONNECT dest Address :183 source Address: 232 N_DATA transferring network data N_DATA transferring network data N_DISCONNECT Closed by Client -N_CONNECT dest Address :84 source Address: 43 +:84 source Address: 43 N_DATA transferring network data N_DATA transferring network data N_DISCONNECT Closed by Client diff --git a/INF1009/bin/Debug/s_ecr.txt b/INF1009/bin/Debug/s_ecr.txt index 72e8f27..345d489 100644 --- a/INF1009/bin/Debug/s_ecr.txt +++ b/INF1009/bin/Debug/s_ecr.txt @@ -1,18 +1,15 @@ -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: 7 Connection established +connection: 7 dest Address: 1 source Address: 11 +connection: 7 disconnected Closed by Client connection: 0 Connection established - - +connection: 0 dest Address: 47 source Address: 15 connection: 0 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: 1 Connection established +connection: 1 disconnected Closed by Client +connection: 4 Connection established +connection: 4 disconnected Closed by Client +connection: 0 Connection established +connection: 0 dest Address: 58 source Address: 217 connection: 2 disconnected Closed by Client e Address: 246 connection: 1 disconnected Closed by Client diff --git a/INF1009/bin/Debug/s_lec.txt b/INF1009/bin/Debug/s_lec.txt index 88d5ace..aa51942 100644 --- a/INF1009/bin/Debug/s_lec.txt +++ b/INF1009/bin/Debug/s_lec.txt @@ -11,7 +11,7 @@ N_CONNECT 200 500 N_DATA declined by Network - no route N_DISCONNECT 200 500 N_CONNECT 9 19 -N_DATA multiple of 19 - no awnser +N_DATA no awnser N_DISCONNECT 9 19 N_CONNECT 12 13 N_DATA multiple of 13 - connection declined by destination diff --git a/INF1009/obj/Debug/INF1009.exe b/INF1009/obj/Debug/INF1009.exe index c0dfdbd..4d5b027 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 80b2b5b..640a874 100644 Binary files a/INF1009/obj/Debug/INF1009.pdb and b/INF1009/obj/Debug/INF1009.pdb differ diff --git a/INF1009_rapport.pdf b/INF1009_rapport.pdf new file mode 100644 index 0000000..98e3f9a Binary files /dev/null and b/INF1009_rapport.pdf differ