uni-tue-kn / p4-source-protection

Source code for the p4 based implementations of the mechanisms presented in "P4 In-Network Source Protection for SensorFail-Over"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Explicitly setting primary port status to avoid overflow error in `Protect.p4` for robustness

GreenieQwQ opened this issue · comments

The time-based mechanism introduced in the paper is like:
image
and the current implementation in Protect.p4 is

 apply {
    period.apply();
    port_config.apply();
    bit<1> accepted = 0;
    bit<48> time = standard_metadata.ingress_global_timestamp;
    if(standard_metadata.ingress_port == meta.primary) {
      last_primary.write(0, time);
      accepted = 1;
    }
    else if(standard_metadata.ingress_port == meta.secondary) {
      bit<48> last;
      last_primary.read(last, 0);
      if((time - last) > meta.period) {
        accepted = 1;
      }
    }
      meta.accepted = accepted;
    }
}

Ideally, if primary is down, packets from secondary port will be unconditionally accepted even if (time - last) <= meta.period occurs (e.g., register last approaches $2^{48}$ and standard_metadata.ingress_global_timestamp overflows). Explicitly setting the primary status register, as depicted in the diagram, would prevent the overflow error.