Enable inter-packet gap to be more than one second
Fixes issue 42
This commit is contained in:
parent
d2c4bf0834
commit
670920afa6
@ -964,8 +964,8 @@ void StreamConfigDialog::StoreCurrentStream()
|
||||
pStream->setNumPackets(leNumPackets->text().toULong(&isOk));
|
||||
pStream->setNumBursts(leNumBursts->text().toULong(&isOk));
|
||||
pStream->setBurstSize(lePacketsPerBurst->text().toULong(&isOk));
|
||||
pStream->setPacketRate(lePacketsPerSec->text().toULong(&isOk));
|
||||
pStream->setBurstRate(leBurstsPerSec->text().toULong(&isOk));
|
||||
pStream->setPacketRate(lePacketsPerSec->text().toDouble(&isOk));
|
||||
pStream->setBurstRate(leBurstsPerSec->text().toDouble(&isOk));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,6 @@ bool FileFormat::openStreams(const QString fileName,
|
||||
}
|
||||
|
||||
Q_ASSERT(meta.data().format_version_major() == kFileFormatVersionMajor);
|
||||
Q_ASSERT(meta.data().format_version_minor() == kFileFormatVersionMinor);
|
||||
|
||||
// ByteSize() does not include the Tag/Key, so we add 2 for that
|
||||
contentOffset = kFileMetaDataOffset + meta.data().ByteSize() + 2;
|
||||
@ -178,6 +177,8 @@ bool FileFormat::openStreams(const QString fileName,
|
||||
if (!content.matter().has_streams())
|
||||
goto _missing_streams;
|
||||
|
||||
postParseFixup(meta.data(), content);
|
||||
|
||||
streams.CopyFrom(content.matter().streams());
|
||||
|
||||
return true;
|
||||
@ -444,3 +445,39 @@ void FileFormat::initFileMetaData(OstProto::FileMetaData &metaData)
|
||||
qApp->property("revision").toString().toUtf8().constData());
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
/*! Fixup content to what is expected in the native version */
|
||||
void FileFormat::postParseFixup(OstProto::FileMetaData metaData,
|
||||
OstProto::FileContent &content)
|
||||
{
|
||||
Q_ASSERT(metaData.format_version_major() == kFileFormatVersionMajor);
|
||||
|
||||
// Do fixups from oldest to newest versions
|
||||
switch (metaData.format_version_minor())
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
int n = content.matter().streams().stream_size();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
OstProto::StreamControl *sctl =
|
||||
content.mutable_matter()->mutable_streams()->mutable_stream(i)->mutable_control();
|
||||
sctl->set_packets_per_sec(sctl->obsolete_packets_per_sec());
|
||||
sctl->set_bursts_per_sec(sctl->obsolete_bursts_per_sec());
|
||||
}
|
||||
|
||||
// fall-through to next higher version until native version
|
||||
}
|
||||
case kFileFormatVersionMinor: // native version
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
qWarning("%s: minor version %u unhandled", __FUNCTION__,
|
||||
metaData.format_version_minor());
|
||||
Q_ASSERT_X(false, "postParseFixup", "unhandled minor version");
|
||||
}
|
||||
|
||||
}
|
||||
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
||||
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
|
||||
private:
|
||||
void initFileMetaData(OstProto::FileMetaData &metaData);
|
||||
void postParseFixup(OstProto::FileMetaData metaData,
|
||||
OstProto::FileContent &content);
|
||||
|
||||
static const int kFileMagicSize = 12;
|
||||
static const int kFileChecksumSize = 5;
|
||||
@ -51,7 +53,7 @@ private:
|
||||
|
||||
// Native file format version
|
||||
static const uint kFileFormatVersionMajor = 0;
|
||||
static const uint kFileFormatVersionMinor = 1;
|
||||
static const uint kFileFormatVersionMinor = 2;
|
||||
static const uint kFileFormatVersionRevision = 3;
|
||||
};
|
||||
|
||||
|
@ -67,8 +67,10 @@ message StreamControl {
|
||||
optional uint32 num_bursts = 4 [default = 1];
|
||||
optional uint32 packets_per_burst = 5 [default = 10];
|
||||
optional NextWhat next = 6 [default = e_nw_goto_next];
|
||||
optional uint32 packets_per_sec = 7 [default = 1];
|
||||
optional uint32 bursts_per_sec = 8 [default = 1];
|
||||
optional uint32 OBSOLETE_packets_per_sec = 7 [default = 1, deprecated=true];
|
||||
optional uint32 OBSOLETE_bursts_per_sec = 8 [default = 1, deprecated=true];
|
||||
optional double packets_per_sec = 9 [default = 1];
|
||||
optional double bursts_per_sec = 10 [default = 1];
|
||||
}
|
||||
|
||||
message ProtocolId {
|
||||
|
@ -325,23 +325,23 @@ bool StreamBase::setBurstSize(quint32 packetsPerBurst)
|
||||
return true;
|
||||
}
|
||||
|
||||
quint32 StreamBase::packetRate() const
|
||||
double StreamBase::packetRate() const
|
||||
{
|
||||
return (quint32) mControl->packets_per_sec();
|
||||
return (double) mControl->packets_per_sec();
|
||||
}
|
||||
|
||||
bool StreamBase::setPacketRate(quint32 packetsPerSec)
|
||||
bool StreamBase::setPacketRate(double packetsPerSec)
|
||||
{
|
||||
mControl->set_packets_per_sec(packetsPerSec);
|
||||
return true;
|
||||
}
|
||||
|
||||
quint32 StreamBase::burstRate() const
|
||||
double StreamBase::burstRate() const
|
||||
{
|
||||
return (quint32) mControl->bursts_per_sec();
|
||||
return (double) mControl->bursts_per_sec();
|
||||
}
|
||||
|
||||
bool StreamBase::setBurstRate(quint32 burstsPerSec)
|
||||
bool StreamBase::setBurstRate(double burstsPerSec)
|
||||
{
|
||||
mControl->set_bursts_per_sec(burstsPerSec);
|
||||
return true;
|
||||
|
@ -125,11 +125,11 @@ public:
|
||||
quint32 burstSize() const;
|
||||
bool setBurstSize(quint32 packetsPerBurst);
|
||||
|
||||
quint32 packetRate() const;
|
||||
bool setPacketRate(quint32 packetsPerSec);
|
||||
double packetRate() const;
|
||||
bool setPacketRate(double packetsPerSec);
|
||||
|
||||
quint32 burstRate() const;
|
||||
bool setBurstRate(quint32 burstsPerSec);
|
||||
double burstRate() const;
|
||||
bool setBurstRate(double burstsPerSec);
|
||||
|
||||
bool isFrameVariable() const;
|
||||
bool isFrameSizeVariable() const;
|
||||
|
@ -204,7 +204,7 @@ void AbstractPort::updatePacketList()
|
||||
appendToPacketList(sec, usec, pktBuf_, len);
|
||||
|
||||
usec += (k < np1) ? ipg1 : ipg2;
|
||||
if (usec > 1000000)
|
||||
while (usec >= 1000000)
|
||||
{
|
||||
sec++;
|
||||
usec -= 1000000;
|
||||
@ -212,7 +212,7 @@ void AbstractPort::updatePacketList()
|
||||
} // for (numPackets)
|
||||
|
||||
usec += (j < nb1) ? ibg1 : ibg2;
|
||||
if (usec > 1000000)
|
||||
while (usec >= 1000000)
|
||||
{
|
||||
sec++;
|
||||
usec -= 1000000;
|
||||
|
@ -492,6 +492,12 @@ void PcapPort::PortTransmitter::udelay(long usec)
|
||||
delay.tv_sec = 0;
|
||||
delay.tv_usec = usec;
|
||||
|
||||
while (delay.tv_usec >= 1000000)
|
||||
{
|
||||
delay.tv_sec++;
|
||||
delay.tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
timeradd(&now, &delay, &target);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user