Project

General

Profile

Actions

Task #2702

closed

ping: refactor for separate responsibility

Added by Junxiao Shi over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Start date:
Due date:
% Done:

100%

Estimated time:
6.00 h

Description

Refactor ndnping program to use the following structure:

           |------| -> Tracer
  Face  <- |      |
           | Ping | -> StatisticsCollector
Options -> |      |          |
           |      |          v
           |------| ->   printStatistics

  • An Options POD struct contains parameters parsed from command line.
  • Ping class constructor should take Face& and Options as argument; getter/setter for each option are deleted from the class.
  • Ping class shouldn't write to stdout directly; instead, it emits a signal for each successful/failed ping, and when all pings are completed.
  • A Tracer class connects to ping succeed/fail signals, and writes logs for each successful/failed ping.
  • A StatisticsCollector class connects to ping succeed/fail signals, and collects statistics.
  • A printStatistics function connects to completion signal, and prints statistics.

Benefits:

  • separate responsibility: Ping performs network operations, Tracer writes logs, StatisticsCollector collects statistics.
  • unit testing: passing DummyClientFace to Ping constructor allows unit testing.
  • simulation: Ping and StatisticsCollector can be reused in a ndnSIM scenario.

Related issues 1 (0 open1 closed)

Blocks ndn-tools - Feature #2796: Tests for Ping and PingServerClosedEric Newberry

Actions
Actions

Also available in: Atom PDF