A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Haivision/srt/commit/a31e618e93ffa80afe57dfef0ea7d590ac380c3a below:

added packUniqueData(..) func · Haivision/srt@a31e618 · GitHub

@@ -9189,16 +9189,14 @@ int srt::CUDT::packLostData(CPacket& w_packet, steady_clock::time_point& w_origi

9189 9189

return 0;

9190 9190

}

9191 9191 9192 -

std::pair<int, steady_clock::time_point> srt::CUDT::packData(CPacket& w_packet)

9192 +

std::pair<bool, steady_clock::time_point> srt::CUDT::packData(CPacket& w_packet)

9193 9193

{

9194 9194

int payload = 0;

9195 9195

bool probe = false;

9196 9196

steady_clock::time_point origintime;

9197 9197

bool new_packet_packed = false;

9198 9198

bool filter_ctl_pkt = false;

9199 9199 9200 -

int kflg = EK_NOENC;

9201 - 9202 9200

const steady_clock::time_point enter_time = steady_clock::now();

9203 9201 9204 9202

if (!is_zero(m_tsNextSendTime) && enter_time > m_tsNextSendTime)

@@ -9217,7 +9215,7 @@ std::pair<int, steady_clock::time_point> srt::CUDT::packData(CPacket& w_packet)

9217 9215

// start the dissolving process, this process will

9218 9216

// not be started until this function is finished.

9219 9217

if (!m_bOpened)

9220 -

return std::make_pair(0, enter_time);

9218 +

return std::make_pair(false, enter_time);

9221 9219 9222 9220

payload = packLostData((w_packet), (origintime));

9223 9221

if (payload > 0)

@@ -9233,122 +9231,24 @@ std::pair<int, steady_clock::time_point> srt::CUDT::packData(CPacket& w_packet)

9233 9231

filter_ctl_pkt = true; // Mark that this packet ALREADY HAS timestamp field and it should not be set

9234 9232 9235 9233

// Stats

9236 -

{

9237 -

ScopedLock lg(m_StatsLock);

9238 -

m_stats.sndr.sentFilterExtra.count(1);

9239 -

}

9234 +

ScopedLock lg(m_StatsLock);

9235 +

m_stats.sndr.sentFilterExtra.count(1);

9240 9236

}

9241 9237

else

9242 9238

