|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
25 #include "ns3/socket-factory.h"
26 #include "ns3/ipv6-raw-socket-factory.h"
27 #include "ns3/simulator.h"
28 #include "ns3/simple-channel.h"
29 #include "ns3/simple-net-device.h"
30 #include "ns3/simple-net-device-helper.h"
31 #include "ns3/socket.h"
35 #include "ns3/node-container.h"
36 #include "ns3/inet6-socket-address.h"
37 #include "ns3/boolean.h"
38 #include "ns3/uinteger.h"
40 #include "ns3/internet-stack-helper.h"
41 #include "ns3/ipv6-l3-protocol.h"
42 #include "ns3/icmpv6-l4-protocol.h"
43 #include "ns3/ipv6-list-routing.h"
44 #include "ns3/ipv6-static-routing.h"
45 #include "ns3/ipv6-address-helper.h"
49 #include <netinet/in.h>
50 #include <sys/socket.h>
51 #include <sys/types.h>
71 void DoSendData (
Ptr<Socket> socket, std::string to);
80 virtual void DoRun (
void);
111 :
TestCase (
"Ipv6 Raw socket implementation")
127 uint32_t availableData;
137 uint32_t availableData;
172 Ptr<Node> rxNode = CreateObject<Node> ();
174 Ptr<Node> txNode = CreateObject<Node> ();
202 device = net1.
Get (0);
207 device = net2.
Get (0);
213 device = net1.
Get (1);
219 device = net2.
Get (1);
229 rxSocket->SetAttribute (
"Protocol",
UintegerValue (Ipv6Header::IPV6_ICMPV6));
282 int err = txSocket->GetPeerName (peerAddress);
284 NS_TEST_EXPECT_MSG_EQ (txSocket->GetErrno (), Socket::ERROR_NOTCONN,
"socket error code should be ERROR_NOTCONN");
287 err = txSocket->Connect (peer);
290 err = txSocket->GetPeerName (peerAddress);
293 NS_TEST_EXPECT_MSG_EQ (peerAddress, peer,
"address from socket GetPeerName() should equal the connected address");
295 Simulator::Destroy ();
holds a vector of ns3::NetDevice pointers
IPv6 address associated with an interface.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void Dispose(void)
Dispose of this Object.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void SendData(Ptr< Socket > socket, std::string to)
Send data.
AttributeValue implementation for Boolean.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t GetId(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive data.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void ReceivePacket(Ptr< Socket > socket)
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
Get the interface index of the specified NetDevice.
Describes an IPv6 address.
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive data.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Helper class to auto-assign global IPv6 unicast addresses.
Ptr< Packet > m_receivedPacket
Received packet (1).
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
API to create IPv6 RAW socket instances.
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address, bool addOnLinkRoute=true)=0
Add an address on the specified IPv6 interface.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void SetPort(uint16_t port)
Set the port.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
a polymophic address class
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual void SetForwarding(uint32_t interface, bool val)=0
Set forwarding on specified IPv6 interface.
Keep track of a set of IPv6 interfaces.
build a set of SimpleNetDevice objects
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
virtual Ptr< Socket > CreateSocket(void)=0
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
static Ipv6RawTestSuite g_ipv6rawTestSuite
Static variable for test initialization.
IPv6 RAW Socket TestSuite.
@ UNIT
This test suite implements a Unit Test.
Time Seconds(double value)
Construct a Time in the indicated unit.
keep track of a set of node pointers.
Ptr< Packet > m_receivedPacket2
Received packet (2).
Access to the IPv6 forwarding table, interfaces, and configuration.
Hold an unsigned integer type.
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
Describes an IPv6 prefix.
aggregate IP/TCP/UDP functionality to existing Nodes.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
An implementation of the ICMPv6 protocol.
void ReceivePkt2(Ptr< Socket > socket)
Receive data.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.