Inter-packet and Inter-burst gaps are now calculated in nanosecond rather than milliseconds. However, the actual delay is still in milliseconds for all OS as of now.
Fixes issue 30
This commit is contained in:
parent
670920afa6
commit
b3bc9e36a7
@ -116,7 +116,7 @@ void AbstractPort::updatePacketList()
|
|||||||
int len;
|
int len;
|
||||||
bool isVariable;
|
bool isVariable;
|
||||||
long sec = 0;
|
long sec = 0;
|
||||||
long usec = 0;
|
long nsec = 0;
|
||||||
|
|
||||||
qDebug("In %s", __FUNCTION__);
|
qDebug("In %s", __FUNCTION__);
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ void AbstractPort::updatePacketList()
|
|||||||
numPackets = streamList_[i]->burstSize();
|
numPackets = streamList_[i]->burstSize();
|
||||||
if (streamList_[i]->burstRate() > 0)
|
if (streamList_[i]->burstRate() > 0)
|
||||||
{
|
{
|
||||||
ibg = 1e6/double(streamList_[i]->burstRate());
|
ibg = 1e9/double(streamList_[i]->burstRate());
|
||||||
ibg1 = ceil(ibg);
|
ibg1 = ceil(ibg);
|
||||||
ibg2 = floor(ibg);
|
ibg2 = floor(ibg);
|
||||||
nb1 = long((ibg - double(ibg2)) * double(numBursts));
|
nb1 = long((ibg - double(ibg2)) * double(numBursts));
|
||||||
@ -156,7 +156,7 @@ void AbstractPort::updatePacketList()
|
|||||||
numPackets = streamList_[i]->numPackets();
|
numPackets = streamList_[i]->numPackets();
|
||||||
if (streamList_[i]->packetRate() > 0)
|
if (streamList_[i]->packetRate() > 0)
|
||||||
{
|
{
|
||||||
ipg = 1e6/double(streamList_[i]->packetRate());
|
ipg = 1e9/double(streamList_[i]->packetRate());
|
||||||
ipg1 = ceil(ipg);
|
ipg1 = ceil(ipg);
|
||||||
ipg2 = floor(ipg);
|
ipg2 = floor(ipg);
|
||||||
np1 = long((ipg - double(ipg2)) * double(numPackets));
|
np1 = long((ipg - double(ipg2)) * double(numPackets));
|
||||||
@ -198,24 +198,24 @@ void AbstractPort::updatePacketList()
|
|||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
qDebug("q(%d, %d, %d) sec = %lu usec = %lu",
|
qDebug("q(%d, %d, %d) sec = %lu nsec = %lu",
|
||||||
i, j, k, sec, usec);
|
i, j, k, sec, nsec);
|
||||||
|
|
||||||
appendToPacketList(sec, usec, pktBuf_, len);
|
appendToPacketList(sec, nsec, pktBuf_, len);
|
||||||
|
|
||||||
usec += (k < np1) ? ipg1 : ipg2;
|
nsec += (k < np1) ? ipg1 : ipg2;
|
||||||
while (usec >= 1000000)
|
while (nsec >= 1e9)
|
||||||
{
|
{
|
||||||
sec++;
|
sec++;
|
||||||
usec -= 1000000;
|
nsec -= 1e9;
|
||||||
}
|
}
|
||||||
} // for (numPackets)
|
} // for (numPackets)
|
||||||
|
|
||||||
usec += (j < nb1) ? ibg1 : ibg2;
|
nsec += (j < nb1) ? ibg1 : ibg2;
|
||||||
while (usec >= 1000000)
|
while (nsec >= 1e9)
|
||||||
{
|
{
|
||||||
sec++;
|
sec++;
|
||||||
usec -= 1000000;
|
nsec -= 1e9;
|
||||||
}
|
}
|
||||||
} // for (numBursts)
|
} // for (numBursts)
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ public:
|
|||||||
void setDirty() { isSendQueueDirty_ = true; }
|
void setDirty() { isSendQueueDirty_ = true; }
|
||||||
|
|
||||||
virtual void clearPacketList() = 0;
|
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;
|
int length) = 0;
|
||||||
virtual void setPacketListLoopMode(bool loop, long usecDelay) = 0;
|
virtual void setPacketListLoopMode(bool loop, long nsecDelay) = 0;
|
||||||
void updatePacketList();
|
void updatePacketList();
|
||||||
|
|
||||||
virtual void startTransmit() = 0;
|
virtual void startTransmit() = 0;
|
||||||
|
@ -298,7 +298,7 @@ void PcapPort::PortTransmitter::clearPacketList()
|
|||||||
setPacketListLoopMode(false, 0);
|
setPacketListLoopMode(false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PcapPort::PortTransmitter::appendToPacketList(long sec, long usec,
|
bool PcapPort::PortTransmitter::appendToPacketList(long sec, long nsec,
|
||||||
const uchar *packet, int length)
|
const uchar *packet, int length)
|
||||||
{
|
{
|
||||||
bool op = true;
|
bool op = true;
|
||||||
@ -307,7 +307,7 @@ bool PcapPort::PortTransmitter::appendToPacketList(long sec, long usec,
|
|||||||
|
|
||||||
pktHdr.caplen = pktHdr.len = length;
|
pktHdr.caplen = pktHdr.len = length;
|
||||||
pktHdr.ts.tv_sec = sec;
|
pktHdr.ts.tv_sec = sec;
|
||||||
pktHdr.ts.tv_usec = usec;
|
pktHdr.ts.tv_usec = nsec/1000;
|
||||||
|
|
||||||
sendQ = sendQueueList_.isEmpty() ? NULL : sendQueueList_.last();
|
sendQ = sendQueueList_.isEmpty() ? NULL : sendQueueList_.last();
|
||||||
|
|
||||||
|
@ -42,12 +42,12 @@ public:
|
|||||||
transmitter_->clearPacketList();
|
transmitter_->clearPacketList();
|
||||||
setPacketListLoopMode(false, 0);
|
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) {
|
int length) {
|
||||||
return transmitter_->appendToPacketList(sec, usec, packet, length);
|
return transmitter_->appendToPacketList(sec, nsec, packet, length);
|
||||||
}
|
}
|
||||||
virtual void setPacketListLoopMode(bool loop, long usecDelay) {
|
virtual void setPacketListLoopMode(bool loop, long nsecDelay) {
|
||||||
transmitter_->setPacketListLoopMode(loop, usecDelay);
|
transmitter_->setPacketListLoopMode(loop, nsecDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void startTransmit() {
|
virtual void startTransmit() {
|
||||||
@ -97,9 +97,9 @@ protected:
|
|||||||
void clearPacketList();
|
void clearPacketList();
|
||||||
bool appendToPacketList(long sec, long usec, const uchar *packet,
|
bool appendToPacketList(long sec, long usec, const uchar *packet,
|
||||||
int length);
|
int length);
|
||||||
void setPacketListLoopMode(bool loop, long usecDelay) {
|
void setPacketListLoopMode(bool loop, long nsecDelay) {
|
||||||
returnToQIdx_ = loop ? 0 : -1;
|
returnToQIdx_ = loop ? 0 : -1;
|
||||||
loopDelay_ = usecDelay;
|
loopDelay_ = nsecDelay/1000;
|
||||||
}
|
}
|
||||||
void setHandle(pcap_t *handle);
|
void setHandle(pcap_t *handle);
|
||||||
void useExternalStats(AbstractPort::PortStats *stats);
|
void useExternalStats(AbstractPort::PortStats *stats);
|
||||||
|
Loading…
Reference in New Issue
Block a user