{

9243 -

// If no loss, and no packetfilter control packet, pack a new packet.

9244 - 9245 -

// Check the congestion/flow window limit

9246 -

const int cwnd = std::min(int(m_iFlowWindowSize), int(m_dCongestionWindow));

9247 -

const int flightspan = getFlightSpan();

9248 -

if (cwnd > flightspan)

9249 -

{

9250 -

// XXX Here it's needed to set kflg to msgno_bitset in the block stored in the

9251 -

// send buffer. This should be somehow avoided, the crypto flags should be set

9252 -

// together with encrypting, and the packet should be sent as is, when rexmitting.

9253 -

// It would be nice to research as to whether CSndBuffer::Block::m_iMsgNoBitset field

9254 -

// isn't a useless redundant state copy. If it is, then taking the flags here can be removed.

9255 -

kflg = m_pCryptoControl->getSndCryptoFlags();

9256 -

int pktskipseqno = 0;

9257 -

payload = m_pSndBuffer->readData((w_packet), (origintime), kflg, (pktskipseqno));

9258 -

if (pktskipseqno)

9259 -

{

9260 -

// Some packets were skipped due to TTL expiry.

9261 -

m_iSndCurrSeqNo = CSeqNo::incseq(m_iSndCurrSeqNo, pktskipseqno);

9262 -

}

9263 - 9264 -

if (payload)

9265 -

{

9266 -

// A CHANGE. The sequence number is currently added to the packet

9267 -

// when scheduling, not when extracting. This is a inter-migration form,

9268 -

// so still override the value, but trace it.

9269 -

m_iSndCurrSeqNo = CSeqNo::incseq(m_iSndCurrSeqNo);

9270 - 9271 -

// Do this checking only for groups and only at the very first moment,

9272 -

// when there's still nothing in the buffer. Otherwise there will be

9273 -

// a serious data discrepancy between the agent and the peer.

9274 -

// After increasing by 1, but being previously set as ISN-1, this should be == ISN,

9275 -

// if this is the very first packet to send.

9276 -

#if ENABLE_EXPERIMENTAL_BONDING

9277 -

// Fortunately here is only the procedure that verifies if the extraction

9278 -

// sequence is moved due to the difference between ISN caught during the existing

9279 -

// transmission and the first sequence possible to be used at the first sending

9280 -

// instruction. The group itself isn't being accessed.

9281 -

if (m_parent->m_GroupOf && m_iSndCurrSeqNo != w_packet.m_iSeqNo && m_iSndCurrSeqNo == m_iISN)

9282 -

{

9283 -

const int packetspan = CSeqNo::seqcmp(w_packet.m_iSeqNo, m_iSndCurrSeqNo);

9284 - 9285 -

HLOGC(qslog.Debug, log << CONID() << "packData: Fixing EXTRACTION sequence " << m_iSndCurrSeqNo

9286 -

<< " from SCHEDULING sequence " << w_packet.m_iSeqNo

9287 -

<< " DIFF: " << packetspan << " STAMP:" << BufferStamp(w_packet.m_pcData, w_packet.getLength()));

9288 - 9289 -

// This is the very first packet to be sent; so there's nothing in

9290 -

// the sending buffer yet, and therefore we are in a situation as just

9291 -

// after connection. No packets in the buffer, no packets are sent,

9292 -

// no ACK to be awaited. We can screw up all the variables that are

9293 -

// initialized from ISN just after connection.

9294 -

//

9295 -

// Additionally send the drop request to the peer so that it

9296 -

// won't stupidly request the packets to be retransmitted.

9297 -

// Don't do it if the difference isn't positive or exceeds the threshold.

9298 -

if (packetspan > 0)

9299 -

{

9300 -

int32_t seqpair[2];

9301 -

seqpair[0] = m_iSndCurrSeqNo;

9302 -

seqpair[1] = w_packet.m_iSeqNo;

9303 -

HLOGC(qslog.Debug, log << "... sending INITIAL DROP (ISN FIX): "

9304 -

<< "msg=" << MSGNO_SEQ::unwrap(w_packet.m_iMsgNo) << " SEQ:"

9305 -

<< seqpair[0] << " - " << seqpair[1] << "(" << packetspan << " packets)");

9306 -

sendCtrl(UMSG_DROPREQ, &w_packet.m_iMsgNo, seqpair, sizeof(seqpair));

9307 - 9308 -

// In case when this message is lost, the peer will still get the

9309 -

// UMSG_DROPREQ message when the agent realizes that the requested

9310 -

// packet are not present in the buffer (preadte the send buffer).

9311 -

}

9312 -

}

9313 -

else

9314 -

#endif

9315 -

{

9316 -

HLOGC(qslog.Debug, log << CONID() << "packData: Applying EXTRACTION sequence " << m_iSndCurrSeqNo

9317 -

<< " over SCHEDULING sequence " << w_packet.m_iSeqNo

9318 -

<< " DIFF: " << CSeqNo::seqcmp(m_iSndCurrSeqNo, w_packet.m_iSeqNo)

9319 -

<< " STAMP:" << BufferStamp(w_packet.m_pcData, w_packet.getLength()));

9320 - 9321 -

#if ENABLE_EXPERIMENTAL_BONDING

9322 -

HLOGC(qslog.Debug, log << "... CONDITION: IN GROUP: " << (m_parent->m_GroupOf ? "yes":"no")

9323 -

<< " extraction-seq=" << m_iSndCurrSeqNo << " scheduling-seq=" << w_packet.m_iSeqNo << " ISN=" << m_iISN);

9324 -

#endif

9325 - 9326 -

// Do this always when not in a group,

9327 -

w_packet.m_iSeqNo = m_iSndCurrSeqNo;

9328 -

}

9329 - 9330 -

// every 16 (0xF) packets, a packet pair is sent

9331 -

if ((w_packet.m_iSeqNo & PUMASK_SEQNO_PROBE) == 0)

9332 -

probe = true;

9333 - 9334 -

new_packet_packed = true;

9335 -

}

9336 -

else

9337 -

{

9338 -

m_tsNextSendTime = steady_clock::time_point();

9339 -

m_tdSendTimeDiff = steady_clock::duration();

9340 -

return std::make_pair(0, enter_time);

9341 -

}

9342 -

}

9343 -

else

9239 +

if (!packUniqueData(w_packet, origintime))

9344 9240

{

9345 -

HLOGC(qslog.Debug, log << "packData: CONGESTED: cwnd=min(" << m_iFlowWindowSize << "," << m_dCongestionWindow

9346 -

<< ")=" << cwnd << " seqlen=(" << m_iSndLastAck << "-" << m_iSndCurrSeqNo << ")=" << flightspan);

9347 9241

m_tsNextSendTime = steady_clock::time_point();

9348 9242

m_tdSendTimeDiff = steady_clock::duration();

9349 -

return std::make_pair(0, enter_time);

9243 +

return std::make_pair(false, enter_time);

9350 9244

}

9245 +

new_packet_packed = true;

9246 + 9247 +

// every 16 (0xF) packets, a packet pair is sent

9248 +

if ((w_packet.m_iSeqNo & PUMASK_SEQNO_PROBE) == 0)

9249 +

probe = true;

9351 9250 9251 +

payload = (int) w_packet.getLength();

9352 9252

reason = "normal";

9353 9253

}

