applications: (fixes #2474) Make Udp[Echo|Trace]Client work with Inet[6]SocketAddresses

This commit is contained in:
Stefano Avallone
2016-09-02 09:31:40 +02:00
parent 4b466d7cd0
commit 8255f5523b
11 changed files with 114 additions and 154 deletions

View File

@@ -94,6 +94,7 @@ Bugs fixed
- Bug 2454 - DsrRouting::NotifyDataReceipt is also triggered for wifi management packets
- Bug 2468 - Simulation with A-MPDU enabled hangs when fragmentation threshold is smaller than MSDU size
- Bug 2469 - send Block Ack Request upon short/long retry failures
- Bug 2474 - UdpEchoClient does not call Connect with addresses of type Inet[6]SocketAddress
- Bug 2479 - Flow monitor does not a have a "DROP_QUEUE_DISC" drop reason
- Bug 2484 - Corrected the exit from CA_LOSS state in TCP
- Bug 2486 - NextTxSequence was not traced back from TCB

View File

@@ -75,18 +75,10 @@ UdpClientHelper::UdpClientHelper (Address address, uint16_t port)
SetAttribute ("RemotePort", UintegerValue (port));
}
UdpClientHelper::UdpClientHelper (Ipv4Address address, uint16_t port)
UdpClientHelper::UdpClientHelper (Address address)
{
m_factory.SetTypeId (UdpClient::GetTypeId ());
SetAttribute ("RemoteAddress", AddressValue (Address(address)));
SetAttribute ("RemotePort", UintegerValue (port));
}
UdpClientHelper::UdpClientHelper (Ipv6Address address, uint16_t port)
{
m_factory.SetTypeId (UdpClient::GetTypeId ());
SetAttribute ("RemoteAddress", AddressValue (Address(address)));
SetAttribute ("RemotePort", UintegerValue (port));
SetAttribute ("RemoteAddress", AddressValue (address));
}
void
@@ -121,19 +113,10 @@ UdpTraceClientHelper::UdpTraceClientHelper (Address address, uint16_t port, std:
SetAttribute ("TraceFilename", StringValue (filename));
}
UdpTraceClientHelper::UdpTraceClientHelper (Ipv4Address address, uint16_t port, std::string filename)
UdpTraceClientHelper::UdpTraceClientHelper (Address address, std::string filename)
{
m_factory.SetTypeId (UdpTraceClient::GetTypeId ());
SetAttribute ("RemoteAddress", AddressValue (Address (address)));
SetAttribute ("RemotePort", UintegerValue (port));
SetAttribute ("TraceFilename", StringValue (filename));
}
UdpTraceClientHelper::UdpTraceClientHelper (Ipv6Address address, uint16_t port, std::string filename)
{
m_factory.SetTypeId (UdpTraceClient::GetTypeId ());
SetAttribute ("RemoteAddress", AddressValue (Address (address)));
SetAttribute ("RemotePort", UintegerValue (port));
SetAttribute ("RemoteAddress", AddressValue (address));
SetAttribute ("TraceFilename", StringValue (filename));
}

View File

