|
|
| 33 |
#include "ns3/log.h" |
33 |
#include "ns3/log.h" |
| 34 |
#include "ns3/node.h" |
34 |
#include "ns3/node.h" |
| 35 |
#include "ns3/inet-socket-address.h" |
35 |
#include "ns3/inet-socket-address.h" |
|
|
36 |
#include "ns3/boolean.h" |
| 36 |
|
37 |
|
| 37 |
#include "arp-l3-protocol.h" |
38 |
#include "arp-l3-protocol.h" |
| 38 |
#include "ipv4-l3-protocol.h" |
39 |
#include "ipv4-l3-protocol.h" |
|
|
| 74 |
Ptr<Packet> m_receivedPacket2; |
75 |
Ptr<Packet> m_receivedPacket2; |
| 75 |
void DoSendData (Ptr<Socket> socket, std::string to); |
76 |
void DoSendData (Ptr<Socket> socket, std::string to); |
| 76 |
void SendData (Ptr<Socket> socket, std::string to); |
77 |
void SendData (Ptr<Socket> socket, std::string to); |
|
|
78 |
void DoSendData_IpHdr (Ptr<Socket> socket, std::string to); |
| 79 |
void SendData_IpHdr (Ptr<Socket> socket, std::string to); |
| 77 |
|
80 |
|
| 78 |
public: |
81 |
public: |
| 79 |
virtual bool DoRun (void); |
82 |
virtual bool DoRun (void); |
|
|
| 139 |
Simulator::Run (); |
142 |
Simulator::Run (); |
| 140 |
} |
143 |
} |
| 141 |
|
144 |
|
|
|
145 |
void |
| 146 |
Ipv4RawSocketImplTest::DoSendData_IpHdr (Ptr<Socket> socket, std::string to) |
| 147 |
{ |
| 148 |
Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 0); |
| 149 |
socket->SetAttribute ("IpHeaderInclude", BooleanValue (true)); |
| 150 |
Ptr<Packet> p = Create<Packet> (123); |
| 151 |
Ipv4Header ipHeader; |
| 152 |
ipHeader.SetSource (Ipv4Address ("10.0.0.2")); |
| 153 |
ipHeader.SetDestination (Ipv4Address (to.c_str ())); |
| 154 |
ipHeader.SetProtocol (0); |
| 155 |
ipHeader.SetPayloadSize (p->GetSize ()); |
| 156 |
ipHeader.SetTtl (255); |
| 157 |
p->AddHeader (ipHeader); |
| 158 |
|
| 159 |
NS_TEST_EXPECT_MSG_EQ (socket->SendTo (p, 0, realTo), |
| 160 |
143, to); |
| 161 |
socket->SetAttribute ("IpHeaderInclude", BooleanValue (false)); |
| 162 |
} |
| 163 |
|
| 164 |
void |
| 165 |
Ipv4RawSocketImplTest::SendData_IpHdr (Ptr<Socket> socket, std::string to) |
| 166 |
{ |
| 167 |
m_receivedPacket = Create<Packet> (); |
| 168 |
m_receivedPacket2 = Create<Packet> (); |
| 169 |
Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0), |
| 170 |
&Ipv4RawSocketImplTest::DoSendData_IpHdr, this, socket, to); |
| 171 |
Simulator::Run (); |
| 172 |
} |
| 173 |
|
| 142 |
bool |
174 |
bool |
| 143 |
Ipv4RawSocketImplTest::DoRun (void) |
175 |
Ipv4RawSocketImplTest::DoRun (void) |
| 144 |
{ |
176 |
{ |
|
|
| 229 |
m_receivedPacket->RemoveAllByteTags (); |
261 |
m_receivedPacket->RemoveAllByteTags (); |
| 230 |
m_receivedPacket2->RemoveAllByteTags (); |
262 |
m_receivedPacket2->RemoveAllByteTags (); |
| 231 |
|
263 |
|
|
|
264 |
// Unicast w/ header test |
| 265 |
SendData_IpHdr (txSocket, "10.0.0.1"); |
| 266 |
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 143, "recv(hdrincl): 10.0.0.1"); |
| 267 |
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should not receive it"); |
| 268 |
|
| 269 |
m_receivedPacket->RemoveAllByteTags (); |
| 270 |
m_receivedPacket2->RemoveAllByteTags (); |
| 271 |
|
| 232 |
#if 0 |
272 |
#if 0 |
| 233 |
// Simple broadcast test |
273 |
// Simple broadcast test |
| 234 |
|
274 |
|