comment wrap
This commit is contained in:
parent
cc7dcc0225
commit
752d0d5a4a
@ -46,7 +46,7 @@ void StreamReassembler::push_substring(const string &data, const size_t index, c
|
||||
// watch out for fetching front from an empty queue
|
||||
wr_data.push_back(_aux_buffer.front());
|
||||
_aux_buffer.pop_front();
|
||||
_aux_buffer_valid.pop_front(); // remember to pop assistent queue
|
||||
_aux_buffer_valid.pop_front(); // remember to pop assistent queue
|
||||
++_unassem;
|
||||
--_unassem_count;
|
||||
}
|
||||
@ -54,7 +54,7 @@ void StreamReassembler::push_substring(const string &data, const size_t index, c
|
||||
_output.write(wr_data);
|
||||
}
|
||||
if (_unassem == _eof) {
|
||||
_output.end_input(); // stream approached to eof
|
||||
_output.end_input(); // stream approached to eof
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,13 +13,13 @@ class StreamReassembler {
|
||||
private:
|
||||
// Your code here -- add private members as necessary.
|
||||
|
||||
ByteStream _output; //!< The reassembled in-order byte stream
|
||||
size_t _capacity{}; //!< The maximum number of bytes
|
||||
size_t _unassem{}; //!< The index (in the stream) of the first unassembled byte
|
||||
size_t _unassem_count{}; //!< Keep the number of unassembled bytes
|
||||
std::deque<char> _aux_buffer; //!< auxiliary storage, initially allocated _capacity bytes
|
||||
std::deque<bool> _aux_buffer_valid; //!< indicate whether the bit in _aux_buffer is filled with a valid byte
|
||||
size_t _eof{static_cast<size_t>(-1)}; //!< indicate the eof byte's index in stream
|
||||
ByteStream _output; //!< The reassembled in-order byte stream
|
||||
size_t _capacity{}; //!< The maximum number of bytes
|
||||
size_t _unassem{}; //!< The index (in the stream) of the first unassembled byte
|
||||
size_t _unassem_count{}; //!< Keep the number of unassembled bytes
|
||||
std::deque<char> _aux_buffer; //!< auxiliary storage, initially allocated _capacity bytes
|
||||
std::deque<bool> _aux_buffer_valid; //!< indicate whether the bit in _aux_buffer is filled with a valid byte
|
||||
size_t _eof{static_cast<size_t>(-1)}; //!< indicate the eof byte's index in stream
|
||||
|
||||
public:
|
||||
//! \brief Construct a `StreamReassembler` that will store up to `capacity` bytes.
|
||||
|
||||
@ -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 {}; }
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user