@@ -103,31 +103,25 @@ public:
/**
* Create UdpClientHelper which will make life easier for people trying
* to set up simulations with udp-client-server.
*
* \param ip The IPv4 address of the remote UDP server
* \param port The port number of the remote UDP server
*/
UdpClientHelper (Ipv4Address ip, uint16_t port);
/**
* Create UdpClientHelper which will make life easier for people trying
* to set up simulations with udp-client-server.
*
* \param ip The IPv6 address of the remote UDP server
* \param port The port number of the remote UDP server
*/
UdpClientHelper (Ipv6Address ip, uint16_t port);
/**
* Create UdpClientHelper which will make life easier for people trying
* to set up simulations with udp-client-server.
* to set up simulations with udp-client-server. Use this variant with
* addresses that do not include a port value (e.g., Ipv4Address and
* Ipv6Address).
*
* \param ip The IP address of the remote UDP server
* \param port The port number of the remote UDP server
*/
UdpClientHelper (Address ip, uint16_t port);
/**
* Create UdpClientHelper which will make life easier for people trying
* to set up simulations with udp-client-server. Use this variant with
* addresses that do include a port value (e.g., InetSocketAddress and
* Inet6SocketAddress).
*
* \param addr The address of the remote UDP server
*/
UdpClientHelper (Address addr);
/**
* Record an attribute to be set in each Application after it is is created.
@@ -173,7 +167,9 @@ public:
/**
* Create UdpTraceClientHelper which will make life easier for people trying
* to set up simulations with udp-client-server.
* to set up simulations with udp-client-server. Use this variant with
* addresses that do not include a port value (e.g., Ipv4Address and
* Ipv6Address).
*
* \param ip The IP address of the remote UDP server
* \param port The port number of the remote UDP server
@@ -182,22 +178,14 @@ public:
UdpTraceClientHelper (Address ip, uint16_t port, std::string filename);
/**
* Create UdpTraceClientHelper which will make life easier for people trying
* to set up simulations with udp-client-server.
* to set up simulations with udp-client-server. Use this variant with
* addresses that do include a port value (e.g., InetSocketAddress and
* Inet6SocketAddress).
*
* \param ip The IPv4 address of the remote UDP server
* \param port The port number of the remote UDP server
* \param addr The address of the remote UDP server
* \param filename the file from which packet traces will be loaded
*/
UdpTraceClientHelper (Ipv4Address ip, uint16_t port, std::string filename);
/**
* Create UdpTraceClientHelper which will make life easier for people trying
* to set up simulations with udp-client-server.
*
* \param ip The IPv6 address of the remote UDP server
* \param port The port number of the remote UDP server
* \param filename the file from which packet traces will be loaded
*/
UdpTraceClientHelper (Ipv6Address ip, uint16_t port, std::string filename);
UdpTraceClientHelper (Address addr, std::string filename);
/**
* Record an attribute to be set in each Application after it is is created.

View File

@@ -80,18 +80,10 @@ UdpEchoClientHelper::UdpEchoClientHelper (Address address, uint16_t port)
SetAttribute ("RemotePort", UintegerValue (port));
}
UdpEchoClientHelper::UdpEchoClientHelper (Ipv4Address address, uint16_t port)
UdpEchoClientHelper::UdpEchoClientHelper (Address address)
{
m_factory.SetTypeId (UdpEchoClient::GetTypeId ());
SetAttribute ("RemoteAddress", AddressValue (Address(address)));
SetAttribute ("RemotePort", UintegerValue (port));
}
UdpEchoClientHelper::UdpEchoClientHelper (Ipv6Address address, uint16_t port)
{
m_factory.SetTypeId (UdpEchoClient::GetTypeId ());
SetAttribute ("RemoteAddress", AddressValue (Address(address)));
SetAttribute ("RemotePort", UintegerValue (port));
SetAttribute ("RemoteAddress", AddressValue (address));
}
void

View File

@@ -108,7 +108,8 @@ class UdpEchoClientHelper
public:
/**
* Create UdpEchoClientHelper which will make life easier for people trying
* to set up simulations with echos.
* to set up simulations with echos. Use this variant with addresses that do
* not include a port value (e.g., Ipv4Address and Ipv6Address).
*
* \param ip The IP address of the remote udp echo server
* \param port The port number of the remote udp echo server
@@ -116,20 +117,12 @@ public:
UdpEchoClientHelper (Address ip, uint16_t port);
/**
* Create UdpEchoClientHelper which will make life easier for people trying
* to set up simulations with echos.
* to set up simulations with echos. Use this variant with addresses that do
* include a port value (e.g., InetSocketAddress and Inet6SocketAddress).
*
* \param ip The IPv4 address of the remote udp echo server
* \param port The port number of the remote udp echo server
* \param addr The address of the remote udp echo server
*/
UdpEchoClientHelper (Ipv4Address ip, uint16_t port);
/**
* Create UdpEchoClientHelper which will make life easier for people trying
* to set up simulations with echos.
*
* \param ip The IPv6 address of the remote udp echo server
* \param port The port number of the remote udp echo server
*/
UdpEchoClientHelper (Ipv6Address ip, uint16_t port);
UdpEchoClientHelper (Address addr);
/**
* Record an attribute to be set in each Application after it is is created.

View File

@@ -86,22 +86,6 @@ UdpClient::~UdpClient ()
NS_LOG_FUNCTION (this);
}
void
UdpClient::SetRemote (Ipv4Address ip, uint16_t port)
{
NS_LOG_FUNCTION (this << ip << port);
m_peerAddress = Address(ip);
m_peerPort = port;
}
void
UdpClient::SetRemote (Ipv6Address ip, uint16_t port)
{
NS_LOG_FUNCTION (this << ip << port);
m_peerAddress = Address(ip);
m_peerPort = port;
}
void
UdpClient::SetRemote (Address ip, uint16_t port)
{
@@ -110,6 +94,13 @@ UdpClient::SetRemote (Address ip, uint16_t port)
m_peerPort = port;
}
void
UdpClient::SetRemote (Address addr)
{
NS_LOG_FUNCTION (this << addr);
m_peerAddress = addr;
}
void
UdpClient::DoDispose (void)
{
@@ -136,6 +127,20 @@ UdpClient::StartApplication (void)
m_socket->Bind6 ();
m_socket->Connect (Inet6SocketAddress (Ipv6Address::ConvertFrom(m_peerAddress), m_peerPort));
}
else if (InetSocketAddress::IsMatchingType (m_peerAddress) == true)
{
m_socket->Bind ();
m_socket->Connect (m_peerAddress);
}
else if (Inet6SocketAddress::IsMatchingType (m_peerAddress) == true)
{
m_socket->Bind6 ();
m_socket->Connect (m_peerAddress);
}
else
{
NS_ASSERT_MSG (false, "Incompatible address type: " << m_peerAddress);
}
}
m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());

View File

@@ -53,24 +53,17 @@ public:
virtual ~UdpClient ();
/**
* \brief set the remote address and port
* \param ip remote IPv4 address
* \param port remote port
*/
void SetRemote (Ipv4Address ip, uint16_t port);
/**
* \brief set the remote address and port
* \param ip remote IPv6 address
* \param port remote port
*/
void SetRemote (Ipv6Address ip, uint16_t port);
/**
* \brief set the remote address and port
* \param ip remote IP address
* \param port remote port
*/
void SetRemote (Address ip, uint16_t port);
/**
* \brief set the remote address
* \param addr remote address
*/
void SetRemote (Address addr);
protected:
virtual void DoDispose (void);

