Skip to content

Commit

Permalink
Add attacker packet ports to the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinna Adhikari committed Dec 6, 2020
1 parent 70c1102 commit eb7b6a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ <h2 class="text-white mb-4">DDD Filter applications in the Network</h2>

<div style="float:left; padding-top: 40px; padding-left: 30px;">
<p id="openPorts" style="color: white; text-align: left;"></p>
<p id="attackerPorts" style="color: white; text-align: left;"></p>
<p id="droppedPackets" style="color: white; text-align: left;"></p>
</div>

Expand Down
19 changes: 19 additions & 0 deletions js/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function createPackets(numPackets, originEntity, nPorts) {
let srcPort = 80;
for (let i = 0; i < numPackets; ++i) {
let dstPort = DDD.generatePort(nPorts);
console.log(dstPort);
let packetX = originEntity.x;
let packetY = originEntity.y;
let radius = 15;
Expand Down Expand Up @@ -115,6 +116,23 @@ function dashboardOpenPorts(ddd) {
}
document.getElementById("openPorts").textContent = "DDD Open Ports: " + printOut;
}

function dashboardAttackerPorts(packets) {
let printPorts = [];
for(let packet of packets){
printPorts.push(packet.dstPort);
}
var printOut = new String("");
for (let i = 0; i < printPorts.length; i++) {
if (i == printPorts.length - 1) {
printOut = printOut + " and " + printPorts[i];
} else {
printOut = printOut + printPorts[i] + ", "
}
}
document.getElementById("attackerPorts").textContent = "Attacker Packet Ports: " + printOut;
}

function dashboardDroppedPackets(garbage){
document.getElementById("droppedPackets").textContent = "Dropped Packets: " + garbage.droppedPackets;
}
Expand Down Expand Up @@ -172,6 +190,7 @@ async function startSimulation() {
let attacker = new Attacker(1500, y, server, packetsPerTimeUnit);
let packetsList = createPackets(totalPackets, attacker, nPorts);
attacker.queue = packetsList;
dashboardAttackerPorts(packetsList);

let systemEntities = [attacker, server, router, client, garbage];
if (dddState) {
Expand Down

0 comments on commit eb7b6a8

Please sign in to comment.