24 #include "ns3/socket-factory.h"
25 #include "ns3/tcp-socket-factory.h"
26 #include "ns3/simulator.h"
27 #include "ns3/simple-channel.h"
28 #include "ns3/simple-net-device.h"
29 #include "ns3/drop-tail-queue.h"
30 #include "ns3/config.h"
31 #include "ns3/ipv4-static-routing.h"
32 #include "ns3/ipv4-list-routing.h"
33 #include "ns3/ipv6-static-routing.h"
34 #include "ns3/ipv6-list-routing.h"
36 #include "ns3/inet-socket-address.h"
37 #include "ns3/inet6-socket-address.h"
38 #include "ns3/uinteger.h"
41 #include "ns3/ipv4-end-point.h"
42 #include "ns3/arp-l3-protocol.h"
43 #include "ns3/ipv4-l3-protocol.h"
44 #include "ns3/ipv6-l3-protocol.h"
45 #include "ns3/icmpv4-l4-protocol.h"
46 #include "ns3/icmpv6-l4-protocol.h"
47 #include "ns3/udp-l4-protocol.h"
48 #include "ns3/tcp-l4-protocol.h"
60 uint32_t sourceWriteSize,
61 uint32_t sourceReadSize,
62 uint32_t serverWriteSize,
63 uint32_t serverReadSize,
66 virtual void DoRun (
void);
67 virtual void DoTeardown (
void);
68 void SetupDefaultSim (
void);
69 void SetupDefaultSim6 (
void);
77 void ServerHandleSend (
Ptr<Socket> sock, uint32_t available);
78 void SourceHandleSend (
Ptr<Socket> sock, uint32_t available);
97 static std::string
Name (std::string str, uint32_t totalStreamSize,
98 uint32_t sourceWriteSize,
99 uint32_t serverReadSize,
100 uint32_t serverWriteSize,
101 uint32_t sourceReadSize,
104 std::ostringstream oss;
105 oss << str <<
" total=" << totalStreamSize <<
" sourceWrite=" << sourceWriteSize
106 <<
" sourceRead=" << sourceReadSize <<
" serverRead=" << serverReadSize
107 <<
" serverWrite=" << serverWriteSize <<
" useIpv6=" << useIpv6;
111 #ifdef NS3_LOG_ENABLE
114 std::ostringstream oss;
121 uint32_t sourceWriteSize,
122 uint32_t sourceReadSize,
123 uint32_t serverWriteSize,
124 uint32_t serverReadSize,
126 :
TestCase (
Name (
"Send string data from client to server and back",
133 m_totalBytes (totalStreamSize),
134 m_sourceWriteSize (sourceWriteSize),
135 m_sourceReadSize (sourceReadSize),
136 m_serverWriteSize (serverWriteSize),
137 m_serverReadSize (serverReadSize),
154 uint8_t m = (uint8_t)(97 + (i % 26));
175 "Server received expected data buffers");
177 "Source received back expected data buffers");
185 Simulator::Destroy ();
202 if (p == 0 && sock->
GetErrno () != Socket::ERROR_NOTERROR)
207 "Server received too many bytes");
210 m_currentServerRxBytes += p->GetSize ();
225 int sent = sock->
Send (p);
227 m_currentServerTxBytes += sent;
245 int sent = sock->
Send (p);
247 m_currentSourceTxBytes += sent;
258 if (p == 0 && sock->
GetErrno () != Socket::ERROR_NOTERROR)
263 "Source received too many bytes");
266 m_currentSourceRxBytes += p->GetSize ();
287 ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
305 dev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
318 const char* netmask =
"255.255.255.0";
319 const char* ipaddr0 =
"192.168.1.1";
320 const char* ipaddr1 =
"192.168.1.2";
336 uint16_t
port = 50000;
340 server->Bind (serverlocaladdr);
348 source->
Connect (serverremoteaddr);
372 uint16_t
port = 50000;
376 server->Bind (serverlocaladdr);
384 source->
Connect (serverremoteaddr);
395 ipv6->SetRoutingProtocol (ipv6Routing);
397 ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
403 ipv6->RegisterExtensions ();
404 ipv6->RegisterOptions ();
418 dev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));