Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ repositories {
dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.mockito:mockito-junit-jupiter:5.11.0")
testImplementation("org.mockito:mockito-core:5.11.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("org.jetbrains:annotations:24.0.0")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ar.edu.unc.david.routersimulator.model.nodes;

import ar.edu.unc.david.routersimulator.model.IpAddress;
import ar.edu.unc.david.routersimulator.model.stats.Stats;

/**
* A node in the simulated network — either a {@link Router} or a {@link Terminal}.
*
* <p>Every node has an IP, can receive packets, advances per tick, and reports a common {@link
* Stats} snapshot. Node-specific stats are available by casting to {@link TerminalStats} or {@link
* RouterStats}.
*/
public interface NetworkNode extends PacketReceiver, Tickable {
IpAddress ip();

Stats collectStats();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ar.edu.unc.david.routersimulator.model.nodes;

import ar.edu.unc.david.routersimulator.model.Packet;

/** Any entity that accepts incoming {@link Packet}s into an input buffer. */
public interface PacketReceiver {
boolean receivePacket(Packet packet);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ar.edu.unc.david.routersimulator.model.nodes;

/**
* Represents an entity that can be processed or updated in discrete time intervals or "ticks".
* Implementing classes define specific behavior to be executed during each tick.
*/
public interface Tickable {
void tick(long currentTick);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ar.edu.unc.david.routersimulator.model.stats;

import ar.edu.unc.david.routersimulator.model.IpAddress;

/**
* A common interface for stats snapshots from both {@link Router}s and {@link Terminal}s, to be
* used in the UI and elsewhere when only the common fields are relevant.
*/
public interface Stats {
IpAddress ip();

long packetsReceived();
}