|
|
@ -63,7 +63,7 @@ namespace stream |
|
|
|
m_AckSendTimer (m_Service), m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (port), |
|
|
|
m_AckSendTimer (m_Service), m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (port), |
|
|
|
m_WindowSize (MIN_WINDOW_SIZE), m_RTT (INITIAL_RTT), m_RTO (INITIAL_RTO), |
|
|
|
m_WindowSize (MIN_WINDOW_SIZE), m_RTT (INITIAL_RTT), m_RTO (INITIAL_RTO), |
|
|
|
m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0) |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0), m_MTU (STREAMING_MTU) |
|
|
|
{ |
|
|
|
{ |
|
|
|
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); |
|
|
|
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); |
|
|
|
m_RemoteIdentity = remote->GetIdentity (); |
|
|
|
m_RemoteIdentity = remote->GetIdentity (); |
|
|
@ -75,7 +75,7 @@ namespace stream |
|
|
|
m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), m_AckSendTimer (m_Service), |
|
|
|
m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), m_AckSendTimer (m_Service), |
|
|
|
m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (0), m_WindowSize (MIN_WINDOW_SIZE), |
|
|
|
m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (0), m_WindowSize (MIN_WINDOW_SIZE), |
|
|
|
m_RTT (INITIAL_RTT), m_RTO (INITIAL_RTO), m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_RTT (INITIAL_RTT), m_RTO (INITIAL_RTO), m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0) |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0), m_MTU (STREAMING_MTU) |
|
|
|
{ |
|
|
|
{ |
|
|
|
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); |
|
|
|
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); |
|
|
|
} |
|
|
|
} |
|
|
@ -473,6 +473,12 @@ namespace stream |
|
|
|
{ |
|
|
|
{ |
|
|
|
// initial packet
|
|
|
|
// initial packet
|
|
|
|
m_Status = eStreamStatusOpen; |
|
|
|
m_Status = eStreamStatusOpen; |
|
|
|
|
|
|
|
if (!m_RemoteLeaseSet) m_RemoteLeaseSet = m_LocalDestination.GetOwner ()->FindLeaseSet (m_RemoteIdentity->GetIdentHash ());; |
|
|
|
|
|
|
|
if (m_RemoteLeaseSet) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_RoutingSession = m_LocalDestination.GetOwner ()->GetRoutingSession (m_RemoteLeaseSet, true); |
|
|
|
|
|
|
|
m_MTU = m_RoutingSession->IsRatchets () ? STREAMING_MTU_RATCHETS : STREAMING_MTU; |
|
|
|
|
|
|
|
} |
|
|
|
uint16_t flags = PACKET_FLAG_SYNCHRONIZE | PACKET_FLAG_FROM_INCLUDED | |
|
|
|
uint16_t flags = PACKET_FLAG_SYNCHRONIZE | PACKET_FLAG_FROM_INCLUDED | |
|
|
|
PACKET_FLAG_SIGNATURE_INCLUDED | PACKET_FLAG_MAX_PACKET_SIZE_INCLUDED; |
|
|
|
PACKET_FLAG_SIGNATURE_INCLUDED | PACKET_FLAG_MAX_PACKET_SIZE_INCLUDED; |
|
|
|
if (isNoAck) flags |= PACKET_FLAG_NO_ACK; |
|
|
|
if (isNoAck) flags |= PACKET_FLAG_NO_ACK; |
|
|
@ -486,7 +492,7 @@ namespace stream |
|
|
|
size += 2; // options size
|
|
|
|
size += 2; // options size
|
|
|
|
m_LocalDestination.GetOwner ()->GetIdentity ()->ToBuffer (packet + size, identityLen); |
|
|
|
m_LocalDestination.GetOwner ()->GetIdentity ()->ToBuffer (packet + size, identityLen); |
|
|
|
size += identityLen; // from
|
|
|
|
size += identityLen; // from
|
|
|
|
htobe16buf (packet + size, STREAMING_MTU); |
|
|
|
htobe16buf (packet + size, m_MTU); |
|
|
|
size += 2; // max packet size
|
|
|
|
size += 2; // max packet size
|
|
|
|
if (isOfflineSignature) |
|
|
|
if (isOfflineSignature) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -498,7 +504,7 @@ namespace stream |
|
|
|
memset (signature, 0, signatureLen); // zeroes for now
|
|
|
|
memset (signature, 0, signatureLen); // zeroes for now
|
|
|
|
size += signatureLen; // signature
|
|
|
|
size += signatureLen; // signature
|
|
|
|
htobe16buf (optionsSize, packet + size - 2 - optionsSize); // actual options size
|
|
|
|
htobe16buf (optionsSize, packet + size - 2 - optionsSize); // actual options size
|
|
|
|
size += m_SendBuffer.Get (packet + size, STREAMING_MTU); // payload
|
|
|
|
size += m_SendBuffer.Get (packet + size, m_MTU); // payload
|
|
|
|
m_LocalDestination.GetOwner ()->Sign (packet, size, signature); |
|
|
|
m_LocalDestination.GetOwner ()->Sign (packet, size, signature); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -508,7 +514,7 @@ namespace stream |
|
|
|
size += 2; // flags
|
|
|
|
size += 2; // flags
|
|
|
|
htobuf16 (packet + size, 0); // no options
|
|
|
|
htobuf16 (packet + size, 0); // no options
|
|
|
|
size += 2; // options size
|
|
|
|
size += 2; // options size
|
|
|
|
size += m_SendBuffer.Get(packet + size, STREAMING_MTU); // payload
|
|
|
|
size += m_SendBuffer.Get(packet + size, m_MTU); // payload
|
|
|
|
} |
|
|
|
} |
|
|
|
p->len = size; |
|
|
|
p->len = size; |
|
|
|
packets.push_back (p); |
|
|
|
packets.push_back (p); |
|
|
|