20 #include "ns3/assert.h"
22 #include "ns3/nstime.h"
24 #include "ns3/packet.h"
26 #include "ns3/ipv4-route.h"
28 #include "ns3/object-vector.h"
29 #include "ns3/string.h"
45 #include <netinet/in.h>
46 #include <arpa/inet.h>
64 virtual void gettime (
unsigned int *,
unsigned int *);
91 #undef NS_LOG_APPEND_CONTEXT
92 #define NS_LOG_APPEND_CONTEXT \
93 if (m_node) { std::clog << Simulator::Now ().GetSeconds () << " [node " << m_node->GetId () << "] "; }
100 .AddConstructor<NscTcpL4Protocol>()
101 .AddAttribute (
"SocketList",
"The list of sockets associated to this protocol.",
104 MakeObjectVectorChecker<NscTcpSocketImpl> ())
105 .AddAttribute (
"Library",
106 "Set the linux library to be used to create the stack",
110 MakeStringChecker ())
124 m_softTimer (
Timer::CANCEL_ON_DESTROY)
195 Ptr<Node>node = this->GetObject<Node> ();
204 tcpFactory->SetTcp (
this);
292 NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
294 peerAddress, peerPort);
311 uint32_t packetSize = packet->
GetSize ();
327 packetSize = packet->
GetSize ();
329 uint8_t *buf =
new uint8_t[packetSize];
331 const uint8_t *
data =
const_cast<uint8_t *
>(buf);
357 uint32_t ipv4Saddr, ipv4Daddr;
365 const uint8_t *rawdata =
reinterpret_cast<const uint8_t *
>(
data);
368 p = Create<Packet> (rawdata, datalen);
371 const uint32_t *ipheader =
reinterpret_cast<const uint32_t *
>(
data);
372 ipv4Saddr = *(ipheader+3);
373 ipv4Daddr = *(ipheader+4);
379 NS_ASSERT_MSG (ipv4,
"nsc callback invoked, but node has no ipv4 object");
393 endPoint != endPoints.end (); endPoint++) {
395 (*endPoint)->ForwardUp (NULL,
Ipv4Header (), 0, 0);
406 *sec = us / (1000*1000);
407 *usec = us - *sec * (1000*1000);
416 NS_ASSERT_MSG (nInterfaces <= 2,
"nsc does not support multiple interfaces per node");
421 for (uint32_t i = 1; i < nInterfaces; i++)
426 uint16_t mtu = ip->
GetMtu (i);
428 std::ostringstream addrOss, maskOss;
430 addr.
Print (addrOss);
431 mask.
Print (maskOss);
433 NS_LOG_LOGIC (
"if_attach " << addrOss.str ().c_str () <<
" " << maskOss.str ().c_str () <<
" " << mtu);
435 std::string addrStr = addrOss.str ();
436 std::string maskStr = maskOss.str ();
437 const char* addrCStr = addrStr.c_str ();
438 const char* maskCStr = maskStr.c_str ();