sign: signed tx stats infra; actual tx signing pending
This commit is contained in:
parent
31c2cd2dcb
commit
a79bbb1fcd
@ -98,6 +98,8 @@ public:
|
|||||||
{ return d.is_exclusive_control(); }
|
{ return d.is_exclusive_control(); }
|
||||||
OstProto::TransmitMode transmitMode()
|
OstProto::TransmitMode transmitMode()
|
||||||
{ return d.transmit_mode(); }
|
{ return d.transmit_mode(); }
|
||||||
|
OstProto::StreamType streamsType()
|
||||||
|
{ return d.streams_type(); }
|
||||||
double averagePacketRate()
|
double averagePacketRate()
|
||||||
{ return avgPacketsPerSec_; }
|
{ return avgPacketsPerSec_; }
|
||||||
double averageBitRate()
|
double averageBitRate()
|
||||||
|
@ -64,6 +64,19 @@ PortConfigDialog::PortConfigDialog(OstProto::Port &portConfig, QWidget *parent)
|
|||||||
qDebug("reservedBy_ = %d", reservedBy_);
|
qDebug("reservedBy_ = %d", reservedBy_);
|
||||||
|
|
||||||
exclusiveControlButton->setChecked(portConfig_.is_exclusive_control());
|
exclusiveControlButton->setChecked(portConfig_.is_exclusive_control());
|
||||||
|
|
||||||
|
switch(portConfig_.streams_type())
|
||||||
|
{
|
||||||
|
case OstProto::kUnsignedStream:
|
||||||
|
signedStreamsButton->setChecked(false);
|
||||||
|
break;
|
||||||
|
case OstProto::kSignedStream:
|
||||||
|
signedStreamsButton->setChecked(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false); // Unreachable!!!
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortConfigDialog::accept()
|
void PortConfigDialog::accept()
|
||||||
@ -96,6 +109,11 @@ void PortConfigDialog::accept()
|
|||||||
|
|
||||||
pc.set_is_exclusive_control(exclusiveControlButton->isChecked());
|
pc.set_is_exclusive_control(exclusiveControlButton->isChecked());
|
||||||
|
|
||||||
|
if (signedStreamsButton->isChecked())
|
||||||
|
pc.set_streams_type(OstProto::kSignedStream);
|
||||||
|
else
|
||||||
|
pc.set_streams_type(OstProto::kUnsignedStream);
|
||||||
|
|
||||||
// Update fields that have changed, clear the rest
|
// Update fields that have changed, clear the rest
|
||||||
if (pc.transmit_mode() != portConfig_.transmit_mode())
|
if (pc.transmit_mode() != portConfig_.transmit_mode())
|
||||||
portConfig_.set_transmit_mode(pc.transmit_mode());
|
portConfig_.set_transmit_mode(pc.transmit_mode());
|
||||||
@ -112,5 +130,10 @@ void PortConfigDialog::accept()
|
|||||||
else
|
else
|
||||||
portConfig_.clear_is_exclusive_control();
|
portConfig_.clear_is_exclusive_control();
|
||||||
|
|
||||||
|
if (pc.streams_type() != portConfig_.streams_type())
|
||||||
|
portConfig_.set_streams_type(pc.streams_type());
|
||||||
|
else
|
||||||
|
portConfig_.clear_streams_type();
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>244</width>
|
<width>244</width>
|
||||||
<height>233</height>
|
<height>257</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
@ -69,6 +69,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="signedStreamsButton" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Signed Streams</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
|
@ -719,7 +719,13 @@ void PortsWindow::on_actionPort_Configuration_triggered()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
OstProto::Port config;
|
OstProto::Port config;
|
||||||
|
// XXX: we don't call Port::protoDataCopyInto() to get config b'coz
|
||||||
|
// we want only the modifiable fields populated to send to Drone
|
||||||
|
// TODO: extend Port::protoDataCopyInto() to accept an optional param
|
||||||
|
// which says copy only modifiable fields
|
||||||
|
plm->port(current).protoDataCopyInto(&config);
|
||||||
config.set_transmit_mode(plm->port(current).transmitMode());
|
config.set_transmit_mode(plm->port(current).transmitMode());
|
||||||
|
config.set_streams_type(plm->port(current).streamsType());
|
||||||
config.set_is_exclusive_control(plm->port(current).hasExclusiveControl());
|
config.set_is_exclusive_control(plm->port(current).hasExclusiveControl());
|
||||||
config.set_user_name(plm->port(current).userName().toStdString());
|
config.set_user_name(plm->port(current).userName().toStdString());
|
||||||
|
|
||||||
|
@ -195,6 +195,11 @@ enum TransmitMode {
|
|||||||
kInterleavedTransmit = 1;
|
kInterleavedTransmit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum StreamType {
|
||||||
|
kUnsignedStream = 0; // FIXME: rename? convert to flags?
|
||||||
|
kSignedStream = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message Port {
|
message Port {
|
||||||
required PortId port_id = 1;
|
required PortId port_id = 1;
|
||||||
optional string name = 2;
|
optional string name = 2;
|
||||||
@ -204,6 +209,7 @@ message Port {
|
|||||||
optional bool is_exclusive_control = 6;
|
optional bool is_exclusive_control = 6;
|
||||||
optional TransmitMode transmit_mode = 7 [default = kSequentialTransmit];
|
optional TransmitMode transmit_mode = 7 [default = kSequentialTransmit];
|
||||||
optional string user_name = 8;
|
optional string user_name = 8;
|
||||||
|
optional StreamType streams_type = 9 [default = kUnsignedStream];
|
||||||
}
|
}
|
||||||
|
|
||||||
message PortConfigList {
|
message PortConfigList {
|
||||||
|
@ -82,6 +82,9 @@ bool AbstractPort::modify(const OstProto::Port &port)
|
|||||||
if (port.has_transmit_mode())
|
if (port.has_transmit_mode())
|
||||||
data_.set_transmit_mode(port.transmit_mode());
|
data_.set_transmit_mode(port.transmit_mode());
|
||||||
|
|
||||||
|
if (port.has_streams_type())
|
||||||
|
setStreamsType(port.streams_type());
|
||||||
|
|
||||||
if (port.has_user_name()) {
|
if (port.has_user_name()) {
|
||||||
data_.set_user_name(port.user_name());
|
data_.set_user_name(port.user_name());
|
||||||
}
|
}
|
||||||
@ -155,6 +158,11 @@ void AbstractPort::addNote(QString note)
|
|||||||
data_.set_notes(notes.toStdString());
|
data_.set_notes(notes.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AbstractPort::setStreamsType(OstProto::StreamType type)
|
||||||
|
{
|
||||||
|
data_.set_streams_type(type);
|
||||||
|
}
|
||||||
|
|
||||||
AbstractPort::Accuracy AbstractPort::rateAccuracy()
|
AbstractPort::Accuracy AbstractPort::rateAccuracy()
|
||||||
{
|
{
|
||||||
return rateAccuracy_;
|
return rateAccuracy_;
|
||||||
|
@ -102,6 +102,8 @@ public:
|
|||||||
bool isDirty() { return isSendQueueDirty_; }
|
bool isDirty() { return isSendQueueDirty_; }
|
||||||
void setDirty() { isSendQueueDirty_ = true; }
|
void setDirty() { isSendQueueDirty_ = true; }
|
||||||
|
|
||||||
|
virtual bool setStreamsType(OstProto::StreamType type);
|
||||||
|
|
||||||
Accuracy rateAccuracy();
|
Accuracy rateAccuracy();
|
||||||
virtual bool setRateAccuracy(Accuracy accuracy);
|
virtual bool setRateAccuracy(Accuracy accuracy);
|
||||||
|
|
||||||
|
@ -133,6 +133,9 @@ void MyService::modifyPort(::google::protobuf::RpcController* /*controller*/,
|
|||||||
id = port.port_id().id();
|
id = port.port_id().id();
|
||||||
if (id < portInfo.size())
|
if (id < portInfo.size())
|
||||||
{
|
{
|
||||||
|
// FIXME: return error for any change in transmitMode/streamsType
|
||||||
|
// while transmit is on
|
||||||
|
|
||||||
portLock[id]->lockForWrite();
|
portLock[id]->lockForWrite();
|
||||||
portInfo[id]->modify(port);
|
portInfo[id]->modify(port);
|
||||||
portLock[id]->unlock();
|
portLock[id]->unlock();
|
||||||
@ -148,6 +151,8 @@ void MyService::modifyPort(::google::protobuf::RpcController* /*controller*/,
|
|||||||
notif->set_notif_type(OstProto::portConfigChanged);
|
notif->set_notif_type(OstProto::portConfigChanged);
|
||||||
emit notification(notif->notif_type(), SharedProtobufMessage(notif));
|
emit notification(notif->notif_type(), SharedProtobufMessage(notif));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: potential memory leak of notif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyService::getStreamIdList(::google::protobuf::RpcController* controller,
|
void MyService::getStreamIdList(::google::protobuf::RpcController* controller,
|
||||||
|
@ -117,6 +117,26 @@ void PcapPort::updateNotes()
|
|||||||
arg(notes).toStdString());
|
arg(notes).toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PcapPort::setStreamsType(OstProto::StreamType type)
|
||||||
|
{
|
||||||
|
AbstractPort::setStreamsType(type);
|
||||||
|
transmitter_->useSignedStreams(type == OstProto::kSignedStream);
|
||||||
|
|
||||||
|
// XXX: Because of the way we implement signed tx stats, changing
|
||||||
|
// streamsType requires us to set sign tx stats equal to tx stats
|
||||||
|
// followed by clear stats; see note in PcapTxStats::run() for details
|
||||||
|
// FIXME: can we get away with clearing only sign stats?
|
||||||
|
// FIXME: Ideally PcapPort should *NOT* know how PcapTxStats implements
|
||||||
|
// sign stats
|
||||||
|
stats_.sign.txPkts = stats_.txPkts;
|
||||||
|
stats_.sign.txBytes = stats_.txBytes;
|
||||||
|
stats_.sign.rxPkts = stats_.rxPkts;
|
||||||
|
stats_.sign.rxBytes = stats_.rxBytes;
|
||||||
|
resetStats();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool PcapPort::setRateAccuracy(AbstractPort::Accuracy accuracy)
|
bool PcapPort::setRateAccuracy(AbstractPort::Accuracy accuracy)
|
||||||
{
|
{
|
||||||
if (transmitter_->setRateAccuracy(accuracy)) {
|
if (transmitter_->setRateAccuracy(accuracy)) {
|
||||||
|
@ -39,6 +39,8 @@ public:
|
|||||||
virtual bool hasExclusiveControl() { return false; }
|
virtual bool hasExclusiveControl() { return false; }
|
||||||
virtual bool setExclusiveControl(bool /*exclusive*/) { return false; }
|
virtual bool setExclusiveControl(bool /*exclusive*/) { return false; }
|
||||||
|
|
||||||
|
virtual bool setStreamsType(OstProto::StreamType type);
|
||||||
|
|
||||||
virtual bool setRateAccuracy(AbstractPort::Accuracy accuracy);
|
virtual bool setRateAccuracy(AbstractPort::Accuracy accuracy);
|
||||||
|
|
||||||
virtual void clearPacketList() {
|
virtual void clearPacketList() {
|
||||||
|
@ -78,6 +78,11 @@ void PcapTransmitter::useExternalStats(AbstractPort::PortStats *stats)
|
|||||||
txStats_.useExternalStats(stats);
|
txStats_.useExternalStats(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PcapTransmitter::useSignedStreams(bool enable)
|
||||||
|
{
|
||||||
|
txStats_.useSignedStreams(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void PcapTransmitter::start()
|
void PcapTransmitter::start()
|
||||||
{
|
{
|
||||||
txThread_.start();
|
txThread_.start();
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
void setHandle(pcap_t *handle);
|
void setHandle(pcap_t *handle);
|
||||||
void useExternalStats(AbstractPort::PortStats *stats);
|
void useExternalStats(AbstractPort::PortStats *stats);
|
||||||
|
|
||||||
|
void useSignedStreams(bool enable);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool isRunning();
|
bool isRunning();
|
||||||
|
@ -28,6 +28,8 @@ PcapTxStats::PcapTxStats()
|
|||||||
stats_ = new AbstractPort::PortStats;
|
stats_ = new AbstractPort::PortStats;
|
||||||
usingInternalStats_ = true;
|
usingInternalStats_ = true;
|
||||||
|
|
||||||
|
usingSignedStreams_ = false;
|
||||||
|
|
||||||
stop_ = false;
|
stop_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +52,11 @@ void PcapTxStats::useExternalStats(AbstractPort::PortStats *stats)
|
|||||||
usingInternalStats_ = false;
|
usingInternalStats_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PcapTxStats::useSignedStreams(bool enable)
|
||||||
|
{
|
||||||
|
usingSignedStreams_ = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void PcapTxStats::start()
|
void PcapTxStats::start()
|
||||||
{
|
{
|
||||||
QThread::start();
|
QThread::start();
|
||||||
@ -76,6 +83,15 @@ void PcapTxStats::run()
|
|||||||
stats_->txPkts = txThreadStats_->pkts;
|
stats_->txPkts = txThreadStats_->pkts;
|
||||||
stats_->txBytes = txThreadStats_->bytes;
|
stats_->txBytes = txThreadStats_->bytes;
|
||||||
|
|
||||||
|
// XXX: If port uses signed streams, we assume that all packets
|
||||||
|
// sent by txThread are signed packets => this requires us to
|
||||||
|
// set sign tx stats equal to tx stats followed by a clear stats
|
||||||
|
// whenever this setting changes
|
||||||
|
if (usingSignedStreams_) {
|
||||||
|
stats_->sign.txPkts = txThreadStats_->pkts;
|
||||||
|
stats_->sign.txBytes = txThreadStats_->bytes;
|
||||||
|
}
|
||||||
|
|
||||||
if (stop_)
|
if (stop_)
|
||||||
break;
|
break;
|
||||||
QThread::msleep(1000);
|
QThread::msleep(1000);
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
|
|
||||||
void useExternalStats(AbstractPort::PortStats *stats);
|
void useExternalStats(AbstractPort::PortStats *stats);
|
||||||
|
|
||||||
|
void useSignedStreams(bool enable);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
private:
|
private:
|
||||||
@ -46,6 +48,7 @@ private:
|
|||||||
bool usingInternalStats_;
|
bool usingInternalStats_;
|
||||||
AbstractPort::PortStats *stats_;
|
AbstractPort::PortStats *stats_;
|
||||||
|
|
||||||
|
volatile bool usingSignedStreams_;
|
||||||
volatile bool stop_;
|
volatile bool stop_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user