src/internet/model/tcp-socket-base.cc
changeset 11510 030e5d6efdd6
parent 11508 e50a1cb4d7db
child 11511 2c614cf0b5bd
equal deleted inserted replaced
11509:265efea1f685 11510:030e5d6efdd6
  1076     }
  1076     }
  1077   else
  1077   else
  1078     { // Received RST or the TCP flags is invalid, in either case, terminate this socket
  1078     { // Received RST or the TCP flags is invalid, in either case, terminate this socket
  1079       if (tcpflags != TcpHeader::RST)
  1079       if (tcpflags != TcpHeader::RST)
  1080         { // this must be an invalid flag, send reset
  1080         { // this must be an invalid flag, send reset
  1081           NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
  1081           NS_LOG_LOGIC ("Illegal flag " << TcpHeader::FlagsToString (tcpflags) << " received. Reset packet is sent.");
  1082           SendRST ();
  1082           SendRST ();
  1083         }
  1083         }
  1084       CloseAndNotify ();
  1084       CloseAndNotify ();
  1085     }
  1085     }
  1086 }
  1086 }
  1201     }
  1201     }
  1202   else
  1202   else
  1203     { // Other in-sequence input
  1203     { // Other in-sequence input
  1204       if (tcpflags != TcpHeader::RST)
  1204       if (tcpflags != TcpHeader::RST)
  1205         { // When (1) rx of FIN+ACK; (2) rx of FIN; (3) rx of bad flags
  1205         { // When (1) rx of FIN+ACK; (2) rx of FIN; (3) rx of bad flags
  1206           NS_LOG_LOGIC ("Illegal flag " << std::hex << static_cast<uint32_t> (tcpflags) << std::dec << " received. Reset packet is sent.");
  1206           NS_LOG_LOGIC ("Illegal flag " << TcpHeader::FlagsToString (tcpflags) <<
       
  1207                         " received. Reset packet is sent.");
  1207           SendRST ();
  1208           SendRST ();
  1208         }
  1209         }
  1209       CloseAndNotify ();
  1210       CloseAndNotify ();
  1210     }
  1211     }
  1211 }
  1212 }
  1281     }
  1282     }
  1282   else
  1283   else
  1283     { // Other in-sequence input
  1284     { // Other in-sequence input
  1284       if (tcpflags != TcpHeader::RST)
  1285       if (tcpflags != TcpHeader::RST)
  1285         { // When (1) rx of SYN+ACK; (2) rx of FIN; (3) rx of bad flags
  1286         { // When (1) rx of SYN+ACK; (2) rx of FIN; (3) rx of bad flags
  1286           NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
  1287           NS_LOG_LOGIC ("Illegal flag " << TcpHeader::FlagsToString (tcpflags) <<
       
  1288                         " received. Reset packet is sent.");
  1287           if (m_endPoint)
  1289           if (m_endPoint)
  1288             {
  1290             {
  1289               m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
  1291               m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
  1290                                    InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
  1292                                    InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
  1291             }
  1293             }
  1337     }
  1339     }
  1338   else
  1340   else
  1339     { // This is a RST or bad flags
  1341     { // This is a RST or bad flags
  1340       if (tcpflags != TcpHeader::RST)
  1342       if (tcpflags != TcpHeader::RST)
  1341         {
  1343         {
  1342           NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
  1344           NS_LOG_LOGIC ("Illegal flag " << TcpHeader::FlagsToString (tcpflags) <<
       
  1345                         " received. Reset packet is sent.");
  1343           SendRST ();
  1346           SendRST ();
  1344         }
  1347         }
  1345       CloseAndNotify ();
  1348       CloseAndNotify ();
  1346       return;
  1349       return;
  1347     }
  1350     }
  1394         { // FIN from the peer as well. We can close immediately.
  1397         { // FIN from the peer as well. We can close immediately.
  1395           SendEmptyPacket (TcpHeader::ACK);
  1398           SendEmptyPacket (TcpHeader::ACK);
  1396         }
  1399         }
  1397       else if (tcpflags != TcpHeader::RST)
  1400       else if (tcpflags != TcpHeader::RST)
  1398         { // Receive of SYN or SYN+ACK or bad flags or pure data
  1401         { // Receive of SYN or SYN+ACK or bad flags or pure data
  1399           NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
  1402           NS_LOG_LOGIC ("Illegal flag " << TcpHeader::FlagsToString (tcpflags) << " received. Reset packet is sent.");
  1400           SendRST ();
  1403           SendRST ();
  1401         }
  1404         }
  1402       CloseAndNotify ();
  1405       CloseAndNotify ();
  1403     }
  1406     }
  1404 }
  1407 }
  1431     {
  1434     {
  1432       CloseAndNotify ();
  1435       CloseAndNotify ();
  1433     }
  1436     }
  1434   else
  1437   else
  1435     { // Received a SYN or SYN+ACK or bad flags
  1438     { // Received a SYN or SYN+ACK or bad flags
  1436       NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
  1439       NS_LOG_LOGIC ("Illegal flag " << TcpHeader::FlagsToString (tcpflags) << " received. Reset packet is sent.");
  1437       SendRST ();
  1440       SendRST ();
  1438       CloseAndNotify ();
  1441       CloseAndNotify ();
  1439     }
  1442     }
  1440 }
  1443 }
  1441 
  1444 
  1909       NS_LOG_LOGIC (this << " SendDataPacket Schedule ReTxTimeout at time " <<
  1912       NS_LOG_LOGIC (this << " SendDataPacket Schedule ReTxTimeout at time " <<
  1910                     Simulator::Now ().GetSeconds () << " to expire at time " <<
  1913                     Simulator::Now ().GetSeconds () << " to expire at time " <<
  1911                     (Simulator::Now () + m_rto.Get ()).GetSeconds () );
  1914                     (Simulator::Now () + m_rto.Get ()).GetSeconds () );
  1912       m_retxEvent = Simulator::Schedule (m_rto, &TcpSocketBase::ReTxTimeout, this);
  1915       m_retxEvent = Simulator::Schedule (m_rto, &TcpSocketBase::ReTxTimeout, this);
  1913     }
  1916     }
  1914   NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);
  1917   NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags" <<
       
  1918                 TcpHeader::FlagsToString (flags));
  1915   if (m_endPoint)
  1919   if (m_endPoint)
  1916     {
  1920     {
  1917       m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
  1921       m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
  1918                          m_endPoint->GetPeerAddress (), m_boundnetdevice);
  1922                          m_endPoint->GetPeerAddress (), m_boundnetdevice);
  1919     }
  1923     }