9354 9254

@@ -9389,23 +9289,6 @@ std::pair<int, steady_clock::time_point> srt::CUDT::packData(CPacket& w_packet)

9389 9289 9390 9290

w_packet.m_iID = m_PeerID;

9391 9291 9392 -

/* Encrypt if 1st time this packet is sent and crypto is enabled */

9393 -

if (kflg)

9394 -

{

9395 -

// XXX Encryption flags are already set on the packet before calling this.

9396 -

// See readData() above.

9397 -

if (m_pCryptoControl->encrypt((w_packet)))

9398 -

{

9399 -

// Encryption failed

9400 -

//>>Add stats for crypto failure

9401 -

LOGC(qslog.Warn, log << "ENCRYPT FAILED - packet won't be sent, size=" << payload);

9402 -

// Encryption failed

9403 -

return std::make_pair(-1, enter_time);

9404 -

}

9405 -

payload = (int) w_packet.getLength(); /* Cipher may change length */

9406 -

reason += " (encrypted)";

9407 -

}

9408 - 9409 9292

if (new_packet_packed && m_PacketFilter)

9410 9293

{

9411 9294

HLOGC(qslog.Debug, log << "filter: Feeding packet for source clip");

@@ -9472,7 +9355,120 @@ std::pair<int, steady_clock::time_point> srt::CUDT::packData(CPacket& w_packet)

9472 9355

#endif

9473 9356

}

9474 9357 9475 -

return std::make_pair(payload, m_tsNextSendTime);

9358 +

return std::make_pair(payload >= 0, m_tsNextSendTime);

9359 +

}

9360 + 9361 +

bool srt::CUDT::packUniqueData(CPacket& w_packet, time_point& w_origintime)

9362 +

