author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 05 Nov 2007 17:41:58 +0100 | |
changeset 2069 | 0de0c81a049f |
parent 1504 | 36ecc970ba96 |
child 1828 | 6ab68edddf45 |
child 1866 | e7dbcc4df546 |
permissions | -rw-r--r-- |
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" |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
#include "udp-echo-client.h" |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
namespace ns3 { |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
30 |
NS_LOG_COMPONENT_DEFINE ("UdpEchoClientApplication"); |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
UdpEchoClient::UdpEchoClient ( |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
Ptr<Node> n, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
Ipv4Address serverAddress, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
uint16_t serverPort, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
uint32_t count, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
Time interval, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
uint32_t size) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
: |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
Application(n) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
42 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
43 |
NS_LOG_PARAM ("(" << n << ", " << serverAddress << |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
", " << serverPort << ", " << count << ", " << interval << |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
", " << size << ")"); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
Construct (n, serverAddress, serverPort, count, interval, size); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
} |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
UdpEchoClient::~UdpEchoClient() |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
52 |
NS_LOG_FUNCTION; |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
} |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
void |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
UdpEchoClient::Construct ( |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
Ptr<Node> n, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
Ipv4Address serverAddress, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
uint16_t serverPort, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
uint32_t count, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
Time interval, |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
uint32_t size) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
64 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
65 |
NS_LOG_PARAM ("(" << n << ", " << serverAddress << |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
", " << serverPort << ", " << count << ", " << interval << |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
", " << size << ")"); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
m_node = n; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
m_serverAddress = serverAddress; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
m_serverPort = serverPort; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
m_count = count; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
m_interval = interval; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
m_size = size; |
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 |
m_sent = 0; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
m_socket = 0; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
m_peer = InetSocketAddress (serverAddress, serverPort); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
m_sendEvent = EventId (); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
} |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
void |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
UdpEchoClient::DoDispose (void) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
85 |
NS_LOG_FUNCTION; |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
Application::DoDispose (); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
} |
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 |
void |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
UdpEchoClient::StartApplication (void) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
92 |
NS_LOG_FUNCTION; |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
if (!m_socket) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
{ |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
InterfaceId iid = InterfaceId::LookupByName ("Udp"); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
Ptr<SocketFactory> socketFactory = |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
GetNode ()->QueryInterface<SocketFactory> (iid); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
m_socket = socketFactory->CreateSocket (); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
m_socket->Bind (); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
m_socket->Connect (m_peer); |
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 |
|
1500
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
104 |
m_socket->SetRecvCallback((Callback<void, Ptr<Socket>, const Packet &, |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
105 |
const Address &>) MakeCallback(&UdpEchoClient::Receive, this)); |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
106 |
|
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
ScheduleTransmit (Seconds(0.)); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
} |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
void |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
UdpEchoClient::StopApplication () |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
113 |
NS_LOG_FUNCTION; |
1500
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 |
if (!m_socket) |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
116 |
{ |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
117 |
m_socket->SetRecvCallback((Callback<void, Ptr<Socket>, const Packet &, |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
118 |
const Address &>) NULL); |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
119 |
} |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
120 |
|
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
121 |
Simulator::Cancel(m_sendEvent); |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
} |
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 |
void |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
UdpEchoClient::ScheduleTransmit (Time dt) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
127 |
NS_LOG_FUNCTION; |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
m_sendEvent = Simulator::Schedule(dt, &UdpEchoClient::Send, this); |
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 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
void |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
UdpEchoClient::Send (void) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
134 |
NS_LOG_FUNCTION; |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
NS_ASSERT (m_sendEvent.IsExpired ()); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
|
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
Packet p (m_size); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
m_socket->Send (p); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
++m_sent; |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
142 |
NS_LOG_INFO ("Sent " << m_size << " bytes to " << m_serverAddress); |
1499
93d51d757afa
working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents:
1496
diff
changeset
|
143 |
|
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
if (m_sent < m_count) |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
{ |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
146 |
ScheduleTransmit (m_interval); |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
} |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
148 |
} |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
|
1500
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
150 |
void |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
151 |
UdpEchoClient::Receive( |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
152 |
Ptr<Socket> socket, |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
153 |
const Packet &packet, |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
154 |
const Address &from) |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
155 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
156 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
157 |
NS_LOG_PARAM ("(" << socket << ", " << packet << ", " << from << ")"); |
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 |
if (InetSocketAddress::IsMatchingType (from)) |
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 |
InetSocketAddress address = InetSocketAddress::ConvertFrom (from); |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
162 |
NS_LOG_INFO ("Received " << packet.GetSize() << " bytes from " << |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1500
diff
changeset
|
163 |
address.GetIpv4()); |
1500
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
164 |
} |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
165 |
} |
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
166 |
|
895ed42278d3
finish up basic echo apps
Craig Dowell <craigdo@ee.washington.edu>
parents:
1499
diff
changeset
|
167 |
|
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
168 |
} // Namespace ns3 |