|
347 |
" deferring close, state " << m_state); |
347 |
" deferring close, state " << m_state); |
348 |
return 0; |
348 |
return 0; |
349 |
} |
349 |
} |
350 |
m_finSequence = m_nextTxSequence + SequenceNumber (1); |
350 |
m_finSequence = m_nextTxSequence + SequenceNumber32 (1); |
351 |
Actions_t action = ProcessEvent (APP_CLOSE); |
351 |
Actions_t action = ProcessEvent (APP_CLOSE); |
352 |
ProcessAction (action); |
352 |
ProcessAction (action); |
353 |
return 0; |
353 |
return 0; |
|
548 |
<< m_bufferedData.size () |
548 |
<< m_bufferedData.size () |
549 |
<< " time " << Simulator::Now ()); |
549 |
<< " time " << Simulator::Now ()); |
550 |
i = m_bufferedData.begin (); |
550 |
i = m_bufferedData.begin (); |
551 |
SequenceNumber s1 = 0; |
551 |
SequenceNumber32 s1 (0); |
552 |
if (i->first > m_nextRxSequence) |
552 |
if (i->first > m_nextRxSequence) |
553 |
{ |
553 |
{ |
554 |
break; // we're done, no more in-sequence data exits |
554 |
break; // we're done, no more in-sequence data exits |
|
588 |
uint32_t avail = maxSize - outPacket->GetSize(); |
588 |
uint32_t avail = maxSize - outPacket->GetSize(); |
589 |
outPacket->AddAtEnd(i->second->CreateFragment(0,avail)); |
589 |
outPacket->AddAtEnd(i->second->CreateFragment(0,avail)); |
590 |
//put the rest back into the buffer |
590 |
//put the rest back into the buffer |
591 |
m_bufferedData[i->first+SequenceNumber(avail)] |
591 |
m_bufferedData[i->first+SequenceNumber32(avail)] |
592 |
= i->second->CreateFragment(avail,i->second->GetSize()-avail); |
592 |
= i->second->CreateFragment(avail,i->second->GetSize()-avail); |
593 |
m_rxAvailable += i->second->GetSize()-avail; |
593 |
m_rxAvailable += i->second->GetSize()-avail; |
594 |
m_rxBufSize += i->second->GetSize()-avail; |
594 |
m_rxBufSize += i->second->GetSize()-avail; |
|
971 |
// This is the cloned endpoint |
971 |
// This is the cloned endpoint |
972 |
// TCP SYN consumes one byte |
972 |
// TCP SYN consumes one byte |
973 |
m_nextRxSequence = tcpHeader.GetSequenceNumber () |
973 |
m_nextRxSequence = tcpHeader.GetSequenceNumber () |
974 |
+ SequenceNumber (1); |
974 |
+ SequenceNumber32 (1); |
975 |
SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); |
975 |
SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); |
976 |
} |
976 |
} |
977 |
|
977 |
|
|
979 |
case ACK_TX_1: |
979 |
case ACK_TX_1: |
980 |
NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action ACK_TX_1"); |
980 |
NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action ACK_TX_1"); |
981 |
// TCP SYN consumes one byte |
981 |
// TCP SYN consumes one byte |
982 |
m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); |
982 |
m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber32(1); |
983 |
m_nextTxSequence = tcpHeader.GetAckNumber (); |
983 |
m_nextTxSequence = tcpHeader.GetAckNumber (); |
984 |
m_firstPendingSequence = m_nextTxSequence; //bug 166 |
984 |
m_firstPendingSequence = m_nextTxSequence; //bug 166 |
985 |
NS_LOG_DEBUG ("TcpSocketImpl " << this << " ACK_TX_1" << |
985 |
NS_LOG_DEBUG ("TcpSocketImpl " << this << " ACK_TX_1" << |
|
1045 |
if (m_finSequence != m_nextRxSequence) |
1045 |
if (m_finSequence != m_nextRxSequence) |
1046 |
{ |
1046 |
{ |
1047 |
// process close later |
1047 |
// process close later |
1048 |
m_finSequence = tcpHeader.GetSequenceNumber () + SequenceNumber (p->GetSize ()); |
1048 |
m_finSequence = tcpHeader.GetSequenceNumber () + SequenceNumber32 (p->GetSize ()); |
1049 |
m_pendingClose = true; |
1049 |
m_pendingClose = true; |
1050 |
NS_LOG_LOGIC ("TcpSocketImpl " << this << " setting pendingClose" |
1050 |
NS_LOG_LOGIC ("TcpSocketImpl " << this << " setting pendingClose" |
1051 |
<< " rxseq " << tcpHeader.GetSequenceNumber () |
1051 |
<< " rxseq " << tcpHeader.GetSequenceNumber () |
|
1168 |
uint32_t sz = p->GetSize (); // Size of packet |
1168 |
uint32_t sz = p->GetSize (); // Size of packet |
1169 |
uint32_t remainingData = m_pendingData->SizeFromSeq( |
1169 |
uint32_t remainingData = m_pendingData->SizeFromSeq( |
1170 |
m_firstPendingSequence, |
1170 |
m_firstPendingSequence, |
1171 |
m_nextTxSequence + SequenceNumber (sz)); |
1171 |
m_nextTxSequence + SequenceNumber32 (sz)); |
1172 |
if (m_closeOnEmpty && (remainingData == 0)) |
1172 |
if (m_closeOnEmpty && (remainingData == 0)) |
1173 |
{ |
1173 |
{ |
1174 |
m_finSequence = m_nextTxSequence + SequenceNumber (1 + sz); |
1174 |
m_finSequence = m_nextTxSequence + SequenceNumber32 (1 + sz); |
1175 |
flags = TcpHeader::FIN; |
1175 |
flags = TcpHeader::FIN; |
1176 |
m_state = FIN_WAIT_1; |
1176 |
m_state = FIN_WAIT_1; |
1177 |
} |
1177 |
} |
|
1303 |
UnAckData_t::iterator next = m_bufferedData.upper_bound (m_nextRxSequence); |
1303 |
UnAckData_t::iterator next = m_bufferedData.upper_bound (m_nextRxSequence); |
1304 |
if (next != m_bufferedData.end ()) |
1304 |
if (next != m_bufferedData.end ()) |
1305 |
{ |
1305 |
{ |
1306 |
SequenceNumber nextBufferedSeq = next->first; |
1306 |
SequenceNumber32 nextBufferedSeq = next->first; |
1307 |
if (m_nextRxSequence + SequenceNumber(s) > nextBufferedSeq) |
1307 |
if (m_nextRxSequence + SequenceNumber32(s) > nextBufferedSeq) |
1308 |
{//tail end isn't all new, trim enough off the end |
1308 |
{//tail end isn't all new, trim enough off the end |
1309 |
s = nextBufferedSeq - m_nextRxSequence; |
1309 |
s = nextBufferedSeq - m_nextRxSequence; |
1310 |
} |
1310 |
} |
|
1344 |
NS_LOG_LOGIC ("Case 2, buffering " << tcpHeader.GetSequenceNumber () ); |
1344 |
NS_LOG_LOGIC ("Case 2, buffering " << tcpHeader.GetSequenceNumber () ); |
1345 |
UnAckData_t::iterator previous = |
1345 |
UnAckData_t::iterator previous = |
1346 |
m_bufferedData.lower_bound (tcpHeader.GetSequenceNumber ()); |
1346 |
m_bufferedData.lower_bound (tcpHeader.GetSequenceNumber ()); |
1347 |
SequenceNumber startSeq = tcpHeader.GetSequenceNumber(); |
1347 |
SequenceNumber32 startSeq = tcpHeader.GetSequenceNumber(); |
1348 |
if (previous != m_bufferedData.begin ()) |
1348 |
if (previous != m_bufferedData.begin ()) |
1349 |
{ |
1349 |
{ |
1350 |
--previous; |
1350 |
--previous; |
1351 |
startSeq = previous->first + SequenceNumber(previous->second->GetSize()); |
1351 |
startSeq = previous->first + SequenceNumber32(previous->second->GetSize()); |
1352 |
if (startSeq > tcpHeader.GetSequenceNumber ()) |
1352 |
if (startSeq > tcpHeader.GetSequenceNumber ()) |
1353 |
{ |
1353 |
{ |
1354 |
s = tcpHeader.GetSequenceNumber () + SequenceNumber(s) - startSeq; |
1354 |
s = tcpHeader.GetSequenceNumber () + SequenceNumber32(s) - startSeq; |
1355 |
} |
1355 |
} |
1356 |
else |
1356 |
else |
1357 |
{ |
1357 |
{ |
|
1362 |
UnAckData_t::iterator next = m_bufferedData.upper_bound (tcpHeader.GetSequenceNumber()); |
1362 |
UnAckData_t::iterator next = m_bufferedData.upper_bound (tcpHeader.GetSequenceNumber()); |
1363 |
if (next != m_bufferedData.end ()) |
1363 |
if (next != m_bufferedData.end ()) |
1364 |
{ |
1364 |
{ |
1365 |
SequenceNumber nextBufferedSeq = next->first; |
1365 |
SequenceNumber32 nextBufferedSeq = next->first; |
1366 |
if (startSeq + SequenceNumber(s) > nextBufferedSeq) |
1366 |
if (startSeq + SequenceNumber32(s) > nextBufferedSeq) |
1367 |
{//tail end isn't all new either, trim enough off the end |
1367 |
{//tail end isn't all new either, trim enough off the end |
1368 |
s = nextBufferedSeq - startSeq; |
1368 |
s = nextBufferedSeq - startSeq; |
1369 |
} |
1369 |
} |
|
1390 |
++next; |
1390 |
++next; |
1391 |
if(next != m_bufferedData.end()) |
1391 |
if(next != m_bufferedData.end()) |
1392 |
{ |
1392 |
{ |
1393 |
NS_ASSERT(next->first >= i->first + SequenceNumber(i->second->GetSize ())); |
1393 |
NS_ASSERT(next->first >= i->first + SequenceNumber32(i->second->GetSize ())); |
1394 |
} |
1394 |
} |
1395 |
} |
1395 |
} |
1396 |
else if (tcpHeader.GetSequenceNumber () + SequenceNumber(s) > m_nextRxSequence) |
1396 |
else if (tcpHeader.GetSequenceNumber () + SequenceNumber32(s) > m_nextRxSequence) |
1397 |
{//parial new data case, only part of the packet is new data |
1397 |
{//parial new data case, only part of the packet is new data |
1398 |
//trim the beginning |
1398 |
//trim the beginning |
1399 |
s = tcpHeader.GetSequenceNumber () + SequenceNumber(s) - m_nextRxSequence; //how much new |
1399 |
s = tcpHeader.GetSequenceNumber () + SequenceNumber32(s) - m_nextRxSequence; //how much new |
1400 |
//possibly trim off the end |
1400 |
//possibly trim off the end |
1401 |
UnAckData_t::iterator next = m_bufferedData.upper_bound (m_nextRxSequence); |
1401 |
UnAckData_t::iterator next = m_bufferedData.upper_bound (m_nextRxSequence); |
1402 |
if (next != m_bufferedData.end ()) |
1402 |
if (next != m_bufferedData.end ()) |
1403 |
{ |
1403 |
{ |
1404 |
SequenceNumber nextBufferedSeq = next->first; |
1404 |
SequenceNumber32 nextBufferedSeq = next->first; |
1405 |
if (m_nextRxSequence + SequenceNumber(s) > nextBufferedSeq) |
1405 |
if (m_nextRxSequence + SequenceNumber32(s) > nextBufferedSeq) |
1406 |
{//tail end isn't all new either, trim enough off the end |
1406 |
{//tail end isn't all new either, trim enough off the end |
1407 |
s = nextBufferedSeq - m_nextRxSequence; |
1407 |
s = nextBufferedSeq - m_nextRxSequence; |
1408 |
} |
1408 |
} |
1409 |
} |
1409 |
} |
1410 |
p = p->CreateFragment (m_nextRxSequence - tcpHeader.GetSequenceNumber (),s); |
1410 |
p = p->CreateFragment (m_nextRxSequence - tcpHeader.GetSequenceNumber (),s); |
1411 |
SequenceNumber start = m_nextRxSequence; |
1411 |
SequenceNumber32 start = m_nextRxSequence; |
1412 |
m_nextRxSequence += s; // Advance next expected sequence |
1412 |
m_nextRxSequence += s; // Advance next expected sequence |
1413 |
//buffer the new fragment, it'll be read by call to Recv |
1413 |
//buffer the new fragment, it'll be read by call to Recv |
1414 |
UnAckData_t::iterator i = m_bufferedData.find (start); |
1414 |
UnAckData_t::iterator i = m_bufferedData.find (start); |
|
1449 |
} |
1449 |
} |
1450 |
} |
1450 |
} |
1451 |
|
1451 |
|
1452 |
void TcpSocketImpl::RxBufFinishInsert (SequenceNumber seq) |
1452 |
void TcpSocketImpl::RxBufFinishInsert (SequenceNumber32 seq) |
1453 |
{ |
1453 |
{ |
1454 |
//putting data into the buffer might have filled in a sequence gap so we have |
1454 |
//putting data into the buffer might have filled in a sequence gap so we have |
1455 |
//to iterate through the list to find the largest contiguous sequenced chunk, |
1455 |
//to iterate through the list to find the largest contiguous sequenced chunk, |
|
1460 |
//make sure the buffer is logically sequenced |
1460 |
//make sure the buffer is logically sequenced |
1461 |
if(next != m_bufferedData.end()) |
1461 |
if(next != m_bufferedData.end()) |
1462 |
{ |
1462 |
{ |
1463 |
NS_ASSERT(next->first >= i->first + SequenceNumber(i->second->GetSize ())); |
1463 |
NS_ASSERT(next->first >= i->first + SequenceNumber32(i->second->GetSize ())); |
1464 |
} |
1464 |
} |
1465 |
while(next != m_bufferedData.end()) |
1465 |
while(next != m_bufferedData.end()) |
1466 |
{ |
1466 |
{ |
1467 |
if(i->first + SequenceNumber(i->second->GetSize ()) == next->first) |
1467 |
if(i->first + SequenceNumber32(i->second->GetSize ()) == next->first) |
1468 |
{ |
1468 |
{ |
1469 |
//next packet is in sequence, count it |
1469 |
//next packet is in sequence, count it |
1470 |
m_rxAvailable += next->second->GetSize(); |
1470 |
m_rxAvailable += next->second->GetSize(); |
|
1485 |
SendEmptyPacket (TcpHeader::ACK); |
1485 |
SendEmptyPacket (TcpHeader::ACK); |
1486 |
} |
1486 |
} |
1487 |
|
1487 |
|
1488 |
void TcpSocketImpl::CommonNewAck (SequenceNumber ack, bool skipTimer) |
1488 |
void TcpSocketImpl::CommonNewAck (SequenceNumber32 ack, bool skipTimer) |
1489 |
{ // CommonNewAck is called only for "New" (non-duplicate) acks |
1489 |
{ // CommonNewAck is called only for "New" (non-duplicate) acks |
1490 |
// and MUST be called by any subclass, from the NewAck function |
1490 |
// and MUST be called by any subclass, from the NewAck function |
1491 |
// Always cancel any pending re-tx timer on new acknowledgement |
1491 |
// Always cancel any pending re-tx timer on new acknowledgement |
|
1566 |
return CopyObject<TcpSocketImpl> (this); |
1566 |
return CopyObject<TcpSocketImpl> (this); |
1567 |
} |
1567 |
} |
1568 |
|
1568 |
|
1569 |
void TcpSocketImpl::NewAck (SequenceNumber seq) |
1569 |
void TcpSocketImpl::NewAck (SequenceNumber32 seq) |
1570 |
{ // New acknowledgement up to sequence number "seq" |
1570 |
{ // New acknowledgement up to sequence number "seq" |
1571 |
// Adjust congestion window in response to new ack's received |
1571 |
// Adjust congestion window in response to new ack's received |
1572 |
NS_LOG_FUNCTION (this << seq); |
1572 |
NS_LOG_FUNCTION (this << seq); |
|
1704 |
// Calculate remaining data for COE check |
1704 |
// Calculate remaining data for COE check |
1705 |
uint32_t remainingData = m_pendingData->SizeFromSeq ( |
1705 |
uint32_t remainingData = m_pendingData->SizeFromSeq ( |
1706 |
m_firstPendingSequence, |
1706 |
m_firstPendingSequence, |
1707 |
m_nextTxSequence + SequenceNumber(p->GetSize ())); |
1707 |
m_nextTxSequence + SequenceNumber32(p->GetSize ())); |
1708 |
if (m_closeOnEmpty && remainingData == 0) |
1708 |
if (m_closeOnEmpty && remainingData == 0) |
1709 |
{ // Add the FIN flag |
1709 |
{ // Add the FIN flag |
1710 |
flags = flags | TcpHeader::FIN; |
1710 |
flags = flags | TcpHeader::FIN; |