summaryrefslogtreecommitdiffstats
path: root/src/Server.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:25:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:25:49 +0000
commit04fc174d50fd19d6ae78fd2fd2faae221acff807 (patch)
tree23e5482ac4eb332df0fc69bf932118f0d4e42eb0 /src/Server.cpp
parentAdding upstream version 2.1.9+dfsg. (diff)
downloadiperf-upstream.tar.xz
iperf-upstream.zip
Adding upstream version 2.2.0+dfsg.upstream/2.2.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/Server.cpp')
-rw-r--r--src/Server.cpp321
1 files changed, 226 insertions, 95 deletions
diff --git a/src/Server.cpp b/src/Server.cpp
index c271cd7..76eba40 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -70,7 +70,6 @@
#include "checksums.h"
#endif
-
/* -------------------------------------------------------------------
* Stores connected socket and socket info.
* ------------------------------------------------------------------- */
@@ -94,6 +93,9 @@ Server::Server (thread_Settings *inSettings) {
}
}
#endif
+#if HAVE_DECL_MSG_CTRUNC
+ ctrunc_warn_enable = true;
+#endif
// Enable kernel level timestamping if available
InitKernelTimeStamping();
int sorcvtimer = 0;
@@ -101,15 +103,24 @@ Server::Server (thread_Settings *inSettings) {
// minterval double, units seconds
// mAmount integer, units 10 milliseconds
// divide by two so timeout is 1/2 the interval
- if (mSettings->mInterval && (mSettings->mIntervalMode == kInterval_Time)) {
+ if ((mSettings->mInterval > 0) && (mSettings->mIntervalMode == kInterval_Time)) {
sorcvtimer = static_cast<int>(round(mSettings->mInterval / 2.0));
} else if (isServerModeTime(mSettings)) {
sorcvtimer = static_cast<int>(round(mSettings->mAmount * 10000) / 2);
}
- isburst = (isIsochronous(mSettings) || isPeriodicBurst(mSettings) || (isTripTime(mSettings) && !isUDP(mSettings)));
+ isburst = (isIsochronous(mSettings) || isPeriodicBurst(mSettings) || (isTripTime(mSettings)&& !isUDP(mSettings)));
if (isburst && (mSettings->mFPS > 0.0)) {
sorcvtimer = static_cast<int>(round(2000000.0 / mSettings->mFPS));
}
+ if ((mSettings->mInterval > 0) && (mSettings->mIntervalMode == kInterval_Time)) {
+ int interval_quarter = static_cast<int>(round(mSettings->mAmount * 10000) / 4);
+ if (sorcvtimer > interval_quarter) {
+ sorcvtimer = interval_quarter;
+ }
+ if (sorcvtimer < 1000) {
+ sorcvtimer = 1000; // lower bound of 1 ms
+ }
+ }
if (sorcvtimer > 0) {
SetSocketOptionsReceiveTimeout(mSettings, sorcvtimer);
}
@@ -162,7 +173,7 @@ void Server::RunTCP () {
reportstruct->packetTime.tv_usec = now.getUsecs();
while (InProgress()) {
// printf("***** bid expect = %u\n", burstid_expect);
- reportstruct->emptyreport=1;
+ reportstruct->emptyreport = true;
currLen = 0;
// perform read
if (isBWSet(mSettings)) {
@@ -170,13 +181,13 @@ void Server::RunTCP () {
tokens += time2.subSec(time1) * (mSettings->mAppRate / 8.0);
time1 = time2;
}
- reportstruct->transit_ready = 0;
+ reportstruct->transit_ready = false;
if (tokens >= 0.0) {
int n = 0;
int readLen = mSettings->mBufLen;
if (burst_nleft > 0)
readLen = (mSettings->mBufLen < burst_nleft) ? mSettings->mBufLen : burst_nleft;
- reportstruct->emptyreport=1;
+ reportstruct->emptyreport = true;
#if HAVE_DECL_TCP_QUICKACK
if (isTcpQuickAck(mSettings)) {
int opt = 1;
@@ -215,7 +226,7 @@ void Server::RunTCP () {
burst_nleft = burst_info.burst_size - n;
if (burst_nleft == 0) {
reportstruct->prevSentTime = myReport->info.ts.prevsendTime;
- reportstruct->transit_ready = 1;
+ reportstruct->transit_ready = true;
reportstruct->burstperiod = burst_info.burst_period_us;
}
currLen += n;
@@ -237,7 +248,7 @@ void Server::RunTCP () {
if (!reportstruct->transit_ready) {
n = recv(mSettings->mSock, mSettings->mBuf, readLen, 0);
if (n > 0) {
- reportstruct->emptyreport = 0;
+ reportstruct->emptyreport = false;
if (isburst) {
burst_nleft -= n;
if (burst_nleft == 0) {
@@ -247,7 +258,7 @@ void Server::RunTCP () {
reportstruct->isochStartTime.tv_usec = burst_info.send_tt.write_tv_usec;
reportstruct->burstperiod = burst_info.burst_period_us;
}
- reportstruct->transit_ready = 1;
+ reportstruct->transit_ready = true;
}
}
} else if (n == 0) {
@@ -256,9 +267,14 @@ void Server::RunTCP () {
thread_debug("Server thread detected EOF on socket %d", mSettings->mSock);
#endif
} else if ((n < 0) && (FATALTCPREADERR(errno))) {
- WARN_errno(1, "recv");
peerclose = true;
n = 0;
+ now.setnow();
+ char warnbuf[WARNBUFSIZE];
+ snprintf(warnbuf, sizeof(warnbuf), "%stcp recv (%ld.%ld)",\
+ mSettings->mTransferIDStr, now.getSecs(), now.getUsecs());
+ warnbuf[sizeof(warnbuf)-1] = '\0';
+ WARN_errno(1, warnbuf);
}
currLen += n;
}
@@ -305,44 +321,103 @@ void Server::PostNullEvent () {
// push a nonevent into the packet ring
// this will cause the reporter to process
// up to this event
- memset(reportstruct, 0, sizeof(struct ReportStruct));
+ struct ReportStruct report_nopacket;
+ memset(&report_nopacket, 0, sizeof(struct ReportStruct));
now.setnow();
- reportstruct->packetTime.tv_sec = now.getSecs();
- reportstruct->packetTime.tv_usec = now.getUsecs();
- reportstruct->emptyreport=1;
- ReportPacket(myReport, reportstruct);
+ report_nopacket.packetTime.tv_sec = now.getSecs();
+ report_nopacket.packetTime.tv_usec = now.getUsecs();
+ report_nopacket.emptyreport = true;
+ report_nopacket.err_readwrite = WriteNoAccount;
+ reportstruct->packetTime = report_nopacket.packetTime; // needed for the InProgress loop test
+ ReportPacket(myReport, &report_nopacket);
}
inline bool Server::ReadBBWithRXTimestamp () {
bool rc = false;
int n;
- while (1) {
- if ((n = recvn(mySocket, mSettings->mBuf, mSettings->mBounceBackBytes, 0)) == mSettings->mBounceBackBytes) {
- struct bounceback_hdr *bbhdr = reinterpret_cast<struct bounceback_hdr *>(mSettings->mBuf);
- uint16_t bbflags = ntohs(bbhdr->bbflags);
- if (!(bbflags & HEADER_BBSTOP)) {
+ while (InProgress()) {
+ int read_offset = 0;
+ RETRY_READ :
+ n = recvn(mySocket, (mSettings->mBuf + read_offset), (mSettings->mBounceBackBytes - read_offset), 0);
+ if (n > 0) {
+ read_offset += n;
+ if (read_offset == mSettings->mBounceBackBytes) {
+ struct bounceback_hdr *bbhdr = reinterpret_cast<struct bounceback_hdr *>(mSettings->mBuf);
+ uint16_t bbflags = ntohs(bbhdr->bbflags);
now.setnow();
reportstruct->packetTime.tv_sec = now.getSecs();
reportstruct->packetTime.tv_usec = now.getUsecs();
- reportstruct->emptyreport=0;
+ reportstruct->emptyreport = false;
reportstruct->packetLen = mSettings->mBounceBackBytes;
// write the rx timestamp back into the payload
bbhdr->bbserverRx_ts.sec = htonl(reportstruct->packetTime.tv_sec);
bbhdr->bbserverRx_ts.usec = htonl(reportstruct->packetTime.tv_usec);
ReportPacket(myReport, reportstruct);
- rc = true;
+ if (!(bbflags & HEADER_BBSTOP)) {
+ rc = true;
+ } else {
+ // last BB write received from client, false return code stops this side
+ }
+ break;
+ }
+ } else if (n == 0) {
+ peerclose = true;
+ } else if (n == IPERF_SOCKET_ERROR_NONFATAL) {
+ PostNullEvent();
+ if (InProgress())
+ goto RETRY_READ;
+ } else {
+ if (FATALTCPREADERR(errno)) {
+ WARN_errno(1, "fatal bounceback read");
+ peerclose = true;
+ break;
} else {
+ WARN(1, "timeout: bounceback read");
+ PostNullEvent();
+ if (InProgress())
+ goto RETRY_READ;
+ }
+ }
+ }
+ return rc;
+}
+
+inline bool Server::WriteBB () {
+ int n;
+ bool rc = false;
+ struct bounceback_hdr *bbhdr = reinterpret_cast<struct bounceback_hdr *>(mSettings->mBuf);
+ now.setnow();
+ bbhdr->bbserverTx_ts.sec = htonl(now.getSecs());
+ bbhdr->bbserverTx_ts.usec = htonl(now.getUsecs());
+ if (mSettings->mTOS) {
+ bbhdr->tos = htons((uint16_t)(mSettings->mTOS & 0xFF));
+ }
+ int write_offset = 0;
+ reportstruct->writecnt = 0;
+ int writelen = mSettings->mBounceBackReplyBytes;
+ while (InProgress()) {
+ n = writen(mySocket, (mSettings->mBuf + write_offset), (writelen - write_offset), &reportstruct->writecnt);
+ if (n < 0) {
+ if (FATALTCPWRITERR(errno)) {
+ reportstruct->err_readwrite=WriteErrFatal;
+ FAIL_errno(1, "tcp bounceback writen", mSettings);
peerclose = true;
+ break;
+ } else {
+ PostNullEvent();
+ continue;
}
- break;
- } else if (n==0) {
- peerclose = true;
- break;
- } else if (n == -2){
+ }
+ write_offset += n;
+ if (write_offset < writelen) {
+ WARN_errno(1, "tcp bounceback writen incomplete");
PostNullEvent();
- } else {
- break;
+ continue;
}
+ reportstruct->emptyreport = false;
+ reportstruct->err_readwrite=WriteSuccess;
+ reportstruct->packetLen = writelen;
+ return true;
}
return rc;
}
@@ -374,40 +449,21 @@ void Server::RunBounceBackTCP () {
reportstruct->packetTime.tv_sec = now.getSecs();
reportstruct->packetTime.tv_usec = now.getUsecs();
reportstruct->packetLen = mSettings->mBounceBackBytes;
- reportstruct->emptyreport=0;
+ reportstruct->emptyreport = false;
ReportPacket(myReport, reportstruct);
- while (InProgress()) {
- int n;
- reportstruct->emptyreport=1;
- do {
- struct bounceback_hdr *bbhdr = reinterpret_cast<struct bounceback_hdr *>(mSettings->mBuf);
- if (mSettings->mBounceBackHold) {
-#if HAVE_DECL_TCP_QUICKACK
- if (isTcpQuickAck(mSettings)) {
- int opt = 1;
- Socklen_t len = sizeof(opt);
- int rc = setsockopt(mySocket, IPPROTO_TCP, TCP_QUICKACK,
- reinterpret_cast<char*>(&opt), len);
- WARN_errno(rc == SOCKET_ERROR, "setsockopt TCP_QUICKACK");
- }
-#endif
- delay_loop(mSettings->mBounceBackHold);
- }
- now.setnow();
- bbhdr->bbserverTx_ts.sec = htonl(now.getSecs());
- bbhdr->bbserverTx_ts.usec = htonl(now.getUsecs());
- if (mSettings->mTOS) {
- bbhdr->tos = htons((uint16_t)(mSettings->mTOS & 0xFF));
- }
- if ((n = writen(mySocket, mSettings->mBuf, mSettings->mBounceBackBytes, &reportstruct->writecnt)) == mSettings->mBounceBackBytes) {
- reportstruct->emptyreport=0;
- reportstruct->packetLen = n;
- ReportPacket(myReport, reportstruct);
- } else {
+ int rc;
+ while (InProgress() && (rc = WriteBB())) {
+ if (rc) {
+ ReportPacket(myReport, reportstruct);
+ if (ReadBBWithRXTimestamp())
+ continue;
+ else {
break;
}
- } while (ReadBBWithRXTimestamp());
+ } else {
+ break;
+ }
}
disarm_itimer();
// stop timing
@@ -471,10 +527,17 @@ inline void Server::SetReportStartTime () {
// Servers that aren't full duplex use the accept timestamp for start
myReport->info.ts.startTime.tv_sec = mSettings->sent_time.tv_sec;
myReport->info.ts.startTime.tv_usec = mSettings->sent_time.tv_usec;
- } else if (!TimeZero(mSettings->accept_time) && !isTxStartTime(mSettings)) {
+ } else if (!TimeZero(mSettings->accept_time)) {
// Servers that aren't full duplex use the accept timestamp for start
myReport->info.ts.startTime.tv_sec = mSettings->accept_time.tv_sec;
myReport->info.ts.startTime.tv_usec = mSettings->accept_time.tv_usec;
+ // The client may have had a barrier between the connect and start of traffic, check and adjust
+ if (mSettings->barrier_time) {
+ now.setnow();
+ if (now.subUsec(mSettings->accept_time) >= mSettings->barrier_time) {
+ TimeAddIntUsec(myReport->info.ts.startTime, mSettings->barrier_time);
+ }
+ }
} else {
now.setnow();
myReport->info.ts.startTime.tv_sec = now.getSecs();
@@ -579,6 +642,20 @@ void Server::ClientReverseFirstRead (void) {
bool Server::InitTrafficLoop (void) {
bool UDPReady = true;
+ if (isSyncTransferID(mSettings)) {
+ if (mSettings->mPeerTransferID != mSettings->mTransferID) {
+ int len = snprintf(NULL, 0, "%sTransfer ID %d remapped to %d\n", \
+ mSettings->mTransferIDStr, mSettings->mTransferID, mSettings->mPeerTransferID);
+ char *text = (char *) calloc(len+1, sizeof(char));
+ if (text) {
+ snprintf(text, len, "%sTransfer ID %d remapped to %d\n", \
+ mSettings->mTransferIDStr, mSettings->mTransferID, mSettings->mPeerTransferID);
+ PostReport(InitStringReport(text));
+ FREE_ARRAY(text);
+ }
+ updateTransferIDPeer(mSettings);
+ }
+ }
myJob = InitIndividualReport(mSettings);
myReport = static_cast<struct ReporterData *>(myJob->this_report);
assert(myJob != NULL);
@@ -598,21 +675,42 @@ bool Server::InitTrafficLoop (void) {
reportstruct->l2errors = 0x0;
int setfullduplexflag = 0;
+ Timestamp now;
+
+ if ((mSettings->txstart_epoch.tv_sec > 0) && (mSettings->txstart_epoch.tv_sec - now.getSecs()) > 1) {
+ // Have the server thread wait on the client's epoch start
+ // unblocking one second ahead
+ struct timeval wait_until = mSettings->txstart_epoch;
+ wait_until.tv_sec -= 1;
+ clock_usleep_abstime(&wait_until);
+ }
if (isFullDuplex(mSettings) && !isServerReverse(mSettings)) {
assert(mSettings->mFullDuplexReport != NULL);
if ((setfullduplexflag = fullduplex_start_barrier(&mSettings->mFullDuplexReport->fullduplex_barrier)) < 0)
exit(-1);
}
- Timestamp now;
if (isReverse(mSettings)) {
mSettings->accept_time.tv_sec = now.getSecs();
mSettings->accept_time.tv_usec = now.getUsecs();
ClientReverseFirstRead();
}
if (isTripTime(mSettings)) {
- if ((abs(now.getSecs() - mSettings->sent_time.tv_sec)) > MAXDIFFTIMESTAMPSECS) {
+ int diff_tolerance;
+ if (mSettings->mInterval && (mSettings->mIntervalMode == kInterval_Time)) {
+ diff_tolerance = ceil(mSettings->mInterval / 1000000);
+ } else {
+ diff_tolerance = MAXDIFFTIMESTAMPSECS;
+ }
+ if (diff_tolerance < 2) {
+ diff_tolerance = 2; // min is 2 seconds
+ }
+ if (mSettings->txstart_epoch.tv_sec > 0) {
+ mSettings->accept_time.tv_sec = mSettings->txstart_epoch.tv_sec;
+ mSettings->accept_time.tv_usec = mSettings->txstart_epoch.tv_usec;
+ mSettings->sent_time = mSettings->accept_time; // the first sent time w/epoch starts uses now()
+ } else if ((abs(now.getSecs() - mSettings->sent_time.tv_sec)) > diff_tolerance) {
unsetTripTime(mSettings);
- fprintf(stdout,"WARN: ignore --trip-times because client didn't provide valid start timestamp within %d seconds of now\n", MAXDIFFTIMESTAMPSECS);
+ fprintf(stdout,"WARN: ignore --trip-times because client didn't provide valid start timestamp within %d seconds of now\n", diff_tolerance);
mSettings->accept_time.tv_sec = now.getSecs();
mSettings->accept_time.tv_usec = now.getUsecs();
}
@@ -643,8 +741,8 @@ bool Server::InitTrafficLoop (void) {
reportstruct->packetLen = mSettings->firstreadbytes;
if (isUDP(mSettings)) {
int offset = 0;
- UDPReady = !ReadPacketID(offset);
reportstruct->packetTime = mSettings->accept_time;
+ UDPReady = !ReadPacketID(offset);
} else {
reportstruct->sentTime.tv_sec = myReport->info.ts.startTime.tv_sec;
reportstruct->sentTime.tv_usec = myReport->info.ts.startTime.tv_usec;
@@ -656,21 +754,36 @@ bool Server::InitTrafficLoop (void) {
}
inline int Server::ReadWithRxTimestamp () {
- long currLen;
- int tsdone = 0;
+ int currLen;
+ int tsdone = false;
-#if HAVE_DECL_SO_TIMESTAMP
+ reportstruct->err_readwrite = ReadSuccess;
+
+#if (HAVE_DECL_SO_TIMESTAMP) && (HAVE_DECL_MSG_CTRUNC)
cmsg = reinterpret_cast<struct cmsghdr *>(&ctrl);
currLen = recvmsg(mSettings->mSock, &message, mSettings->recvflags);
if (currLen > 0) {
- for (cmsg = CMSG_FIRSTHDR(&message); cmsg != NULL;
- cmsg = CMSG_NXTHDR(&message, cmsg)) {
- if (cmsg->cmsg_level == SOL_SOCKET &&
- cmsg->cmsg_type == SCM_TIMESTAMP &&
- cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) {
- memcpy(&(reportstruct->packetTime), CMSG_DATA(cmsg), sizeof(struct timeval));
- tsdone = 1;
+#if HAVE_DECL_MSG_TRUNC
+ if (message.msg_flags & MSG_TRUNC) {
+ reportstruct->err_readwrite = ReadErrLen;
+ }
+#endif
+ if (!(message.msg_flags & MSG_CTRUNC)) {
+ for (cmsg = CMSG_FIRSTHDR(&message); cmsg != NULL;
+ cmsg = CMSG_NXTHDR(&message, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_TIMESTAMP &&
+ cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) {
+ memcpy(&(reportstruct->packetTime), CMSG_DATA(cmsg), sizeof(struct timeval));
+ if (TimeZero(myReport->info.ts.prevpacketTime)) {
+ myReport->info.ts.prevpacketTime = reportstruct->packetTime;
+ }
+ tsdone = true;
+ }
}
+ } else if (ctrunc_warn_enable && mSettings->mTransferIDStr) {
+ fprintf(stderr, "%sWARN: recvmsg MSG_CTRUNC occured\n", mSettings->mTransferIDStr);
+ ctrunc_warn_enable = false;
}
}
#else
@@ -678,13 +791,15 @@ inline int Server::ReadWithRxTimestamp () {
#endif
if (currLen <=0) {
// Socket read timeout or read error
- reportstruct->emptyreport=1;
+ reportstruct->emptyreport = true;
if (currLen == 0) {
peerclose = true;
} else if (FATALUDPREADERR(errno)) {
WARN_errno(1, "recvmsg");
currLen = 0;
peerclose = true;
+ } else {
+ reportstruct->err_readwrite = ReadTimeo;
}
} else if (TimeZero(myReport->info.ts.prevpacketTime)) {
myReport->info.ts.prevpacketTime = reportstruct->packetTime;
@@ -704,29 +819,45 @@ inline bool Server::ReadPacketID (int offset_adjust) {
// terminate when datagram begins with negative index
// the datagram ID should be correct, just negated
+ // read the sent timestamp from the rx packet
+ reportstruct->sentTime.tv_sec = ntohl(mBuf_UDP->tv_sec);
+ reportstruct->sentTime.tv_usec = ntohl(mBuf_UDP->tv_usec);
if (isSeqNo64b(mSettings)) {
- // New client - Signed PacketID packed into unsigned id2,id
- reportstruct->packetID = (static_cast<uint32_t>(ntohl(mBuf_UDP->id))) | (static_cast<uintmax_t>(ntohl(mBuf_UDP->id2)) << 32);
+ // New client - Signed PacketID packed into unsigned id2,id
+ reportstruct->packetID = (static_cast<uint32_t>(ntohl(mBuf_UDP->id))) | (static_cast<uintmax_t>(ntohl(mBuf_UDP->id2)) << 32);
#ifdef HAVE_PACKET_DEBUG
- printf("id 0x%x, 0x%x -> %" PRIdMAX " (0x%" PRIxMAX ")\n",
- ntohl(mBuf_UDP->id), ntohl(mBuf_UDP->id2), reportstruct->packetID, reportstruct->packetID);
+ if (isTripTime(mSettings)) {
+ int len = snprintf(NULL,0,"%sPacket id 0x%x, 0x%x -> %" PRIdMAX " (0x%" PRIxMAX ") Sent: %ld.%ld6 Received: %ld.%ld6 Delay: %f\n", \
+ mSettings->mTransferIDStr,ntohl(mBuf_UDP->id), ntohl(mBuf_UDP->id2), reportstruct->packetID, reportstruct->packetID, \
+ reportstruct->sentTime.tv_sec, reportstruct->sentTime.tv_usec, \
+ reportstruct->packetTime.tv_sec, reportstruct->packetTime.tv_usec, TimeDifference(reportstruct->packetTime, reportstruct->sentTime));
+ char *text = (char *) calloc(len+1, sizeof(char));
+ if (text) {
+ snprintf(text, len,"%sPacket ID id 0x%x, 0x%x -> %" PRIdMAX " (0x%" PRIxMAX ") Sent: %ld.%ld Received: %ld.%ld Delay: %f\n", \
+ mSettings->mTransferIDStr,ntohl(mBuf_UDP->id), ntohl(mBuf_UDP->id2), reportstruct->packetID, reportstruct->packetID, \
+ reportstruct->sentTime.tv_sec, reportstruct->sentTime.tv_usec, \
+ reportstruct->packetTime.tv_sec, reportstruct->packetTime.tv_usec, TimeDifference(reportstruct->packetTime, reportstruct->sentTime));
+ PostReport(InitStringReport(text));
+ FREE_ARRAY(text);
+ }
+ } else {
+ printf("id 0x%x, 0x%x -> %" PRIdMAX " (0x%" PRIxMAX ")\n",
+ ntohl(mBuf_UDP->id), ntohl(mBuf_UDP->id2), reportstruct->packetID, reportstruct->packetID);
+ }
#endif
} else {
- // Old client - Signed PacketID in Signed id
- reportstruct->packetID = static_cast<int32_t>(ntohl(mBuf_UDP->id));
+ // Old client - Signed PacketID in Signed id
+ reportstruct->packetID = static_cast<int32_t>(ntohl(mBuf_UDP->id));
#ifdef HAVE_PACKET_DEBUG
- printf("id 0x%x -> %" PRIdMAX " (0x%" PRIxMAX ")\n",
- ntohl(mBuf_UDP->id), reportstruct->packetID, reportstruct->packetID);
+ printf("id 0x%x -> %" PRIdMAX " (0x%" PRIxMAX ")\n",
+ ntohl(mBuf_UDP->id), reportstruct->packetID, reportstruct->packetID);
#endif
}
if (reportstruct->packetID < 0) {
- reportstruct->packetID = - reportstruct->packetID;
- terminate = true;
+ reportstruct->packetID = -reportstruct->packetID;
+ terminate = true;
}
- // read the sent timestamp from the rx packet
- reportstruct->sentTime.tv_sec = ntohl(mBuf_UDP->tv_sec);
- reportstruct->sentTime.tv_usec = ntohl(mBuf_UDP->tv_usec);
return terminate;
}
@@ -749,7 +880,7 @@ void Server::L2_processing () {
if (L2_quintuple_filter() != 0) {
reportstruct->l2errors |= L2UNKNOWN;
reportstruct->l2errors |= L2CSUMERR;
- reportstruct->emptyreport = 1;
+ reportstruct->emptyreport = true;
}
}
if (!(reportstruct->l2errors & L2UNKNOWN)) {
@@ -759,7 +890,7 @@ void Server::L2_processing () {
if (rc) {
reportstruct->l2errors |= L2CSUMERR;
if ((!(reportstruct->l2errors & L2LENERR)) && (L2_quintuple_filter() != 0)) {
- reportstruct->emptyreport = 1;
+ reportstruct->emptyreport = true;
reportstruct->l2errors |= L2UNKNOWN;
}
}
@@ -848,7 +979,7 @@ int Server::L2_quintuple_filter () {
}
inline void Server::udp_isoch_processing (int rxlen) {
- reportstruct->transit_ready = 0;
+ reportstruct->transit_ready = false;
// Ignore runt sized isoch packets
if (rxlen < static_cast<int>(sizeof(struct UDP_datagram) + sizeof(struct client_hdr_v1) + sizeof(struct client_hdrext) + sizeof(struct isoch_payload))) {
reportstruct->burstsize = 0;
@@ -865,7 +996,7 @@ inline void Server::udp_isoch_processing (int rxlen) {
reportstruct->burstperiod = ntohl(udp_pkt->isoch.burstperiod);
reportstruct->remaining = ntohl(udp_pkt->isoch.remaining);
if ((reportstruct->remaining == (uint32_t) rxlen) && ((reportstruct->frameID - reportstruct->prevframeID) == 1)) {
- reportstruct->transit_ready = 1;
+ reportstruct->transit_ready = true;
}
}
}
@@ -891,13 +1022,13 @@ void Server::RunUDP () {
// bandwidth accounting, basically it's indicating
// that the reportstruct itself couldn't be
// completely filled out.
- reportstruct->emptyreport=1;
+ reportstruct->emptyreport = true;
reportstruct->packetLen=0;
// read the next packet with timestamp
// will also set empty report or not
rxlen=ReadWithRxTimestamp();
if (!peerclose && (rxlen > 0)) {
- reportstruct->emptyreport = 0;
+ reportstruct->emptyreport = false;
reportstruct->packetLen = rxlen;
if (isL2LengthCheck(mSettings)) {
reportstruct->l2len = rxlen;
@@ -924,7 +1055,7 @@ void Server::RunUDP () {
}
}
disarm_itimer();
- int do_close = EndJob(myJob, reportstruct);
+ bool do_close = EndJob(myJob, reportstruct);
if (!isMulticast(mSettings) && !isNoUDPfin(mSettings)) {
// send a UDP acknowledgement back except when:
// 1) we're NOT receiving multicast