comment wrap

This commit is contained in:
ridethepig 2023-02-16 05:08:25 +00:00
parent cc7dcc0225
commit 752d0d5a4a
5 changed files with 18 additions and 16 deletions

View File

@ -6,13 +6,11 @@
// automated checks run by `make check_lab2`.
template <typename... Targs>
void DUMMY_CODE(Targs &&... /* unused */) {}
void DUMMY_CODE(Targs &&.../* unused */) {}
using namespace std;
void TCPReceiver::segment_received(const TCPSegment &seg) {
DUMMY_CODE(seg);
}
void TCPReceiver::segment_received(const TCPSegment &seg) { DUMMY_CODE(seg); }
optional<WrappingInt32> TCPReceiver::ackno() const { return {}; }

View File

@ -19,6 +19,9 @@ class TCPReceiver {
//! The maximum number of bytes we'll store.
size_t _capacity;
WrappingInt32 _seqno{0};
WrappingInt32 _ackno{0};
bool _is_start{};
public:
//! \brief Construct a TCP receiver

View File

@ -6,7 +6,7 @@
// automated checks run by `make check_lab2`.
template <typename... Targs>
void DUMMY_CODE(Targs &&... /* unused */) {}
void DUMMY_CODE(Targs &&.../* unused */) {}
using namespace std;
@ -30,13 +30,14 @@ WrappingInt32 wrap(uint64_t n, WrappingInt32 isn) {
//! has a different ISN.
#define MODULO (1UL << 32)
uint64_t unwrap(WrappingInt32 n, WrappingInt32 isn, uint64_t checkpoint) {
// well, really ulgy impl
// have to make sure that no overflow happens
uint64_t tmp = static_cast<uint64_t>(n.raw_value() - isn.raw_value());
tmp += (checkpoint >> 32) << 32;
if (tmp > checkpoint) {
if (tmp < MODULO || tmp - checkpoint < checkpoint - (tmp - MODULO)) {
return tmp;
}
else {
} else {
return tmp - MODULO;
}
} else {