src/applications/udp-echo/udp-echo-client.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 13 Mar 2008 12:56:49 -0700
changeset 2602 d9262bff6df2
parent 2494 1c69ea12779c
child 2766 9b1b0cc12042
permissions -rw-r--r--
add back support for introspected doxygen.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * Copyright 2007 University of Washington
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 * 
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 *
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 *
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
 */
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
    18
#include "ns3/log.h"
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
#include "ns3/ipv4-address.h"
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
#include "ns3/nstime.h"
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
#include "ns3/inet-socket-address.h"
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
#include "ns3/socket.h"
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
#include "ns3/simulator.h"
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include "ns3/socket-factory.h"
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
#include "ns3/packet.h"
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    26
#include "ns3/uinteger.h"
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
#include "udp-echo-client.h"
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
namespace ns3 {
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
    31
NS_LOG_COMPONENT_DEFINE ("UdpEchoClientApplication");
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    32
NS_OBJECT_ENSURE_REGISTERED (UdpEchoClient);
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    34
TypeId
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    35
UdpEchoClient::GetTypeId (void)
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    36
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    37
  static TypeId tid = TypeId ("ns3::UdpEchoClient")
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    38
    .SetParent<Application> ()
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    39
    .AddConstructor<UdpEchoClient> ()
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    40
    .AddAttribute ("MaxPackets", "XXX",
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    41
                   Uinteger (100),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    42
                   MakeUintegerAccessor (&UdpEchoClient::m_count),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    43
                   MakeUintegerChecker<uint32_t> ())
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    44
    .AddAttribute ("Interval", "XXX",
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    45
                   Seconds (1.0),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    46
                   MakeTimeAccessor (&UdpEchoClient::m_interval),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    47
                   MakeTimeChecker ())
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    48
    .AddAttribute ("RemoteIpv4", "XXX",
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    49
                   Ipv4Address (),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    50
                   MakeIpv4AddressAccessor (&UdpEchoClient::m_peerAddress),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    51
                   MakeIpv4AddressChecker ())
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    52
    .AddAttribute ("RemotePort", "XXX",
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    53
                   Uinteger (0),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    54
                   MakeUintegerAccessor (&UdpEchoClient::m_peerPort),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    55
                   MakeUintegerChecker<uint16_t> ())
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    56
    .AddAttribute ("PacketSize", "Size of packets generated",
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    57
                   Uinteger (100),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    58
                   MakeUintegerAccessor (&UdpEchoClient::m_size),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    59
                   MakeUintegerChecker<uint32_t> ())
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    60
    ;
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    61
  return tid;
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    62
}
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    63
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    64
UdpEchoClient::UdpEchoClient ()
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
    66
  NS_LOG_FUNCTION;
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    67
  m_sent = 0;
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    68
  m_socket = 0;
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    69
  m_sendEvent = EventId ();
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
}
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
UdpEchoClient::~UdpEchoClient()
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
    74
  NS_LOG_FUNCTION;
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
}
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
void
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
UdpEchoClient::DoDispose (void)
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
    80
  NS_LOG_FUNCTION;
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
  Application::DoDispose ();
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
}
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
void 
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
UdpEchoClient::StartApplication (void)
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
    87
  NS_LOG_FUNCTION;
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
  if (!m_socket)
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
    {
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    91
      TypeId tid = TypeId::LookupByName ("ns3::Udp");
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
      Ptr<SocketFactory> socketFactory = 
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    93
        GetNode ()->GetObject<SocketFactory> (tid);
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
      m_socket = socketFactory->CreateSocket ();
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
      m_socket->Bind ();
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    96
      m_socket->Connect (InetSocketAddress (m_peerAddress, m_peerPort));
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
    }
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
    99
  m_socket->SetRecvCallback(MakeCallback(&UdpEchoClient::Receive, this));
1500
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   100
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
  ScheduleTransmit (Seconds(0.));
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
}
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
void 
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
UdpEchoClient::StopApplication ()
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
   107
  NS_LOG_FUNCTION;
1500
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   108
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   109
  if (!m_socket) 
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   110
    {
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   111
      m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket>, Ptr<Packet>,
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   112
                                const Address &> ());
1500
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   113
    }
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   114
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   115
  Simulator::Cancel(m_sendEvent);
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
}
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
void 
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
UdpEchoClient::ScheduleTransmit (Time dt)
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
   121
  NS_LOG_FUNCTION;
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
  m_sendEvent = Simulator::Schedule(dt, &UdpEchoClient::Send, this);
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   123
}
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
void 
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   126
UdpEchoClient::Send (void)
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
   128
  NS_LOG_FUNCTION;
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
  NS_ASSERT (m_sendEvent.IsExpired ());
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   132
  Ptr<Packet> p = Create<Packet> (m_size);
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
  m_socket->Send (p);
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
  ++m_sent;
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
   136
  NS_LOG_INFO ("Sent " << m_size << " bytes to " << m_peerAddress);
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1496
diff changeset
   137
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   138
  if (m_sent < m_count) 
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   139
    {
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
      ScheduleTransmit (m_interval);
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
    }
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
}
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
1500
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   144
void
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   145
UdpEchoClient::Receive(
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   146
  Ptr<Socket> socket, 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   147
  Ptr<Packet> packet,
1500
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   148
  const Address &from) 
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   149
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
   150
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   151
  NS_LOG_PARAMS (this << socket << packet << from);
1500
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   152
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   153
  if (InetSocketAddress::IsMatchingType (from))
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   154
    {
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   155
      InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   156
      NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1500
diff changeset
   157
        address.GetIpv4());
1500
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   158
    }
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   159
}
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   160
895ed42278d3 finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
   161
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
} // Namespace ns3