View File

@@ -103,19 +103,10 @@ UdpEchoClient::SetRemote (Address ip, uint16_t port)
}
void
UdpEchoClient::SetRemote (Ipv4Address ip, uint16_t port)
UdpEchoClient::SetRemote (Address addr)
{
NS_LOG_FUNCTION (this << ip << port);
m_peerAddress = Address (ip);
m_peerPort = port;
}
void
UdpEchoClient::SetRemote (Ipv6Address ip, uint16_t port)
{
NS_LOG_FUNCTION (this << ip << port);
m_peerAddress = Address (ip);
m_peerPort = port;
NS_LOG_FUNCTION (this << addr);
m_peerAddress = addr;
}
void
@@ -144,6 +135,20 @@ UdpEchoClient::StartApplication (void)
m_socket->Bind6();
m_socket->Connect (Inet6SocketAddress (Ipv6Address::ConvertFrom(m_peerAddress), m_peerPort));
}
else if (InetSocketAddress::IsMatchingType (m_peerAddress) == true)
{
m_socket->Bind ();
m_socket->Connect (m_peerAddress);
}
else if (Inet6SocketAddress::IsMatchingType (m_peerAddress) == true)
{
m_socket->Bind6 ();
m_socket->Connect (m_peerAddress);
}
else
{
NS_ASSERT_MSG (false, "Incompatible address type: " << m_peerAddress);
}
}
m_socket->SetRecvCallback (MakeCallback (&UdpEchoClient::HandleRead, this));
@@ -324,6 +329,16 @@ UdpEchoClient::Send (void)
NS_LOG_INFO ("At time " << Simulator::Now ().GetSeconds () << "s client sent " << m_size << " bytes to " <<
Ipv6Address::ConvertFrom (m_peerAddress) << " port " << m_peerPort);
}
else if (InetSocketAddress::IsMatchingType (m_peerAddress))
{
NS_LOG_INFO ("At time " << Simulator::Now ().GetSeconds () << "s client sent " << m_size << " bytes to " <<
InetSocketAddress::ConvertFrom (m_peerAddress).GetIpv4 () << " port " << InetSocketAddress::ConvertFrom (m_peerAddress).GetPort ());
}
else if (Inet6SocketAddress::IsMatchingType (m_peerAddress))
{
NS_LOG_INFO ("At time " << Simulator::Now ().GetSeconds () << "s client sent " << m_size << " bytes to " <<
Inet6SocketAddress::ConvertFrom (m_peerAddress).GetIpv6 () << " port " << Inet6SocketAddress::ConvertFrom (m_peerAddress).GetPort ());
}
if (m_sent < m_count)
{

View File

@@ -49,24 +49,17 @@ public:
virtual ~UdpEchoClient ();
/**
* \brief set the remote address and port
* \param ip remote IPv4 address
* \param port remote port
*/
void SetRemote (Ipv4Address ip, uint16_t port);
/**
* \brief set the remote address and port
* \param ip remote IPv6 address
* \param port remote port
*/
void SetRemote (Ipv6Address ip, uint16_t port);
/**
* \brief set the remote address and port
* \param ip remote IP address
* \param port remote port
*/
void SetRemote (Address ip, uint16_t port);
/**
* \brief set the remote address
* \param addr remote address
*/
void SetRemote (Address addr);
/**
* Set the data size of the packet (the number of bytes that are sent as data

View File

@@ -131,21 +131,11 @@ UdpTraceClient::SetRemote (Address ip, uint16_t port)
}
void
UdpTraceClient::SetRemote (Ipv4Address ip, uint16_t port)
UdpTraceClient::SetRemote (Address addr)
{
NS_LOG_FUNCTION (this << ip << port);
NS_LOG_FUNCTION (this << addr);
m_entries.clear ();
m_peerAddress = Address (ip);
m_peerPort = port;
}
void
UdpTraceClient::SetRemote (Ipv6Address ip, uint16_t port)
{
NS_LOG_FUNCTION (this << ip << port);
m_entries.clear ();
m_peerAddress = Address (ip);
m_peerPort = port;
m_peerAddress = addr;
}
void
@@ -260,6 +250,20 @@ UdpTraceClient::StartApplication (void)
m_socket->Bind6 ();
m_socket->Connect (Inet6SocketAddress (Ipv6Address::ConvertFrom (m_peerAddress), m_peerPort));
}
else if (InetSocketAddress::IsMatchingType (m_peerAddress) == true)
{
m_socket->Bind ();
m_socket->Connect (m_peerAddress);
}
else if (Inet6SocketAddress::IsMatchingType (m_peerAddress) == true)
{
m_socket->Bind6 ();
m_socket->Connect (m_peerAddress);
}
else
{
NS_ASSERT_MSG (false, "Incompatible address type: " << m_peerAddress);
}
}
m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
m_socket->SetAllowBroadcast (true);

View File

@@ -76,24 +76,17 @@ public:
UdpTraceClient (Ipv4Address ip, uint16_t port, char *traceFile);
~UdpTraceClient ();
/**
* \brief set the remote address and port
* \param ip remote IPv4 address
* \param port remote port
*/
void SetRemote (Ipv4Address ip, uint16_t port);
/**
* \brief set the remote address and port
* \param ip remote IPv6 address
* \param port remote port
*/
void SetRemote (Ipv6Address ip, uint16_t port);
/**
* \brief set the remote address and port
* \param ip remote IP address
* \param port remote port
*/
void SetRemote (Address ip, uint16_t port);
/**
* \brief set the remote address
* \param addr remote address
*/
void SetRemote (Address addr);
/**
* \brief Set the trace file to be used by the application