Addressed comment in CodeReview
SendPacket made private except the one which takes general Address. Some minor
correction on doxygen comments.
--- a/src/internet/model/tcp-l4-protocol.cc Mon Jul 13 08:03:44 2015 -0700
+++ b/src/internet/model/tcp-l4-protocol.cc Mon Jul 13 08:05:07 2015 -0700
@@ -520,9 +520,9 @@
}
void
-TcpL4Protocol::SendPacket (Ptr<Packet> packet, const TcpHeader &outgoing,
- const Ipv4Address &saddr, const Ipv4Address &daddr,
- Ptr<NetDevice> oif) const
+TcpL4Protocol::SendPacketV4 (Ptr<Packet> packet, const TcpHeader &outgoing,
+ const Ipv4Address &saddr, const Ipv4Address &daddr,
+ Ptr<NetDevice> oif) const
{
NS_LOG_LOGIC ("TcpL4Protocol " << this
<< " sending seq " << outgoing.GetSequenceNumber ()
@@ -571,9 +571,9 @@
}
void
-TcpL4Protocol::SendPacket (Ptr<Packet> packet, const TcpHeader &outgoing,
- const Ipv6Address &saddr, const Ipv6Address &daddr,
- Ptr<NetDevice> oif) const
+TcpL4Protocol::SendPacketV6 (Ptr<Packet> packet, const TcpHeader &outgoing,
+ const Ipv6Address &saddr, const Ipv6Address &daddr,
+ Ptr<NetDevice> oif) const
{
NS_LOG_LOGIC ("TcpL4Protocol " << this
<< " sending seq " << outgoing.GetSequenceNumber ()
@@ -633,8 +633,8 @@
{
NS_ASSERT (Ipv4Address::IsMatchingType (daddr));
- SendPacket (pkt, outgoing, Ipv4Address::ConvertFrom (saddr),
- Ipv4Address::ConvertFrom (daddr), oif);
+ SendPacketV4 (pkt, outgoing, Ipv4Address::ConvertFrom (saddr),
+ Ipv4Address::ConvertFrom (daddr), oif);
return;
}
@@ -642,8 +642,8 @@
{
NS_ASSERT (Ipv6Address::IsMatchingType (daddr));
- SendPacket (pkt, outgoing, Ipv6Address::ConvertFrom (saddr),
- Ipv6Address::ConvertFrom (daddr), oif);
+ SendPacketV6 (pkt, outgoing, Ipv6Address::ConvertFrom (saddr),
+ Ipv6Address::ConvertFrom (daddr), oif);
return;
}
@@ -652,7 +652,7 @@
InetSocketAddress s = InetSocketAddress::ConvertFrom (saddr);
InetSocketAddress d = InetSocketAddress::ConvertFrom (daddr);
- SendPacket (pkt, outgoing, s.GetIpv4 (), d.GetIpv4 (), oif);
+ SendPacketV4 (pkt, outgoing, s.GetIpv4 (), d.GetIpv4 (), oif);
return;
}
@@ -661,7 +661,7 @@
Inet6SocketAddress s = Inet6SocketAddress::ConvertFrom (saddr);
Inet6SocketAddress d = Inet6SocketAddress::ConvertFrom (daddr);
- SendPacket (pkt, outgoing, s.GetIpv6 (), d.GetIpv6 (), oif);
+ SendPacketV6 (pkt, outgoing, s.GetIpv6 (), d.GetIpv6 (), oif);
return;
}
--- a/src/internet/model/tcp-l4-protocol.h Mon Jul 13 08:03:44 2015 -0700
+++ b/src/internet/model/tcp-l4-protocol.h Mon Jul 13 08:05:07 2015 -0700
@@ -170,32 +170,6 @@
Ipv6Address peerAddress, uint16_t peerPort);
/**
- * \brief Send a packet via TCP (IPv4)
- *
- * \param pkt The packet to send
- * \param outgoing The packet header
- * \param saddr The source Ipv4Address
- * \param daddr The destination Ipv4Address
- * \param oif The output interface bound. Defaults to null (unspecified).
- */
- void SendPacket (Ptr<Packet> pkt, const TcpHeader &outgoing,
- const Ipv4Address &saddr, const Ipv4Address &daddr,
- Ptr<NetDevice> oif = 0) const;
-
- /**
- * \brief Send a packet via TCP (IPv6)
- *
- * \param pkt The packet to send
- * \param outgoing The packet header
- * \param saddr The source Ipv4Address
- * \param daddr The destination Ipv4Address
- * \param oif The output interface bound. Defaults to null (unspecified).
- */
- void SendPacket (Ptr<Packet> pkt, const TcpHeader &outgoing,
- const Ipv6Address &saddr, const Ipv6Address &daddr,
- Ptr<NetDevice> oif = 0) const;
-
- /**
* \brief Send a packet via TCP (IP-agnostic)
*
* \param pkt The packet to send
@@ -209,7 +183,7 @@
Ptr<NetDevice> oif = 0) const;
/**
- * \brief Make a socket capable to being demultiplexed
+ * \brief Make a socket fully operational
*
* Called after a socket has been bound, it is inserted in an internal vector.
*
@@ -269,17 +243,17 @@
* new stack member is now connected. This will be used to notify Layer 3
* protocol of layer 4 protocol stack to connect them together.
* The aggregation is completed by setting the node in the TCP stack, link
- * it to the ipv4 stack and adding TCP socket factory to the node.
+ * it to the ipv4 or ipv6 stack and adding TCP socket factory to the node.
*/
virtual void NotifyNewAggregate ();
/**
- * \brief Get the tcp header of the incoming packet and checks its checksum
+ * \brief Get the tcp header of the incoming packet and checks its checksum if needed
*
* \param packet Received packet
- * \param incomingTcpHeader At the end will contain the tcp header of the packet
- * \param source Source address (who sent the packet)
- * \param destination Destination address (who received the packet -- us)
+ * \param incomingTcpHeader Overwritten with the tcp header of the packet
+ * \param source Source address (an underlying Ipv4Address or Ipv6Address)
+ * \param destination Destination address (an underlying Ipv4Address or Ipv6Address)
*
* \return RX_CSUM_FAILED if the checksum check fails, RX_OK otherwise
*/
@@ -326,6 +300,32 @@
* \returns
*/
TcpL4Protocol &operator = (const TcpL4Protocol &);
+
+ /**
+ * \brief Send a packet via TCP (IPv4)
+ *
+ * \param pkt The packet to send
+ * \param outgoing The packet header
+ * \param saddr The source Ipv4Address
+ * \param daddr The destination Ipv4Address
+ * \param oif The output interface bound. Defaults to null (unspecified).
+ */
+ void SendPacketV4 (Ptr<Packet> pkt, const TcpHeader &outgoing,
+ const Ipv4Address &saddr, const Ipv4Address &daddr,
+ Ptr<NetDevice> oif = 0) const;
+
+ /**
+ * \brief Send a packet via TCP (IPv6)
+ *
+ * \param pkt The packet to send
+ * \param outgoing The packet header
+ * \param saddr The source Ipv4Address
+ * \param daddr The destination Ipv4Address
+ * \param oif The output interface bound. Defaults to null (unspecified).
+ */
+ void SendPacketV6 (Ptr<Packet> pkt, const TcpHeader &outgoing,
+ const Ipv6Address &saddr, const Ipv6Address &daddr,
+ Ptr<NetDevice> oif = 0) const;
};
} // namespace ns3
--- a/src/internet/model/tcp-socket-base.cc Mon Jul 13 08:03:44 2015 -0700
+++ b/src/internet/model/tcp-socket-base.cc Mon Jul 13 08:05:07 2015 -0700
@@ -1004,7 +1004,8 @@
h.SetDestinationPort (tcpHeader.GetSourcePort ());
h.SetWindowSize (AdvertisedWindowSize ());
AddOptions (h);
- m_tcp->SendPacket (Create<Packet> (), h, header.GetDestination (), header.GetSource (), m_boundnetdevice);
+ m_tcp->SendPacket (Create<Packet> (), h, header.GetDestination (),
+ header.GetSource (), m_boundnetdevice);
}
break;
case SYN_SENT:
@@ -1111,7 +1112,8 @@
h.SetDestinationPort (tcpHeader.GetSourcePort ());
h.SetWindowSize (AdvertisedWindowSize ());
AddOptions (h);
- m_tcp->SendPacket (Create<Packet> (), h, header.GetDestinationAddress (), header.GetSourceAddress (), m_boundnetdevice);
+ m_tcp->SendPacket (Create<Packet> (), h, header.GetDestinationAddress (),
+ header.GetSourceAddress (), m_boundnetdevice);
}
break;
case SYN_SENT: