Skip to content

feat/coreNodeInterfaces #11

@David-A-T-M

Description

@David-A-T-M

Issue: Define Core Network Interfaces and Statistics Hierarchy

Description

Establish the foundational contracts for the simulation by defining the core interfaces for network nodes and their statistics. This architecture enables polymorphism, allowing the simulation engine to interact with any node type (Router, Terminal) through a unified API.

Technical Requirements

  • Location: All interfaces should be placed in the ar.edu.unc.david.routersimulator.model.nodes package (or a .stats sub-package for metrics).
  • Interface Composition:
    • PacketReceiver: Functional interface for objects that can accept packets.
    • Tickable: Interface for entities synchronized with the simulation clock.
    • Node: A composite interface extending both PacketReceiver and Tickable.
  • Statistics Strategy:
    • Use a base NodeStats interface for common metrics.
    • Implement specialized Record objects for TerminalStats and RouterStats to ensure immutability and thread-safety.

Tasks

  • Core Interfaces:
    • Create PacketReceiver.java with void receive(Packet p).
    • Create Tickable.java with void tick(long currentTick).
    • Create Node.java extending both, adding IpAddress ip() and NodeStats getStats().
  • Statistics Hierarchy:
    • Create NodeStats.java (Interface) with common getters: ip(), packetsSent(), packetsReceived(), packetsDropped().
    • Create TerminalStats.java (Record) implementing NodeStats with additional fields: pagesCompleted, pagesTimedOut.
    • Create RouterStats.java (Record) implementing NodeStats with additional fields: packetsRouted, bufferUtilization.

Acceptance Criteria

  • All public methods must have Javadoc for Checkstyle compliance.
  • Naming convention must follow "Record-style" (e.g., ip() instead of getIp()).
  • The project must compile successfully with empty implementations in Terminal and Router.
  • No logic should be present in the interfaces (pure contracts).

Architecture Preview

public interface Node extends PacketReceiver, Tickable {
    IpAddress ip();
    NodeStats getStats();
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions