Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickduhaime committed May 1, 2018
1 parent fdf83c0 commit 1738d3b
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 71 deletions.
Binary file modified .vs/INF1009/v15/.suo
Binary file not shown.
Binary file modified .vs/INF1009/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified .vs/INF1009/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified .vs/INF1009/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
Binary file modified .vs/INF1009/v15/sqlite3/storage.ide
Binary file not shown.
Binary file modified .vs/INF1009/v15/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified .vs/INF1009/v15/sqlite3/storage.ide-wal
Binary file not shown.
4 changes: 2 additions & 2 deletions INF1009/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand All @@ -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" +
Expand Down
69 changes: 33 additions & 36 deletions INF1009/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions INF1009/Packet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions INF1009/Processing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
}

Expand All @@ -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)
{
Expand Down
Binary file modified INF1009/bin/Debug/INF1009.exe
Binary file not shown.
Binary file modified INF1009/bin/Debug/INF1009.pdb
Binary file not shown.
15 changes: 6 additions & 9 deletions INF1009/bin/Debug/l_ecr.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 9 additions & 7 deletions INF1009/bin/Debug/l_lec.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 10 additions & 13 deletions INF1009/bin/Debug/s_ecr.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion INF1009/bin/Debug/s_lec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified INF1009/obj/Debug/INF1009.exe
Binary file not shown.
Binary file modified INF1009/obj/Debug/INF1009.pdb
Binary file not shown.
Binary file added INF1009_rapport.pdf
Binary file not shown.

0 comments on commit 1738d3b

Please sign in to comment.