{

9363 +

// Check the congestion/flow window limit

9364 +

const int cwnd = std::min(int(m_iFlowWindowSize), int(m_dCongestionWindow));

9365 +

const int flightspan = getFlightSpan();

9366 +

if (cwnd <= flightspan)

9367 +

{

9368 +

HLOGC(qslog.Debug, log << "packData: CONGESTED: cwnd=min(" << m_iFlowWindowSize << "," << m_dCongestionWindow

9369 +

<< ")=" << cwnd << " seqlen=(" << m_iSndLastAck << "-" << m_iSndCurrSeqNo << ")=" << flightspan);

9370 +

return false;

9371 +

}

9372 + 9373 +

// XXX Here it's needed to set kflg to msgno_bitset in the block stored in the

9374 +

// send buffer. This should be somehow avoided, the crypto flags should be set

9375 +

// together with encrypting, and the packet should be sent as is, when rexmitting.

9376 +

// It would be nice to research as to whether CSndBuffer::Block::m_iMsgNoBitset field

9377 +

// isn't a useless redundant state copy. If it is, then taking the flags here can be removed.

9378 +

const int kflg = m_pCryptoControl->getSndCryptoFlags();

9379 +

int pktskipseqno = 0;

9380 +

const int pld_size = m_pSndBuffer->readData((w_packet), (w_origintime), kflg, (pktskipseqno));

9381 +

if (pktskipseqno)

9382 +

{

9383 +

// Some packets were skipped due to TTL expiry.

9384 +

m_iSndCurrSeqNo = CSeqNo::incseq(m_iSndCurrSeqNo, pktskipseqno);

9385 +

}

9386 + 9387 +

if (pld_size == 0)

9388 +

{

9389 +

return false;

9390 +

}

9391 + 9392 +

// A CHANGE. The sequence number is currently added to the packet

9393 +

// when scheduling, not when extracting. This is a inter-migration form,

9394 +

// so still override the value, but trace it.

9395 +

m_iSndCurrSeqNo = CSeqNo::incseq(m_iSndCurrSeqNo);

9396 + 9397 +

// Do this checking only for groups and only at the very first moment,

9398 +

// when there's still nothing in the buffer. Otherwise there will be

9399 +

// a serious data discrepancy between the agent and the peer.

9400 +

// After increasing by 1, but being previously set as ISN-1, this should be == ISN,

9401 +

// if this is the very first packet to send.

9402 +

#if ENABLE_EXPERIMENTAL_BONDING

9403 +

// Fortunately here is only the procedure that verifies if the extraction

9404 +

// sequence is moved due to the difference between ISN caught during the existing

9405 +

// transmission and the first sequence possible to be used at the first sending

9406 +

// instruction. The group itself isn't being accessed.

9407 +

if (m_parent->m_GroupOf && m_iSndCurrSeqNo != w_packet.m_iSeqNo && m_iSndCurrSeqNo == m_iISN)

9408 +

{

9409 +

const int packetspan = CSeqNo::seqcmp(w_packet.m_iSeqNo, m_iSndCurrSeqNo);

9410 + 9411 +

HLOGC(qslog.Debug, log << CONID() << "packData: Fixing EXTRACTION sequence " << m_iSndCurrSeqNo

9412 +

<< " from SCHEDULING sequence " << w_packet.m_iSeqNo

9413 +

<< " DIFF: " << packetspan << " STAMP:" << BufferStamp(w_packet.m_pcData, w_packet.getLength()));

9414 + 9415 +

// This is the very first packet to be sent; so there's nothing in

9416 +

// the sending buffer yet, and therefore we are in a situation as just

9417 +

// after connection. No packets in the buffer, no packets are sent,

9418 +

// no ACK to be awaited. We can screw up all the variables that are

9419 +

// initialized from ISN just after connection.

9420 +

//

9421 +

// Additionally send the drop request to the peer so that it

9422 +

// won't stupidly request the packets to be retransmitted.

9423 +

// Don't do it if the difference isn't positive or exceeds the threshold.

9424 +

if (packetspan > 0)

9425 +

{

9426 +

int32_t seqpair[2];

9427 +

seqpair[0] = m_iSndCurrSeqNo;

9428 +

seqpair[1] = w_packet.m_iSeqNo;

9429 +

HLOGC(qslog.Debug, log << "... sending INITIAL DROP (ISN FIX): "

9430 +

<< "msg=" << MSGNO_SEQ::unwrap(w_packet.m_iMsgNo) << " SEQ:"

9431 +

<< seqpair[0] << " - " << seqpair[1] << "(" << packetspan << " packets)");

9432 +

sendCtrl(UMSG_DROPREQ, &w_packet.m_iMsgNo, seqpair, sizeof(seqpair));

9433 + 9434 +

// In case when this message is lost, the peer will still get the

9435 +

// UMSG_DROPREQ message when the agent realizes that the requested

9436 +

// packet are not present in the buffer (preadte the send buffer).

9437 +

}

9438 +

}

9439 +

else

9440 +

#endif

9441 +

{

9442 +

HLOGC(qslog.Debug, log << CONID() << "packData: Applying EXTRACTION sequence " << m_iSndCurrSeqNo

9443 +

<< " over SCHEDULING sequence " << w_packet.m_iSeqNo

9444 +

<< " DIFF: " << CSeqNo::seqcmp(m_iSndCurrSeqNo, w_packet.m_iSeqNo)

9445 +

<< " STAMP:" << BufferStamp(w_packet.m_pcData, w_packet.getLength()));

9446 + 9447 +

#if ENABLE_EXPERIMENTAL_BONDING

9448 +

HLOGC(qslog.Debug, log << "... CONDITION: IN GROUP: " << (m_parent->m_GroupOf ? "yes":"no")

9449 +

<< " extraction-seq=" << m_iSndCurrSeqNo << " scheduling-seq=" << w_packet.m_iSeqNo << " ISN=" << m_iISN);

9450 +

#endif

9451 + 9452 +

// Do this always when not in a group,

9453 +

w_packet.m_iSeqNo = m_iSndCurrSeqNo;

9454 +

}

9455 + 9456 +

// Encrypt if 1st time this packet is sent and crypto is enabled

9457 +

if (kflg != EK_NOENC)

9458 +

{

9459 +

// Note that the packet header must have a valid seqno set, as it is used as a counter for encryption.

9460 +

// Other fields of the data packet header (e.g. timestamp, destination socket ID) are not used for the counter.

9461 +

// Cypher may change packet length!

9462 +

if (m_pCryptoControl->encrypt((w_packet)))

9463 +

{

9464 +

// Encryption failed

9465 +

//>>Add stats for crypto failure

9466 +

LOGC(qslog.Warn, log << "ENCRYPT FAILED - packet won't be sent, size=" << pld_size);

9467 +

return -1;

9468 +

}

9469 +

}

9470 + 9471 +

return true;

9476 9472

}

9477 9473 9478 9474

// This is a close request, but called from the


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4