ClarkuCSCI / pydiode

Transfer data through a unidirectional network (i.e., a data diode)
MIT License
2 stars 0 forks source link

Meaningful Exit Codes #1

Closed peterstory closed 11 months ago

peterstory commented 11 months ago

pydiode should give a meaningful exit code, based on whether the data was received correctly.

For now, we'll compare a SHA-256 hash of the received data to a hash included in the EOF packets.

peterstory commented 11 months ago

Results in PEP paper:

docker compose exec python python3 -m diode.print_table --column redundancy \
experiments/diode.2023-07-03.1.csv
  Target (bits/sec)    redundancy      Successful    Duration (sec)
-------------------  ------------  --------------  ----------------
        100,000,000             1   99.8% of 1000       10.35±9E-03
        250,000,000             1   99.1% of 1000        4.25±1E-02
        500,000,000             1   96.1% of 1000        2.18±2E-02
        750,000,000             1   86.7% of 1000        1.52±8E-03
      1,000,000,000             1   81.8% of 1000        1.13±3E-03

        100,000,000             2  100.0% of 1000       20.49±1E-02
        250,000,000             2  100.0% of 1000        8.36±1E-02
        500,000,000             2  100.0% of 1000        4.28±3E-02
        750,000,000             2  100.0% of 1000        2.94±1E-02
      1,000,000,000             2  100.0% of 1000        2.17±2E-03

Results in this branch:

docker compose exec python python3 -m diode.print_table --column redundancy \
experiments/pydiode.2023-07-26.1.csv

  Target (bits/sec)    redundancy      Successful    Duration (sec)
-------------------  ------------  --------------  ----------------
        100,000,000             1  100.0% of 1000       10.54±3E-02
        250,000,000             1   99.8% of 1000        4.35±3E-02
        500,000,000             1   98.9% of 1000        2.27±2E-02
        750,000,000             1   97.7% of 1000        1.60±1E-02
      1,000,000,000             1   92.8% of 1000        1.21±8E-03

        100,000,000             2  100.0% of 1000       20.71±1E-02
        250,000,000             2  100.0% of 1000        8.45±3E-02
        500,000,000             2  100.0% of 1000        4.35±3E-02
        750,000,000             2  100.0% of 1000        3.02±2E-02
      1,000,000,000             2  100.0% of 1000        2.26±1E-02

This branch's code runs slightly slower, but is actually more reliable than the results in the PEP paper. Without retesting UDPcast and netcat, it isn't clear whether that's because of some external factor (e.g., reseating the ethernet cables). Still, should be safe to merge into main.

Also, the exit codes and error logging appear to be working correctly:

> grep "Transfer error" experiments/pydiode.2023-07-26.1.txt | head -n 3
WARNING:root:Transfer error for {'max_bitrate': 1000000000, 'fec': None, 'redundancy': 1, 'chunk_duration': None, 'chunk_max_packets': None}
WARNING:root:Transfer error for {'max_bitrate': 1000000000, 'fec': None, 'redundancy': 1, 'chunk_duration': None, 'chunk_max_packets': None}
WARNING:root:Transfer error for {'max_bitrate': 1000000000, 'fec': None, 'redundancy': 1, 'chunk_duration': None, 'chunk_max_packets': None}

> grep "exited with code 1" experiments/pydiode.2023-07-26.1.txt | head -n 3
WARNING:root:'read' exited with code 1 and stderr 'WARNING:root:Receieved data's digest != EOF's digest: 5d9c332f34886fd9b6ab0b6a70fe7c4bc686f10349b6850e125bf0fc8522b795 != 6b7b494a2a0f49f5c17ac9d6479ba2f43a0509f6c77f23c7ff8ddacdc0d46774'
WARNING:root:'read' exited with code 1 and stderr 'WARNING:root:Receieved data's digest != EOF's digest: aa34ff6135788ffc4db2ba933bae02215387e67e7b1454446ba1e73d91b144da != e70af43cb01bef5dffb968238795e04ffe74a57522f3e205e0fade04ccee5cc8'
WARNING:root:'read' exited with code 1 and stderr 'WARNING:root:Receieved data's digest != EOF's digest: 7c99b251c7a7fd5b9edde21dcc4c10ecba12a796b60167741dde379a9b70a0f2 != df4a1fce18a1dc076147321ffb426824f70cbf852a59f64582a8a587545c432d'

> grep "Transfer error" experiments/pydiode.2023-07-26.1.txt | wc -l
108

> grep "exited with code 1" experiments/pydiode.2023-07-26.1.txt | wc -l
108