Fixed burst mode timing problem by taking into account overhead
This commit is contained in:
parent
955be71082
commit
aae32eb510
@ -369,6 +369,7 @@ void PcapPort::PortTransmitter::run()
|
|||||||
|
|
||||||
const int kSyncTransmit = 1;
|
const int kSyncTransmit = 1;
|
||||||
int i;
|
int i;
|
||||||
|
long overHead = 0;
|
||||||
|
|
||||||
qDebug("sendQueueList_.size = %d", sendQueueList_.size());
|
qDebug("sendQueueList_.size = %d", sendQueueList_.size());
|
||||||
if (sendQueueList_.size() <= 0)
|
if (sendQueueList_.size() <= 0)
|
||||||
@ -378,11 +379,13 @@ void PcapPort::PortTransmitter::run()
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
_restart:
|
_restart:
|
||||||
ret = sendQueueTransmit(handle_, sendQueueList_.at(i), kSyncTransmit);
|
ret = sendQueueTransmit(handle_, sendQueueList_.at(i), overHead,
|
||||||
|
kSyncTransmit);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
qDebug("error %d in sendQueueTransmit()", ret);
|
qDebug("error %d in sendQueueTransmit()", ret);
|
||||||
|
qDebug("overHead = %ld", overHead);
|
||||||
stop_ = false;
|
stop_ = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -390,10 +393,17 @@ _restart:
|
|||||||
|
|
||||||
if (returnToQIdx_ >= 0)
|
if (returnToQIdx_ >= 0)
|
||||||
{
|
{
|
||||||
i = returnToQIdx_;
|
long usecs = loopDelay_ + overHead;
|
||||||
|
|
||||||
if (loopDelay_)
|
if (usecs > 0)
|
||||||
udelay(loopDelay_);
|
{
|
||||||
|
udelay(usecs);
|
||||||
|
overHead = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
overHead = usecs;
|
||||||
|
|
||||||
|
i = returnToQIdx_;
|
||||||
goto _restart;
|
goto _restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,7 +415,7 @@ void PcapPort::PortTransmitter::stop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PcapPort::PortTransmitter::sendQueueTransmit(pcap_t *p,
|
int PcapPort::PortTransmitter::sendQueueTransmit(pcap_t *p,
|
||||||
pcap_send_queue *queue, int sync)
|
pcap_send_queue *queue, long &overHead, int sync)
|
||||||
{
|
{
|
||||||
TimeStamp ovrStart, ovrEnd;
|
TimeStamp ovrStart, ovrEnd;
|
||||||
struct timeval ts;
|
struct timeval ts;
|
||||||
@ -427,9 +437,15 @@ int PcapPort::PortTransmitter::sendQueueTransmit(pcap_t *p,
|
|||||||
|
|
||||||
getTimeStamp(&ovrEnd);
|
getTimeStamp(&ovrEnd);
|
||||||
|
|
||||||
usec -= udiffTimeStamp(&ovrStart, &ovrEnd);
|
overHead -= udiffTimeStamp(&ovrStart, &ovrEnd);
|
||||||
|
usec += overHead;
|
||||||
if (usec > 0)
|
if (usec > 0)
|
||||||
|
{
|
||||||
udelay(usec);
|
udelay(usec);
|
||||||
|
overHead = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
overHead = usec;
|
||||||
|
|
||||||
ts = hdr->ts;
|
ts = hdr->ts;
|
||||||
getTimeStamp(&ovrStart);
|
getTimeStamp(&ovrStart);
|
||||||
@ -471,6 +487,8 @@ void PcapPort::PortTransmitter::udelay(long usec)
|
|||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
struct timeval delay, target, now;
|
struct timeval delay, target, now;
|
||||||
|
|
||||||
|
//qDebug("usec delay = %ld", usec);
|
||||||
|
|
||||||
delay.tv_sec = 0;
|
delay.tv_sec = 0;
|
||||||
delay.tv_usec = usec;
|
delay.tv_usec = usec;
|
||||||
|
|
||||||
|
@ -107,7 +107,8 @@ protected:
|
|||||||
void stop();
|
void stop();
|
||||||
private:
|
private:
|
||||||
void udelay(long usec);
|
void udelay(long usec);
|
||||||
int sendQueueTransmit(pcap_t *p, pcap_send_queue *queue, int sync);
|
int sendQueueTransmit(pcap_t *p, pcap_send_queue *queue, long &overHead,
|
||||||
|
int sync);
|
||||||
|
|
||||||
quint64 ticksFreq_;
|
quint64 ticksFreq_;
|
||||||
QList<pcap_send_queue*> sendQueueList_;
|
QList<pcap_send_queue*> sendQueueList_;
|
||||||
|
Loading…
Reference in New Issue
Block a user