예제 #1
0
CbfPacketBuffer::packet_list CbfPacketBuffer::packets_to_send(Timestamp now)
{
    packet_list packets;

    // move all packets with expired timeout
    for (auto it = m_nodes.begin(); it != m_nodes.end();) {
        packet_type& packet = std::get<0>(*it);
        CbfPacketMetaData& meta = std::get<1>(*it);
        assert(packet.pdu);
        if (!now.before(meta.timer_expiry())) {
            units::Duration lifetime = packet.pdu->basic().lifetime.decode();
            units::Duration queuetime { now - meta.buffered_since() };
            m_stored -= length(packet);
            if (queuetime < lifetime) {
                packet.pdu->basic().lifetime.encode(lifetime - queuetime);
                packets.push_back(std::move(packet));
            }

            it = m_nodes.erase(it);
        } else {
            ++it;
        }
    }

    return packets;
}
예제 #2
0
파일: delay.cpp 프로젝트: CalSPEED/iPerf
void delay_loop( unsigned long usec ) {
    Timestamp end;
    end.add( usec * 1e-6 );

    Timestamp now;
    while ( now.before( end ) ) {
        now.setnow();
    }
}
예제 #3
0
void CbfPacketMetaData::set_timeout(units::Duration timeout, Timestamp now)
{
    assert(!now.before(m_buffered_since));
    m_timer_expiry = now + Timestamp::duration_type(timeout);
}