diff --git a/server/abstractport.cpp b/server/abstractport.cpp index 252f4b5..193a480 100644 --- a/server/abstractport.cpp +++ b/server/abstractport.cpp @@ -116,7 +116,7 @@ void AbstractPort::updatePacketList() int len; bool isVariable; long sec = 0; - long usec = 0; + long nsec = 0; qDebug("In %s", __FUNCTION__); @@ -144,7 +144,7 @@ void AbstractPort::updatePacketList() numPackets = streamList_[i]->burstSize(); if (streamList_[i]->burstRate() > 0) { - ibg = 1e6/double(streamList_[i]->burstRate()); + ibg = 1e9/double(streamList_[i]->burstRate()); ibg1 = ceil(ibg); ibg2 = floor(ibg); nb1 = long((ibg - double(ibg2)) * double(numBursts)); @@ -156,7 +156,7 @@ void AbstractPort::updatePacketList() numPackets = streamList_[i]->numPackets(); if (streamList_[i]->packetRate() > 0) { - ipg = 1e6/double(streamList_[i]->packetRate()); + ipg = 1e9/double(streamList_[i]->packetRate()); ipg1 = ceil(ipg); ipg2 = floor(ipg); np1 = long((ipg - double(ipg2)) * double(numPackets)); @@ -198,24 +198,24 @@ void AbstractPort::updatePacketList() if (len <= 0) continue; - qDebug("q(%d, %d, %d) sec = %lu usec = %lu", - i, j, k, sec, usec); + qDebug("q(%d, %d, %d) sec = %lu nsec = %lu", + i, j, k, sec, nsec); - appendToPacketList(sec, usec, pktBuf_, len); + appendToPacketList(sec, nsec, pktBuf_, len); - usec += (k < np1) ? ipg1 : ipg2; - while (usec >= 1000000) + nsec += (k < np1) ? ipg1 : ipg2; + while (nsec >= 1e9) { sec++; - usec -= 1000000; + nsec -= 1e9; } } // for (numPackets) - usec += (j < nb1) ? ibg1 : ibg2; - while (usec >= 1000000) + nsec += (j < nb1) ? ibg1 : ibg2; + while (nsec >= 1e9) { sec++; - usec -= 1000000; + nsec -= 1e9; } } // for (numBursts) diff --git a/server/abstractport.h b/server/abstractport.h index 954014f..18d0b1e 100644 --- a/server/abstractport.h +++ b/server/abstractport.h @@ -71,9 +71,9 @@ public: void setDirty() { isSendQueueDirty_ = true; } virtual void clearPacketList() = 0; - virtual bool appendToPacketList(long sec, long usec, const uchar *packet, + virtual bool appendToPacketList(long sec, long nsec, const uchar *packet, int length) = 0; - virtual void setPacketListLoopMode(bool loop, long usecDelay) = 0; + virtual void setPacketListLoopMode(bool loop, long nsecDelay) = 0; void updatePacketList(); virtual void startTransmit() = 0; diff --git a/server/pcapport.cpp b/server/pcapport.cpp index c92eae8..fba37e1 100644 --- a/server/pcapport.cpp +++ b/server/pcapport.cpp @@ -298,7 +298,7 @@ void PcapPort::PortTransmitter::clearPacketList() setPacketListLoopMode(false, 0); } -bool PcapPort::PortTransmitter::appendToPacketList(long sec, long usec, +bool PcapPort::PortTransmitter::appendToPacketList(long sec, long nsec, const uchar *packet, int length) { bool op = true; @@ -307,7 +307,7 @@ bool PcapPort::PortTransmitter::appendToPacketList(long sec, long usec, pktHdr.caplen = pktHdr.len = length; pktHdr.ts.tv_sec = sec; - pktHdr.ts.tv_usec = usec; + pktHdr.ts.tv_usec = nsec/1000; sendQ = sendQueueList_.isEmpty() ? NULL : sendQueueList_.last(); diff --git a/server/pcapport.h b/server/pcapport.h index f5acfda..53e5867 100644 --- a/server/pcapport.h +++ b/server/pcapport.h @@ -42,12 +42,12 @@ public: transmitter_->clearPacketList(); setPacketListLoopMode(false, 0); } - virtual bool appendToPacketList(long sec, long usec, const uchar *packet, + virtual bool appendToPacketList(long sec, long nsec, const uchar *packet, int length) { - return transmitter_->appendToPacketList(sec, usec, packet, length); + return transmitter_->appendToPacketList(sec, nsec, packet, length); } - virtual void setPacketListLoopMode(bool loop, long usecDelay) { - transmitter_->setPacketListLoopMode(loop, usecDelay); + virtual void setPacketListLoopMode(bool loop, long nsecDelay) { + transmitter_->setPacketListLoopMode(loop, nsecDelay); } virtual void startTransmit() { @@ -97,9 +97,9 @@ protected: void clearPacketList(); bool appendToPacketList(long sec, long usec, const uchar *packet, int length); - void setPacketListLoopMode(bool loop, long usecDelay) { + void setPacketListLoopMode(bool loop, long nsecDelay) { returnToQIdx_ = loop ? 0 : -1; - loopDelay_ = usecDelay; + loopDelay_ = nsecDelay/1000; } void setHandle(pcap_t *handle); void useExternalStats(AbstractPort::PortStats *stats);