本文整理汇总了C++中NetworkData类的典型用法代码示例。如果您正苦于以下问题:C++ NetworkData类的具体用法?C++ NetworkData怎么用?C++ NetworkData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NetworkData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void PlayerNetworkMeter::WriteString(const char* inString)
{
ASSERT(this->mMessage.GetMessagePending());
NetworkData theNetworkData;
theNetworkData.SetTypeString(inString);
this->mMessage.AddData(theNetworkData);
}
示例2: runExperiment22
void runExperiment22(int N, int M, int L, int L_user) {
int count = 200;
while (count--) {
NetworkData data;
data.init(N,M,L,L_user);
vector<int> p(0);
ProblemSolver ps(data);
cout << ps.findOptimalUniformPrice().first << " ";
pair<int, vector<int> > r1 = ps.findLocallyOptimalNonuiformPricing(0,0);
pair<int, vector<int> > r2 = ps.findLocallyOptimalNonuiformPricing(1,0);
cout << r1.first << " ";
cout << ps._getRevenueForNonuniformPricing(r2.second) << endl;
}
}
示例3: get_input
void get_input(ACE_HANDLE fd) {
unsigned char buf[2000];
int read_count = ACE_OS::read(fd, buf, 2000);
if ( read_count < 0 ) {
cerr << "Input error: " << (string) ACE_OS::strerror(errno) << endl;
}
else {
NetworkData *nd = new NetworkData(read_count, buf);
cout << "Received " << read_count << " bytes: " << endl;
nd->dump();
}
}
示例4: measure
NetworkData VnaLinearSweep::measure(QVector<uint> ports) {
NetworkData network;
if (ports.size() <= 0)
return(network);
if (_channel->isCwSweep() || _channel->isTimeSweep())
return(network);
setSParameterGroup(ports);
network.setParameter(NetworkParameter::S);
network.setReferenceImpedance(50);
network.setXUnits(Units::Hertz);
network.setData(frequencies_Hz(), readSParameterGroup());
return(network);
}
示例5: getAuxData_
bool modAOS_IN_SDU_Insert::_insertWaitingInSduUnit(AOS_Transfer_Frame* frame) {
bool success = false;
if ( ! getAuxQueue()->is_empty() ) {
std::pair<NetworkData*, int> auxQueueTop = getAuxData_();
if ( auxQueueTop.second < 0 ) {
MOD_ERROR("getAuxData_() call failed.");
}
else if ( ! auxQueueTop.first ) {
MOD_ERROR("getAuxData_() returned with null data.");
}
else {
ACE_Message_Block* mb = auxQueueTop.first;
NetworkData* inSdu = dynamic_cast<NetworkData*>(mb);
if ( ! inSdu || mb->length() != static_cast<size_t>(getInsertZoneSize()) ) {
MOD_WARNING("Unrecognized %d-octet, non-IN_SDU data unit received on auxInput queue (inSdu ptr: %X, IZ size: %d)",
mb->length(), inSdu, getInsertZoneSize());
ndSafeRelease(mb);
}
else {
MOD_DEBUG("%d-octet IN_SDU unit is waiting, attempting to copy to the %d-octet Insert Zone.",
inSdu->getUnitLength(), frame->getInSduLen());
_receivedInSduUnitCount += 1;
_receivedInSduOctetCount += inSdu->getUnitLength();
try {
frame->setInsertZone(inSdu);
success = true;
}
catch(const BufferOverflow& e) {
MOD_WARNING("%d-octet IN_SDU unit could not fit into %d-octet Insert Zone, dropping.",
inSdu->getUnitLength(), frame->getInSduLen());
}
ndSafeRelease(inSdu);
}
}
}
return success;
}
示例6: MOD_DEBUG
void modAOS_VC_Frame::rebuildIdleUnitTemplate_() {
MOD_DEBUG("Rebuilding Idle AOS Transfer Frame template.");
idleUnitTemplateCreation_.acquire();
AOS_Transfer_Frame* newFrame = new AOS_Transfer_Frame(static_cast<size_t>(getFrameSize()));
newFrame->makeIdle(getSCID());
NetworkData* idleData = new NetworkData(idlePattern_.getLength());
for (int i = 0; i < idlePattern_.getLength(); i++ ) {
*(idleData->ptrUnit() + i) = static_cast<int>(idlePattern_[i]) & 0xFF;
}
newFrame->setDataToPattern(idleData);
ndSafeRelease(idleData);
ndSafeRelease(idleUnitTemplate_);
idleUnitTemplate_ = newFrame;
idleUnitTemplateCreation_.release();
}
示例7: print_ppp_info
void print_ppp_info(PppFrame* frame) {
NetworkData* nd = frame;
cout << endl
<< " Start Flag: " << hex << uppercase << setw(2) << setfill('0') << (int) frame->startFlagVal() << endl
<< "Address Length: " << (int) frame->getAddressLength() << endl
<< " Address Value: " << hex << uppercase << setw(2 * frame->getAddressLength()) << setfill('0') << frame->addressVal() << endl
<< "Control Length: " << (int) frame->getControlLength() << endl
<< " Control Value: " << hex << uppercase << setw(2 * frame->getControlLength()) << setfill('0') << frame->controlVal() << endl
<< "Protocol Value: " << hex << uppercase << setw(4) << setfill('0') << frame->protocolVal() << endl
<< " Data Length: " << dec << (int) frame->dataLength() << endl
<< " FCS Length: " << (int) frame->getFCSLength() << endl
<< " FCS Value: " << hex << uppercase << setw(2 * frame->getFCSLength()) << setfill('0') << frame->fcsVal() << endl
<< " End Flag: " << hex << uppercase << setw(2) << setfill('0') << (int) frame->endFlagVal() << endl
<< " FCS Valid?: " << ((frame->fcsValid())? "Yes" : "No" ) << endl
<< " size(): " << dec << (int) frame->getUnitLength() << endl
<< " Type String: " << nd->typeStr() << endl
<< endl;
};
示例8: main
int main() {
NetworkData* data;
IPv4Addr src("192.168.100.1"), dst("192.168.100.2");
unsigned total = 0, bad = 0;
srand48(time(0));
for (int bufsize = 0; bufsize < 10000; bufsize++) {
++total;
data = new NetworkData(bufsize);
for (int idx = 0; idx < bufsize; idx++) {
*(data->ptrBuffer() + idx) = lrand48() % 0xFF;
}
IPv4_UDP_Datagram* dgm = new IPv4_UDP_Datagram();
dgm->build(src, 4321, dst, 1234, data);
dgm->setChecksum(dgm->computeChecksum());
dgm->setUDPChecksum(dgm->computeUDPChecksum());
if ( ! dgm->hasValidUDPChecksum() ) {
++bad;
dgm->dump();
cerr << "Datagram with data field length " << bufsize << " has invalid checksum:" << endl
<< " UDPLength: " << dec << dgm->getUDPLength() << endl
<< " DataLength: " << dgm->getDataLength() << endl
<< " Stored CRC: " << hex << setw(4) << setfill('0') << dgm->getUDPChecksum() << endl
<< " Computed CRC: " << hex << setw(4) << setfill('0') << dgm->computeUDPChecksum() << endl
<< " ---------------- " << endl;
}
data->release();
dgm->release();
}
cout << "Datagrams generated: " << dec << total << endl
<< "Bad checksums: " << bad << endl;
}
示例9: runEvaluation
void runEvaluation(int N, int M, int L, int L_user) {
int n_cases = 1;
while (true) {
cout << "case: " << n_cases++ << endl;
NetworkData data;
data.init(N,M,L,L_user);
ProblemSolver ps(data);
int nonuni_r = ps.findLocallyOptimalNonuiformPricing(1,1).first;
}
// while (true) {
// NetworkData data;
// data.init(N,M,L,L_user);
// ProblemSolver ps(data);
// int uni_r = ps.findOptimalUniformPrice().first;
// int nonuni_r = ps.findLocallyOptimalNonuiformPricing(1, 0).first;
// int opt_r = ps.findOptimalPricingByDFS().first;
// cout << uni_r << " " << nonuni_r << " " << opt_r << endl;
// }
}
示例10: transferData
void RemoteControl::transferData(ObserverData* param)
{
if (!getIsActive())
{
if (sgl_ConnectionManager.getState() == STATE_JOINED || sgl_ConnectionManager.getState() == STATE_CREATED_JOINED)
{
NetworkData ndata;
std::map<int,float>* data = new std::map<int,float>();
data->insert(std::pair<int,float>(1, param->getSpeed().x * 0.7f));
data->insert(std::pair<int,float>(2, param->getSpeed().y * 0.7f));
ndata.setData(data);
sgl_ConnectionManager.sendEvent(ndata, kShoot);
_state.needsSync = true;
}
}
}
示例11: runExperiment2
void runExperiment2(int N, int M, int L, int L_user) {
int count = 1000;
while (count--) {
NetworkData data;
data.init(N,M,L,L_user);
vector<int> p(0);
for (int i = 0; i < L; ++i) {
p.push_back(rand()%(MAX_VALUATION+1));
}
ProblemSolver ps(data);
cout << ps._getRevenueForNonuniformPricing(p);
ApproximateAlgorithm aa = ApproximateAlgorithm(data, p);
cout << " " << aa.computeRevenue() << endl;
// int random_max = 0;
// for (int i = 0; i < 20; ++i) {
// int r = aa._computeRevenueWithRandomSelection();
// random_max = r > random_max ? r : random_max;
// cout << " " << random_max;
// }
// cout << endl;
}
}
示例12: slice
static std::vector<DataSegment<Header>> slice(const NetworkData &nd,
size_t segmentWireLength)
{
std::vector<DataSegment<Header>> segments;
size_t payloadLength = DataSegment<Header>::payloadLength(segmentWireLength);
if (payloadLength == 0)
return segments;
std::vector<uint8_t>::const_iterator p1 = nd.data().begin();
std::vector<uint8_t>::const_iterator p2 = p1 + payloadLength;
while (p2 < nd.data().end())
{
segments.push_back(DataSegment<Header>(p1, p2));
p1 = p2;
p2 += payloadLength;
}
segments.push_back(DataSegment<Header>(p1, nd.data().end()));
return segments;
}
示例13: svcStart_
int modASM_Remove::svc() {
svcStart_();
ACE_UINT8* markerBuf = 0;
size_t markerLen = 0;
_rebuildMarker = true;
NetworkData* data = 0;
NetworkData* goodUnit = 0;
size_t goodUnitLength = 0;
size_t advanceLen = 0;
size_t remainingLen = 0;
size_t partialMarkerLen = 0;
size_t markerOffset = 0;
bool searching = false;
while ( continueService() ) {
std::pair<NetworkData*, int> queueTop = getData_();
if ( msg_queue()->deactivated() ) break;
if ( queueTop.second < 0 ) {
MOD_ERROR("getData_() call failed.");
continue;
}
else if ( ! queueTop.first ) {
MOD_ERROR("getData_() returned with null data.");
continue;
}
data = queueTop.first;
_updateMarker(markerBuf, markerLen);
MOD_DEBUG("Received a %d-octet unit to test for ASMs.", data->getUnitLength());
while ( data->getUnitLength() ) {
if ( ! goodUnit ) { // no unit to continue, need to find next ASM
partialMarkerLen = markerLen - markerOffset;
// determine if enough buffer left to find ASM
// if not, check what's left and check for remainder in next buffer
if ( data->getUnitLength() < partialMarkerLen ) {
if ( _markerMatch(data->ptrUnit(), markerBuf + markerOffset, data->getUnitLength()) ) {
// this portion is correct
markerOffset += data->getUnitLength();
}
else {
MOD_DEBUG("Missed partial ASM, resetting marker offset and bit error count.");
incPartialMismatchCount();
markerOffset = 0;
_currentBitErrors = 0;
}
advanceLen = data->getUnitLength();
}
// if so, look for ASM normally
else if ( _markerMatch(data->ptrUnit(), markerBuf + markerOffset, partialMarkerLen) ) {
MOD_DEBUG("Found ASM.");
_asmCount++;
if ( searching ) _asmDiscoveredCount++;
else _asmValidCount++;
searching = false;
advanceLen = partialMarkerLen;
markerOffset = 0;
_currentBitErrors = 0;
// determine if entire unit can be extracted from buffer
// if so, wrap and send
if ( data->getUnitLength() - partialMarkerLen >= getExpectedUnitLength() ) {
MOD_DEBUG("Found complete unit.");
goodUnit = data->wrapInnerPDU<NetworkData>(getExpectedUnitLength(),
data->ptrUnit() + partialMarkerLen);
_send(goodUnit);
advanceLen += getExpectedUnitLength();
}
// if not, create a new unit to hold it
else {
MOD_DEBUG("Holding partial unit for expected completion.");
goodUnitLength = data->getUnitLength() - partialMarkerLen;
goodUnit = new NetworkData(getExpectedUnitLength());
goodUnit->copyUnit(goodUnit->ptrUnit(), data->ptrUnit() + partialMarkerLen, goodUnitLength);
advanceLen += goodUnitLength;
};
}
else {
MOD_DEBUG("Missed ASM, advancing one octet at a time.");
if (! searching ) _asmMissedCount++; // Only increment for the first miss, or after another ASM was found.
searching = true;
incSearchCount();
// data->dump();
advanceLen = 1;
markerOffset = 0;
_currentBitErrors = 0;
}
}
else { // continuing previous unit, don't look for ASM
remainingLen = getExpectedUnitLength() - goodUnitLength;
// determine if remaining unit fits in buffer
//.........这里部分代码省略.........
示例14: svcStart_
int modTM_MC_Frame::svc() {
svcStart_();
NetworkData* data = 0;
TM_Transfer_Frame* frame = 0;
while ( continueService() ) {
ndSafeRelease(data);
ndSafeRelease(frame);
std::pair<NetworkData*, int> queueTop = getData_();
if ( msg_queue()->deactivated() ) break;
if ( queueTop.second < 0 ) {
MOD_ERROR("getData_() call failed.");
continue;
}
else if ( ! queueTop.first ) {
MOD_ERROR("getData_() returned with null data.");
continue;
}
data = queueTop.first;
queueTop.first = 0;
MOD_DEBUG("Channel MCID %X: Received a %d-octet MC frame.", getMCID(), data->getTotalUnitLength());
if ( data->getTotalUnitLength() != getMRU() ) {
MOD_ERROR("Received %d-octet frame when exactly %d octets are required.", data->getTotalUnitLength(), getMRU());
incBadLengthCount();
if ( getDropBadFrames() ) { ndSafeRelease(data); continue; }
}
TM_Transfer_Frame* frame = new TM_Transfer_Frame(
getFrameSize(), // all frames in MC have the same size
data->ptrUnit(), // copy the data
getUseOperationalControl(), // existance of OCF is VC dependent
getUseFrameErrorControl(), // all frames in MC have frame CRC, or not
getFSHSize() // size of secondary header
);
if ( ! frame ) {
MOD_ALERT("Failed to allocate a TM_Transfer_Frame!", getName().c_str());
continue;
}
if ( frame->getMCID() != getMCID() ) {
ND_WARNING("[%s] Incoming frame MCID %X does not match assigned MCID %X.", frame->getMCID(), getMCID());
incBadMCIDCount();
if ( getDropBadFrames() ) continue;
}
else {
incValidFrameCount();
}
if ( links_[PrimaryOutputLink] ) {
MOD_DEBUG("Sending %-octet frame to next segment.", frame->getUnitLength());
links_[PrimaryOutputLink]->send(frame);
frame = 0; // important
}
else {
MOD_ERROR("No output target defined, dropping packet.");
}
}
return svcEnd_();
}
示例15: svcStart_
int modAOS_VC_Frame::svc() {
svcStart_();
NetworkData* data = 0;
AOS_Transfer_Frame* aos = 0;
while ( continueService() ) {
bool frameIsValid = true;
ndSafeRelease(data); // Handle all cases from previous iteration
std::pair<NetworkData*, int> queueTop = getData_();
if ( msg_queue()->deactivated() ) break;
if ( queueTop.second < 0 ) {
MOD_ERROR("getData_() call failed.");
continue;
}
else if ( ! queueTop.first ) {
MOD_ERROR("getData_() returned with null data.");
continue;
}
data = queueTop.first;
queueTop.first = 0;
MOD_DEBUG("Channel GVCID %X: Received a %d-octet VC frame.", getGVCID(), data->getTotalUnitLength());
if ( data->getTotalUnitLength() != getMRU() ) {
MOD_ERROR("Received %d-octet frame when exactly %d octets are required.", data->getTotalUnitLength(), getMRU());
incBadLengthCount();
frameIsValid = false;
if ( getDropBadFrames() ) continue;
}
if ( links_[PrimaryOutputLink] ) {
ndSafeRelease(aos);
aos = new AOS_Transfer_Frame(
getFrameSize(), // all frames in MC have the same size
data->ptrUnit() // copy the data buffer
);
if ( ! aos ) {
MOD_ALERT("Failed to allocate an AOS_Transfer_Frame!", getName().c_str());
}
else if ( aos->getGVCID() != getGVCID() ) {
ND_WARNING("[%s] Incoming frame GVCID %X does not match assigned GVCID %X.", aos->getGVCID(), getGVCID());
incBadGVCIDCount();
frameIsValid = false;
if ( getDropBadFrames() ) continue;
}
if ( frameIsValid ) incValidFrameCount();
if (aos) {
MOD_DEBUG("Sending %-octet frame to next segment.", aos->getUnitLength());
links_[PrimaryOutputLink]->send(aos);
aos = 0; // important
}
}
else {
MOD_ERROR("No output target defined, dropping packet.");
}
}
return svcEnd_();
}