Enhancements
- (Abs/Pcap/WinPcap)Port: Inter SendQueue Timing implemented using a dummy packet length of zero (this is not supported by the winpcap pcap_sendqueue_transmit() but since we don't use that API we are not affected) - (Abs/Pcap/WinPcap)Port: Loop Mode Timing across loop iterations implemented - Added the year 2010 to Copyright notice in the About dialog Fixes - (Win)PcapPort: Fixed the wrong rates when packets sent in 'burst' mode
This commit is contained in:
parent
c97ae3bc55
commit
78a2de040b
@ -51,7 +51,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Copyright (c) 2007-2009 Srivats P.</string>
|
<string>Copyright (c) 2007-2010 Srivats P.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment" >
|
<property name="alignment" >
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
|
@ -73,22 +73,18 @@ void AbstractPort::updatePacketList()
|
|||||||
int len;
|
int len;
|
||||||
bool isVariable;
|
bool isVariable;
|
||||||
uchar pktBuf[2000];
|
uchar pktBuf[2000];
|
||||||
long sec;
|
long sec = 0;
|
||||||
long usec;
|
long usec = 0;
|
||||||
|
|
||||||
qDebug("In %s", __FUNCTION__);
|
qDebug("In %s", __FUNCTION__);
|
||||||
|
|
||||||
clearPacketList();
|
|
||||||
//returnToQIdx = -1;
|
|
||||||
|
|
||||||
// First sort the streams by ordinalValue
|
// First sort the streams by ordinalValue
|
||||||
qSort(streamList_);
|
qSort(streamList_);
|
||||||
|
|
||||||
sec = 0;
|
clearPacketList();
|
||||||
usec = 0;
|
|
||||||
for (int i = 0; i < streamList_.size(); i++)
|
for (int i = 0; i < streamList_.size(); i++)
|
||||||
{
|
{
|
||||||
//_restart:
|
|
||||||
if (streamList_[i]->isEnabled())
|
if (streamList_[i]->isEnabled())
|
||||||
{
|
{
|
||||||
long numPackets, numBursts;
|
long numPackets, numBursts;
|
||||||
@ -139,18 +135,17 @@ void AbstractPort::updatePacketList()
|
|||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
qDebug("q(%d, %d, %d) sec = %lu usec = %lu",
|
||||||
|
i, j, k, sec, usec);
|
||||||
|
|
||||||
|
appendToPacketList(sec, usec, pktBuf, len);
|
||||||
|
|
||||||
usec += ipg;
|
usec += ipg;
|
||||||
if (usec > 1000000)
|
if (usec > 1000000)
|
||||||
{
|
{
|
||||||
sec++;
|
sec++;
|
||||||
usec -= 1000000;
|
usec -= 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("q(%d, %d, %d) sec = %lu usec = %lu",
|
|
||||||
i, j, k, sec, usec);
|
|
||||||
|
|
||||||
appendToPacketList(sec, usec, pktBuf, len);
|
|
||||||
|
|
||||||
} // for (numPackets)
|
} // for (numPackets)
|
||||||
|
|
||||||
usec += ibg;
|
usec += ibg;
|
||||||
@ -179,7 +174,8 @@ void AbstractPort::updatePacketList()
|
|||||||
returnToQIdx = 0;
|
returnToQIdx = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
setPacketListLoopMode(true);
|
setPacketListLoopMode(true, streamList_[i]->sendUnit() ==
|
||||||
|
OstProto::StreamControl::e_su_bursts ? ibg : ipg);
|
||||||
goto _stop_no_more_pkts;
|
goto _stop_no_more_pkts;
|
||||||
|
|
||||||
case ::OstProto::StreamControl::e_nw_goto_next:
|
case ::OstProto::StreamControl::e_nw_goto_next:
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
virtual void clearPacketList() = 0;
|
virtual void clearPacketList() = 0;
|
||||||
virtual bool appendToPacketList(long sec, long usec, const uchar *packet,
|
virtual bool appendToPacketList(long sec, long usec, const uchar *packet,
|
||||||
int length) = 0;
|
int length) = 0;
|
||||||
virtual void setPacketListLoopMode(bool loop) = 0;
|
virtual void setPacketListLoopMode(bool loop, long usecDelay) = 0;
|
||||||
void updatePacketList();
|
void updatePacketList();
|
||||||
|
|
||||||
virtual void startTransmit() = 0;
|
virtual void startTransmit() = 0;
|
||||||
|
@ -177,6 +177,7 @@ PcapPort::PortTransmitter::PortTransmitter(const char *device)
|
|||||||
"This Win32 platform does not support performance counter");
|
"This Win32 platform does not support performance counter");
|
||||||
#endif
|
#endif
|
||||||
returnToQIdx_ = -1;
|
returnToQIdx_ = -1;
|
||||||
|
loopDelay_ = 0;
|
||||||
stop_ = false;
|
stop_ = false;
|
||||||
stats_ = new AbstractPort::PortStats;
|
stats_ = new AbstractPort::PortStats;
|
||||||
usingInternalStats_ = true;
|
usingInternalStats_ = true;
|
||||||
@ -210,6 +211,7 @@ void PcapPort::PortTransmitter::clearPacketList()
|
|||||||
pcap_send_queue *sq = sendQueueList_.takeFirst();
|
pcap_send_queue *sq = sendQueueList_.takeFirst();
|
||||||
pcap_sendqueue_destroy(sq);
|
pcap_sendqueue_destroy(sq);
|
||||||
}
|
}
|
||||||
|
setPacketListLoopMode(false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PcapPort::PortTransmitter::appendToPacketList(long sec, long usec,
|
bool PcapPort::PortTransmitter::appendToPacketList(long sec, long usec,
|
||||||
@ -223,24 +225,22 @@ bool PcapPort::PortTransmitter::appendToPacketList(long sec, long usec,
|
|||||||
pktHdr.ts.tv_sec = sec;
|
pktHdr.ts.tv_sec = sec;
|
||||||
pktHdr.ts.tv_usec = usec;
|
pktHdr.ts.tv_usec = usec;
|
||||||
|
|
||||||
if (sendQueueList_.size())
|
sendQ = sendQueueList_.isEmpty() ? NULL : sendQueueList_.last();
|
||||||
sendQ = sendQueueList_.last();
|
|
||||||
else
|
|
||||||
sendQ = pcap_sendqueue_alloc(1*1024*1024);
|
|
||||||
|
|
||||||
// Not enough space? Alloc another one!
|
if ((sendQ == NULL) ||
|
||||||
if ((sendQ->len + length + sizeof(pcap_pkthdr)) > sendQ->maxlen)
|
(sendQ->len + sizeof(pcap_pkthdr) + length) > sendQ->maxlen)
|
||||||
{
|
{
|
||||||
sendQueueList_.append(sendQ);
|
|
||||||
|
|
||||||
//! \todo (LOW): calculate sendqueue size
|
//! \todo (LOW): calculate sendqueue size
|
||||||
sendQ = pcap_sendqueue_alloc(1*1024*1024);
|
sendQ = pcap_sendqueue_alloc(1*1024*1024);
|
||||||
|
sendQueueList_.append(sendQ);
|
||||||
|
|
||||||
|
// Validate that the pkt will fit inside the new sendQ
|
||||||
|
Q_ASSERT((length + sizeof(pcap_pkthdr)) < sendQ->maxlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcap_sendqueue_queue(sendQ, &pktHdr, (u_char*) packet) < 0)
|
if (pcap_sendqueue_queue(sendQ, &pktHdr, (u_char*) packet) < 0)
|
||||||
op = false;
|
op = false;
|
||||||
|
|
||||||
sendQueueList_.append(sendQ);
|
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +279,8 @@ void PcapPort::PortTransmitter::run()
|
|||||||
const int kSyncTransmit = 1;
|
const int kSyncTransmit = 1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
qDebug("sendQueueList_.size = %d", sendQueueList_.size());
|
||||||
|
|
||||||
for(i = 0; i < sendQueueList_.size(); i++)
|
for(i = 0; i < sendQueueList_.size(); i++)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -286,17 +288,17 @@ _restart:
|
|||||||
ret = sendQueueTransmit(handle_, sendQueueList_.at(i), kSyncTransmit);
|
ret = sendQueueTransmit(handle_, sendQueueList_.at(i), kSyncTransmit);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
qDebug("error in sendQueueTransmit()");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
//! \todo (HIGH): Timing between subsequent sendQueues
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnToQIdx_ >= 0)
|
if (returnToQIdx_ >= 0)
|
||||||
{
|
{
|
||||||
i = returnToQIdx_;
|
i = returnToQIdx_;
|
||||||
|
|
||||||
//! \todo (HIGH) 1s fixed; Change this to ipg of last stream
|
udelay(loopDelay_);
|
||||||
QThread::usleep(1000000);
|
|
||||||
goto _restart;
|
goto _restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,11 +329,14 @@ int PcapPort::PortTransmitter::sendQueueTransmit(pcap_t *p,
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A pktLen of size 0 is used at the end of a sendQueue and before
|
||||||
|
// the next sendQueue - i.e. for inter sendQueue timing
|
||||||
if(pktLen > 0)
|
if(pktLen > 0)
|
||||||
|
{
|
||||||
pcap_sendpacket(p, pkt, pktLen);
|
pcap_sendpacket(p, pkt, pktLen);
|
||||||
|
|
||||||
stats_->txPkts++;
|
stats_->txPkts++;
|
||||||
stats_->txBytes += pktLen;
|
stats_->txBytes += pktLen;
|
||||||
|
}
|
||||||
|
|
||||||
// Step to the next packet in the buffer
|
// Step to the next packet in the buffer
|
||||||
hdr = (struct pcap_pkthdr*) ((uchar*)hdr + sizeof(*hdr) + pktLen);
|
hdr = (struct pcap_pkthdr*) ((uchar*)hdr + sizeof(*hdr) + pktLen);
|
||||||
|
@ -18,14 +18,14 @@ public:
|
|||||||
|
|
||||||
virtual void clearPacketList() {
|
virtual void clearPacketList() {
|
||||||
transmitter_->clearPacketList();
|
transmitter_->clearPacketList();
|
||||||
setPacketListLoopMode(false);
|
setPacketListLoopMode(false, 0);
|
||||||
}
|
}
|
||||||
virtual bool appendToPacketList(long sec, long usec, const uchar *packet,
|
virtual bool appendToPacketList(long sec, long usec, const uchar *packet,
|
||||||
int length) {
|
int length) {
|
||||||
return transmitter_->appendToPacketList(sec, usec, packet, length);
|
return transmitter_->appendToPacketList(sec, usec, packet, length);
|
||||||
}
|
}
|
||||||
virtual void setPacketListLoopMode(bool loop) {
|
virtual void setPacketListLoopMode(bool loop, long usecDelay) {
|
||||||
transmitter_->setPacketListLoopMode(loop);
|
transmitter_->setPacketListLoopMode(loop, usecDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void startTransmit() {
|
virtual void startTransmit() {
|
||||||
@ -73,8 +73,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) {
|
void setPacketListLoopMode(bool loop, long usecDelay) {
|
||||||
returnToQIdx_ = loop ? 0 : -1;
|
returnToQIdx_ = loop ? 0 : -1;
|
||||||
|
loopDelay_ = usecDelay;
|
||||||
}
|
}
|
||||||
void setHandle(pcap_t *handle);
|
void setHandle(pcap_t *handle);
|
||||||
void useExternalStats(AbstractPort::PortStats *stats);
|
void useExternalStats(AbstractPort::PortStats *stats);
|
||||||
@ -87,6 +88,7 @@ protected:
|
|||||||
quint64 ticksFreq_;
|
quint64 ticksFreq_;
|
||||||
QList<pcap_send_queue*> sendQueueList_;
|
QList<pcap_send_queue*> sendQueueList_;
|
||||||
int returnToQIdx_;
|
int returnToQIdx_;
|
||||||
|
long loopDelay_;
|
||||||
bool usingInternalStats_;
|
bool usingInternalStats_;
|
||||||
AbstractPort::PortStats *stats_;
|
AbstractPort::PortStats *stats_;
|
||||||
bool usingInternalHandle_;
|
bool usingInternalHandle_;
|
||||||
|
Loading…
Reference in New Issue
Block a user