A Discrete-Event Network Simulator
API
udp-socket-impl.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#include "udp-socket-impl.h"
21
22#include "ipv4-end-point.h"
23#include "ipv6-end-point.h"
24#include "udp-l4-protocol.h"
25
26#include "ns3/inet-socket-address.h"
27#include "ns3/inet6-socket-address.h"
28#include "ns3/ipv4-header.h"
29#include "ns3/ipv4-packet-info-tag.h"
30#include "ns3/ipv4-route.h"
31#include "ns3/ipv4-routing-protocol.h"
32#include "ns3/ipv4.h"
33#include "ns3/ipv6-l3-protocol.h"
34#include "ns3/ipv6-packet-info-tag.h"
35#include "ns3/ipv6-route.h"
36#include "ns3/ipv6-routing-protocol.h"
37#include "ns3/ipv6.h"
38#include "ns3/log.h"
39#include "ns3/node.h"
40#include "ns3/trace-source-accessor.h"
41#include "ns3/udp-socket-factory.h"
42
43#include <limits>
44
45namespace ns3
46{
47
48NS_LOG_COMPONENT_DEFINE("UdpSocketImpl");
49
50NS_OBJECT_ENSURE_REGISTERED(UdpSocketImpl);
51
52// The correct maximum UDP message size is 65507, as determined by the following formula:
53// 0xffff - (sizeof(IP Header) + sizeof(UDP Header)) = 65535-(20+8) = 65507
54// \todo MAX_IPV4_UDP_DATAGRAM_SIZE is correct only for IPv4
56
57// Add attributes generic to all UdpSockets to base class UdpSocket
60{
61 static TypeId tid =
62 TypeId("ns3::UdpSocketImpl")
64 .SetGroupName("Internet")
65 .AddConstructor<UdpSocketImpl>()
66 .AddTraceSource("Drop",
67 "Drop UDP packet due to receive buffer overflow",
69 "ns3::Packet::TracedCallback")
70 .AddAttribute("IcmpCallback",
71 "Callback invoked whenever an icmp error is received on this socket.",
75 .AddAttribute("IcmpCallback6",
76 "Callback invoked whenever an icmpv6 error is received on this socket.",
80 return tid;
81}
82
84 : m_endPoint(nullptr),
85 m_endPoint6(nullptr),
86 m_node(nullptr),
87 m_udp(nullptr),
88 m_errno(ERROR_NOTERROR),
89 m_shutdownSend(false),
90 m_shutdownRecv(false),
91 m_connected(false),
92 m_rxAvailable(0)
93{
94 NS_LOG_FUNCTION(this);
95 m_allowBroadcast = false;
96}
97
99{
100 NS_LOG_FUNCTION(this);
101
103 m_node = nullptr;
109 if (m_endPoint != nullptr)
110 {
120 NS_ASSERT(m_endPoint != nullptr);
121 m_udp->DeAllocate(m_endPoint);
122 NS_ASSERT(m_endPoint == nullptr);
123 }
124 if (m_endPoint6 != nullptr)
125 {
135 NS_ASSERT(m_endPoint6 != nullptr);
136 m_udp->DeAllocate(m_endPoint6);
137 NS_ASSERT(m_endPoint6 == nullptr);
138 }
139 m_udp = nullptr;
140}
141
142void
144{
145 NS_LOG_FUNCTION(this << node);
146 m_node = node;
147}
148
149void
151{
152 NS_LOG_FUNCTION(this << udp);
153 m_udp = udp;
154}
155
158{
159 NS_LOG_FUNCTION(this);
160 return m_errno;
161}
162
165{
166 return NS3_SOCK_DGRAM;
167}
168
171{
172 NS_LOG_FUNCTION(this);
173 return m_node;
174}
175
176void
178{
179 NS_LOG_FUNCTION(this);
180 m_endPoint = nullptr;
181}
182
183void
185{
186 NS_LOG_FUNCTION(this);
187 m_endPoint6 = nullptr;
188}
189
190/* Deallocate the end point and cancel all the timers */
191void
193{
194 if (m_endPoint != nullptr)
195 {
196 m_endPoint->SetDestroyCallback(MakeNullCallback<void>());
197 m_udp->DeAllocate(m_endPoint);
198 m_endPoint = nullptr;
199 }
200 if (m_endPoint6 != nullptr)
201 {
202 m_endPoint6->SetDestroyCallback(MakeNullCallback<void>());
203 m_udp->DeAllocate(m_endPoint6);
204 m_endPoint6 = nullptr;
205 }
206}
207
208int
210{
211 NS_LOG_FUNCTION(this);
212 bool done = false;
213 if (m_endPoint != nullptr)
214 {
221 done = true;
222 }
223 if (m_endPoint6 != nullptr)
224 {
231 done = true;
232 }
233 if (done)
234 {
235 m_shutdownRecv = false;
236 m_shutdownSend = false;
237 return 0;
238 }
239 return -1;
240}
241
242int
244{
245 NS_LOG_FUNCTION(this);
246 m_endPoint = m_udp->Allocate();
248 {
250 }
251 return FinishBind();
252}
253
254int
256{
257 NS_LOG_FUNCTION(this);
258 m_endPoint6 = m_udp->Allocate6();
260 {
262 }
263 return FinishBind();
264}
265
266int
268{
269 NS_LOG_FUNCTION(this << address);
270
272 {
273 NS_ASSERT_MSG(m_endPoint == nullptr, "Endpoint already allocated.");
274
276 Ipv4Address ipv4 = transport.GetIpv4();
277 uint16_t port = transport.GetPort();
278 SetIpTos(transport.GetTos());
279 if (ipv4 == Ipv4Address::GetAny() && port == 0)
280 {
281 m_endPoint = m_udp->Allocate();
282 }
283 else if (ipv4 == Ipv4Address::GetAny() && port != 0)
284 {
285 m_endPoint = m_udp->Allocate(GetBoundNetDevice(), port);
286 }
287 else if (ipv4 != Ipv4Address::GetAny() && port == 0)
288 {
289 m_endPoint = m_udp->Allocate(ipv4);
290 }
291 else if (ipv4 != Ipv4Address::GetAny() && port != 0)
292 {
293 m_endPoint = m_udp->Allocate(GetBoundNetDevice(), ipv4, port);
294 }
295 if (nullptr == m_endPoint)
296 {
298 return -1;
299 }
301 {
303 }
304 }
306 {
307 NS_ASSERT_MSG(m_endPoint == nullptr, "Endpoint already allocated.");
308
310 Ipv6Address ipv6 = transport.GetIpv6();
311 uint16_t port = transport.GetPort();
312 if (ipv6 == Ipv6Address::GetAny() && port == 0)
313 {
314 m_endPoint6 = m_udp->Allocate6();
315 }
316 else if (ipv6 == Ipv6Address::GetAny() && port != 0)
317 {
318 m_endPoint6 = m_udp->Allocate6(GetBoundNetDevice(), port);
319 }
320 else if (ipv6 != Ipv6Address::GetAny() && port == 0)
321 {
322 m_endPoint6 = m_udp->Allocate6(ipv6);
323 }
324 else if (ipv6 != Ipv6Address::GetAny() && port != 0)
325 {
326 m_endPoint6 = m_udp->Allocate6(GetBoundNetDevice(), ipv6, port);
327 }
328 if (nullptr == m_endPoint6)
329 {
331 return -1;
332 }
334 {
336 }
337
338 if (ipv6.IsMulticast())
339 {
341 if (ipv6l3)
342 {
343 if (!m_boundnetdevice)
344 {
345 ipv6l3->AddMulticastAddress(ipv6);
346 }
347 else
348 {
349 uint32_t index = ipv6l3->GetInterfaceForDevice(m_boundnetdevice);
350 ipv6l3->AddMulticastAddress(m_endPoint6->GetLocalAddress(), index);
351 }
352 }
353 }
354 }
355 else
356 {
357 NS_LOG_ERROR("Not IsMatchingType");
359 return -1;
360 }
361
362 return FinishBind();
363}
364
365int
367{
368 NS_LOG_FUNCTION(this);
369 m_shutdownSend = true;
370 return 0;
371}
372
373int
375{
376 NS_LOG_FUNCTION(this);
377 m_shutdownRecv = true;
378 if (m_endPoint)
379 {
380 m_endPoint->SetRxEnabled(false);
381 }
382 if (m_endPoint6)
383 {
385 }
386 return 0;
387}
388
389int
391{
392 NS_LOG_FUNCTION(this);
393 if (m_shutdownRecv == true && m_shutdownSend == true)
394 {
396 return -1;
397 }
399 m_shutdownRecv = true;
400 m_shutdownSend = true;
402 return 0;
403}
404
405int
407{
408 NS_LOG_FUNCTION(this << address);
410 {
412 m_defaultAddress = Address(transport.GetIpv4());
413 m_defaultPort = transport.GetPort();
414 SetIpTos(transport.GetTos());
415 m_connected = true;
417 }
419 {
421 m_defaultAddress = Address(transport.GetIpv6());
422 m_defaultPort = transport.GetPort();
423 m_connected = true;
425 }
426 else
427 {
429 return -1;
430 }
431
432 return 0;
433}
434
435int
437{
439 return -1;
440}
441
442int
444{
445 NS_LOG_FUNCTION(this << p << flags);
446
447 if (!m_connected)
448 {
450 return -1;
451 }
452
453 return DoSend(p);
454}
455
456int
458{
459 NS_LOG_FUNCTION(this << p);
460 if ((m_endPoint == nullptr) && (Ipv4Address::IsMatchingType(m_defaultAddress) == true))
461 {
462 if (Bind() == -1)
463 {
464 NS_ASSERT(m_endPoint == nullptr);
465 return -1;
466 }
467 NS_ASSERT(m_endPoint != nullptr);
468 }
469 else if ((m_endPoint6 == nullptr) && (Ipv6Address::IsMatchingType(m_defaultAddress) == true))
470 {
471 if (Bind6() == -1)
472 {
473 NS_ASSERT(m_endPoint6 == nullptr);
474 return -1;
475 }
476 NS_ASSERT(m_endPoint6 != nullptr);
477 }
478 if (m_shutdownSend)
479 {
481 return -1;
482 }
483
485 {
487 }
489 {
491 }
492
494 return (-1);
495}
496
497int
499{
500 NS_LOG_FUNCTION(this << p << dest << port << (uint16_t)tos);
502 {
503 NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex());
504 }
505 if (m_endPoint == nullptr)
506 {
507 if (Bind() == -1)
508 {
509 NS_ASSERT(m_endPoint == nullptr);
510 return -1;
511 }
512 NS_ASSERT(m_endPoint != nullptr);
513 }
514 if (m_shutdownSend)
515 {
517 return -1;
518 }
519
520 if (p->GetSize() > GetTxAvailable())
521 {
523 return -1;
524 }
525
526 uint8_t priority = GetPriority();
527 if (tos)
528 {
529 SocketIpTosTag ipTosTag;
530 ipTosTag.SetTos(tos);
531 // This packet may already have a SocketIpTosTag (see BUG 2440)
532 p->ReplacePacketTag(ipTosTag);
533 priority = IpTos2Priority(tos);
534 }
535
536 if (priority)
537 {
538 SocketPriorityTag priorityTag;
539 priorityTag.SetPriority(priority);
540 p->ReplacePacketTag(priorityTag);
541 }
542
543 Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4>();
544
545 // Locally override the IP TTL for this socket
546 // We cannot directly modify the TTL at this stage, so we set a Packet tag
547 // The destination can be either multicast, unicast/anycast, or
548 // either all-hosts broadcast or limited (subnet-directed) broadcast.
549 // For the latter two broadcast types, the TTL will later be set to one
550 // irrespective of what is set in these socket options. So, this tagging
551 // may end up setting the TTL of a limited broadcast packet to be
552 // the same as a unicast, but it will be fixed further down the stack
553 if (m_ipMulticastTtl != 0 && dest.IsMulticast())
554 {
555 SocketIpTtlTag tag;
557 p->AddPacketTag(tag);
558 }
559 else if (IsManualIpTtl() && GetIpTtl() != 0 && !dest.IsMulticast() && !dest.IsBroadcast())
560 {
561 SocketIpTtlTag tag;
562 tag.SetTtl(GetIpTtl());
563 p->AddPacketTag(tag);
564 }
565 {
567 bool found = p->RemovePacketTag(tag);
568 if (!found)
569 {
570 if (m_mtuDiscover)
571 {
572 tag.Enable();
573 }
574 else
575 {
576 tag.Disable();
577 }
578 p->AddPacketTag(tag);
579 }
580 }
581
582 // Note that some systems will only send limited broadcast packets
583 // out of the "default" interface; here we send it out all interfaces
584 if (dest.IsBroadcast())
585 {
586 if (!m_allowBroadcast)
587 {
589 return -1;
590 }
591 NS_LOG_LOGIC("Limited broadcast start.");
592 for (uint32_t i = 0; i < ipv4->GetNInterfaces(); i++)
593 {
594 // Get the primary address
595 Ipv4InterfaceAddress iaddr = ipv4->GetAddress(i, 0);
596 Ipv4Address addri = iaddr.GetLocal();
597 if (addri == Ipv4Address("127.0.0.1"))
598 {
599 continue;
600 }
601 // Check if interface-bound socket
603 {
604 if (ipv4->GetNetDevice(i) != m_boundnetdevice)
605 {
606 continue;
607 }
608 }
609 NS_LOG_LOGIC("Sending one copy from " << addri << " to " << dest);
610 m_udp->Send(p->Copy(), addri, dest, m_endPoint->GetLocalPort(), port);
613 }
614 NS_LOG_LOGIC("Limited broadcast end.");
615 return p->GetSize();
616 }
618 {
619 m_udp->Send(p->Copy(),
621 dest,
623 port,
624 nullptr);
627 return p->GetSize();
628 }
629 else if (ipv4->GetRoutingProtocol())
630 {
631 Ipv4Header header;
632 header.SetDestination(dest);
634 Socket::SocketErrno errno_;
635 Ptr<Ipv4Route> route;
636 Ptr<NetDevice> oif = m_boundnetdevice; // specify non-zero if bound to a specific device
637 // TBD-- we could cache the route and just check its validity
638 route = ipv4->GetRoutingProtocol()->RouteOutput(p, header, oif, errno_);
639 if (route)
640 {
641 NS_LOG_LOGIC("Route exists");
642 if (!m_allowBroadcast)
643 {
644 // Here we try to route subnet-directed broadcasts
645 uint32_t outputIfIndex = ipv4->GetInterfaceForDevice(route->GetOutputDevice());
646 uint32_t ifNAddr = ipv4->GetNAddresses(outputIfIndex);
647 for (uint32_t addrI = 0; addrI < ifNAddr; ++addrI)
648 {
649 Ipv4InterfaceAddress ifAddr = ipv4->GetAddress(outputIfIndex, addrI);
650 if (dest == ifAddr.GetBroadcast())
651 {
653 return -1;
654 }
655 }
656 }
657
658 header.SetSource(route->GetSource());
659 m_udp->Send(p->Copy(),
660 header.GetSource(),
661 header.GetDestination(),
663 port,
664 route);
666 return p->GetSize();
667 }
668 else
669 {
670 NS_LOG_LOGIC("No route to destination");
671 NS_LOG_ERROR(errno_);
672 m_errno = errno_;
673 return -1;
674 }
675 }
676 else
677 {
678 NS_LOG_ERROR("ERROR_NOROUTETOHOST");
680 return -1;
681 }
682
683 return 0;
684}
685
686int
688{
689 NS_LOG_FUNCTION(this << p << dest << port);
690
691 if (dest.IsIpv4MappedAddress())
692 {
693 return (DoSendTo(p, dest.GetIpv4MappedAddress(), port, 0));
694 }
696 {
697 NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex());
698 }
699 if (m_endPoint6 == nullptr)
700 {
701 if (Bind6() == -1)
702 {
703 NS_ASSERT(m_endPoint6 == nullptr);
704 return -1;
705 }
706 NS_ASSERT(m_endPoint6 != nullptr);
707 }
708 if (m_shutdownSend)
709 {
711 return -1;
712 }
713
714 if (p->GetSize() > GetTxAvailable())
715 {
717 return -1;
718 }
719
720 if (IsManualIpv6Tclass())
721 {
722 SocketIpv6TclassTag ipTclassTag;
723 ipTclassTag.SetTclass(GetIpv6Tclass());
724 p->AddPacketTag(ipTclassTag);
725 }
726
727 uint8_t priority = GetPriority();
728 if (priority)
729 {
730 SocketPriorityTag priorityTag;
731 priorityTag.SetPriority(priority);
732 p->ReplacePacketTag(priorityTag);
733 }
734
735 Ptr<Ipv6> ipv6 = m_node->GetObject<Ipv6>();
736
737 // Locally override the IP TTL for this socket
738 // We cannot directly modify the TTL at this stage, so we set a Packet tag
739 // The destination can be either multicast, unicast/anycast, or
740 // either all-hosts broadcast or limited (subnet-directed) broadcast.
741 // For the latter two broadcast types, the TTL will later be set to one
742 // irrespective of what is set in these socket options. So, this tagging
743 // may end up setting the TTL of a limited broadcast packet to be
744 // the same as a unicast, but it will be fixed further down the stack
745 if (m_ipMulticastTtl != 0 && dest.IsMulticast())
746 {
749 p->AddPacketTag(tag);
750 }
751 else if (IsManualIpv6HopLimit() && GetIpv6HopLimit() != 0 && !dest.IsMulticast())
752 {
755 p->AddPacketTag(tag);
756 }
757 // There is no analogous to an IPv4 broadcast address in IPv6.
758 // Instead, we use a set of link-local, site-local, and global
759 // multicast addresses. The Ipv6 routing layers should all
760 // provide an interface-specific route to these addresses such
761 // that we can treat these multicast addresses as "not broadcast"
762
764 {
765 m_udp->Send(p->Copy(),
767 dest,
769 port,
770 nullptr);
773 return p->GetSize();
774 }
775 else if (ipv6->GetRoutingProtocol())
776 {
777 Ipv6Header header;
778 header.SetDestination(dest);
780 Socket::SocketErrno errno_;
781 Ptr<Ipv6Route> route;
782 Ptr<NetDevice> oif = m_boundnetdevice; // specify non-zero if bound to a specific device
783 // TBD-- we could cache the route and just check its validity
784 route = ipv6->GetRoutingProtocol()->RouteOutput(p, header, oif, errno_);
785 if (route)
786 {
787 NS_LOG_LOGIC("Route exists");
788 header.SetSource(route->GetSource());
789 m_udp->Send(p->Copy(),
790 header.GetSource(),
791 header.GetDestination(),
793 port,
794 route);
796 return p->GetSize();
797 }
798 else
799 {
800 NS_LOG_LOGIC("No route to destination");
801 NS_LOG_ERROR(errno_);
802 m_errno = errno_;
803 return -1;
804 }
805 }
806 else
807 {
808 NS_LOG_ERROR("ERROR_NOROUTETOHOST");
810 return -1;
811 }
812
813 return 0;
814}
815
816// maximum message size for UDP broadcast is limited by MTU
817// size of underlying link; we are not checking that now.
818// \todo Check MTU size of underlying link
821{
822 NS_LOG_FUNCTION(this);
823 // No finite send buffer is modelled, but we must respect
824 // the maximum size of an IP datagram (65535 bytes - headers).
826}
827
828int
830{
831 NS_LOG_FUNCTION(this << p << flags << address);
833 {
835 Ipv4Address ipv4 = transport.GetIpv4();
836 uint16_t port = transport.GetPort();
837 uint8_t tos = transport.GetTos();
838 return DoSendTo(p, ipv4, port, tos);
839 }
841 {
843 Ipv6Address ipv6 = transport.GetIpv6();
844 uint16_t port = transport.GetPort();
845 return DoSendTo(p, ipv6, port);
846 }
847 return -1;
848}
849
852{
853 NS_LOG_FUNCTION(this);
854 // We separately maintain this state to avoid walking the queue
855 // every time this might be called
856 return m_rxAvailable;
857}
858
861{
862 NS_LOG_FUNCTION(this << maxSize << flags);
863
864 Address fromAddress;
865 Ptr<Packet> packet = RecvFrom(maxSize, flags, fromAddress);
866 return packet;
867}
868
871{
872 NS_LOG_FUNCTION(this << maxSize << flags);
873
874 if (m_deliveryQueue.empty())
875 {
877 return nullptr;
878 }
879 Ptr<Packet> p = m_deliveryQueue.front().first;
880 fromAddress = m_deliveryQueue.front().second;
881
882 if (p->GetSize() <= maxSize)
883 {
884 m_deliveryQueue.pop();
885 m_rxAvailable -= p->GetSize();
886 }
887 else
888 {
889 p = nullptr;
890 }
891 return p;
892}
893
894int
896{
897 NS_LOG_FUNCTION(this << address);
898 if (m_endPoint != nullptr)
899 {
901 }
902 else if (m_endPoint6 != nullptr)
903 {
905 }
906 else
907 { // It is possible to call this method on a socket without a name
908 // in which case, behavior is unspecified
909 // Should this return an InetSocketAddress or an Inet6SocketAddress?
911 }
912 return 0;
913}
914
915int
917{
918 NS_LOG_FUNCTION(this << address);
919
920 if (!m_connected)
921 {
923 return -1;
924 }
925
927 {
930 inet.SetTos(GetIpTos());
931 address = inet;
932 }
934 {
937 }
938 else
939 {
940 NS_ASSERT_MSG(false, "unexpected address type");
941 }
942
943 return 0;
944}
945
946int
948{
949 NS_LOG_FUNCTION(interface << groupAddress);
950 /*
951 1) sanity check interface
952 2) sanity check that it has not been called yet on this interface/group
953 3) determine address family of groupAddress
954 4) locally store a list of (interface, groupAddress)
955 5) call ipv4->MulticastJoinGroup () or Ipv6->MulticastJoinGroup ()
956 */
957 return 0;
958}
959
960int
962{
963 NS_LOG_FUNCTION(interface << groupAddress);
964 /*
965 1) sanity check interface
966 2) determine address family of groupAddress
967 3) delete from local list of (interface, groupAddress); raise a LOG_WARN
968 if not already present (but return 0)
969 5) call ipv4->MulticastLeaveGroup () or Ipv6->MulticastLeaveGroup ()
970 */
971 return 0;
972}
973
974void
976{
977 NS_LOG_FUNCTION(netdevice);
978
979 Ptr<NetDevice> oldBoundNetDevice = m_boundnetdevice;
980
981 Socket::BindToNetDevice(netdevice); // Includes sanity check
982 if (m_endPoint != nullptr)
983 {
984 m_endPoint->BindToNetDevice(netdevice);
985 }
986
987 if (m_endPoint6 != nullptr)
988 {
989 m_endPoint6->BindToNetDevice(netdevice);
990
991 // The following is to fix the multicast distribution inside the node
992 // and to upgrade it to the actual bound NetDevice.
994 {
996 if (ipv6l3)
997 {
998 // Cleanup old one
999 if (oldBoundNetDevice)
1000 {
1001 uint32_t index = ipv6l3->GetInterfaceForDevice(oldBoundNetDevice);
1002 ipv6l3->RemoveMulticastAddress(m_endPoint6->GetLocalAddress(), index);
1003 }
1004 else
1005 {
1006 ipv6l3->RemoveMulticastAddress(m_endPoint6->GetLocalAddress());
1007 }
1008 // add new one
1009 if (netdevice)
1010 {
1011 uint32_t index = ipv6l3->GetInterfaceForDevice(netdevice);
1012 ipv6l3->AddMulticastAddress(m_endPoint6->GetLocalAddress(), index);
1013 }
1014 else
1015 {
1016 ipv6l3->AddMulticastAddress(m_endPoint6->GetLocalAddress());
1017 }
1018 }
1019 }
1020 }
1021}
1022
1023void
1025 Ipv4Header header,
1026 uint16_t port,
1027 Ptr<Ipv4Interface> incomingInterface)
1028{
1029 NS_LOG_FUNCTION(this << packet << header << port);
1030
1031 if (m_shutdownRecv)
1032 {
1033 return;
1034 }
1035
1036 // Should check via getsockopt ()..
1037 if (IsRecvPktInfo())
1038 {
1040 packet->RemovePacketTag(tag);
1041 tag.SetAddress(header.GetDestination());
1042 tag.SetTtl(header.GetTtl());
1043 tag.SetRecvIf(incomingInterface->GetDevice()->GetIfIndex());
1044 packet->AddPacketTag(tag);
1045 }
1046
1047 // Check only version 4 options
1048 if (IsIpRecvTos())
1049 {
1050 SocketIpTosTag ipTosTag;
1051 ipTosTag.SetTos(header.GetTos());
1052 packet->AddPacketTag(ipTosTag);
1053 }
1054
1055 if (IsIpRecvTtl())
1056 {
1057 SocketIpTtlTag ipTtlTag;
1058 ipTtlTag.SetTtl(header.GetTtl());
1059 packet->AddPacketTag(ipTtlTag);
1060 }
1061
1062 // in case the packet still has a priority tag attached, remove it
1063 SocketPriorityTag priorityTag;
1064 packet->RemovePacketTag(priorityTag);
1065
1066 if ((m_rxAvailable + packet->GetSize()) <= m_rcvBufSize)
1067 {
1069 m_deliveryQueue.emplace(packet, address);
1070 m_rxAvailable += packet->GetSize();
1072 }
1073 else
1074 {
1075 // In general, this case should not occur unless the
1076 // receiving application reads data from this socket slowly
1077 // in comparison to the arrival rate
1078 //
1079 // drop and trace packet
1080 NS_LOG_WARN("No receive buffer space available. Drop.");
1081 m_dropTrace(packet);
1082 }
1083}
1084
1085void
1087 Ipv6Header header,
1088 uint16_t port,
1089 Ptr<Ipv6Interface> incomingInterface)
1090{
1091 NS_LOG_FUNCTION(this << packet << header.GetSource() << port);
1092
1093 if (m_shutdownRecv)
1094 {
1095 return;
1096 }
1097
1098 // Should check via getsockopt ().
1099 if (IsRecvPktInfo())
1100 {
1102 packet->RemovePacketTag(tag);
1103 tag.SetAddress(header.GetDestination());
1104 tag.SetHoplimit(header.GetHopLimit());
1105 tag.SetTrafficClass(header.GetTrafficClass());
1106 tag.SetRecvIf(incomingInterface->GetDevice()->GetIfIndex());
1107 packet->AddPacketTag(tag);
1108 }
1109
1110 // Check only version 6 options
1111 if (IsIpv6RecvTclass())
1112 {
1113 SocketIpv6TclassTag ipTclassTag;
1114 ipTclassTag.SetTclass(header.GetTrafficClass());
1115 packet->AddPacketTag(ipTclassTag);
1116 }
1117
1118 if (IsIpv6RecvHopLimit())
1119 {
1120 SocketIpv6HopLimitTag ipHopLimitTag;
1121 ipHopLimitTag.SetHopLimit(header.GetHopLimit());
1122 packet->AddPacketTag(ipHopLimitTag);
1123 }
1124
1125 // in case the packet still has a priority tag attached, remove it
1126 SocketPriorityTag priorityTag;
1127 packet->RemovePacketTag(priorityTag);
1128
1129 if ((m_rxAvailable + packet->GetSize()) <= m_rcvBufSize)
1130 {
1132 m_deliveryQueue.emplace(packet, address);
1133 m_rxAvailable += packet->GetSize();
1135 }
1136 else
1137 {
1138 // In general, this case should not occur unless the
1139 // receiving application reads data from this socket slowly
1140 // in comparison to the arrival rate
1141 //
1142 // drop and trace packet
1143 NS_LOG_WARN("No receive buffer space available. Drop.");
1144 m_dropTrace(packet);
1145 }
1146}
1147
1148void
1150 uint8_t icmpTtl,
1151 uint8_t icmpType,
1152 uint8_t icmpCode,
1153 uint32_t icmpInfo)
1154{
1155 NS_LOG_FUNCTION(this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType
1156 << (uint32_t)icmpCode << icmpInfo);
1157 if (!m_icmpCallback.IsNull())
1158 {
1159 m_icmpCallback(icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
1160 }
1161}
1162
1163void
1165 uint8_t icmpTtl,
1166 uint8_t icmpType,
1167 uint8_t icmpCode,
1168 uint32_t icmpInfo)
1169{
1170 NS_LOG_FUNCTION(this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType
1171 << (uint32_t)icmpCode << icmpInfo);
1172 if (!m_icmpCallback6.IsNull())
1173 {
1174 m_icmpCallback6(icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
1175 }
1176}
1177
1178void
1180{
1181 m_rcvBufSize = size;
1182}
1183
1186{
1187 return m_rcvBufSize;
1188}
1189
1190void
1192{
1193 m_ipMulticastTtl = ipTtl;
1194}
1195
1196uint8_t
1198{
1199 return m_ipMulticastTtl;
1200}
1201
1202void
1204{
1205 m_ipMulticastIf = ipIf;
1206}
1207
1208int32_t
1210{
1211 return m_ipMulticastIf;
1212}
1213
1214void
1216{
1217 m_ipMulticastLoop = loop;
1218}
1219
1220bool
1222{
1223 return m_ipMulticastLoop;
1224}
1225
1226void
1228{
1229 m_mtuDiscover = discover;
1230}
1231
1232bool
1234{
1235 return m_mtuDiscover;
1236}
1237
1238bool
1240{
1241 m_allowBroadcast = allowBroadcast;
1242 return true;
1243}
1244
1245bool
1247{
1248 return m_allowBroadcast;
1249}
1250
1251void
1254 std::vector<Ipv6Address> sourceAddresses)
1255{
1256 NS_LOG_FUNCTION(this << address << &filterMode << &sourceAddresses);
1257
1258 // We can join only one multicast group (or change its params)
1260 "Can join only one IPv6 multicast group.");
1261
1263
1265 if (ipv6l3)
1266 {
1267 if (filterMode == INCLUDE && sourceAddresses.empty())
1268 {
1269 // it is a leave
1270 if (m_boundnetdevice)
1271 {
1272 int32_t index = ipv6l3->GetInterfaceForDevice(m_boundnetdevice);
1273 NS_ASSERT_MSG(index >= 0, "Interface without a valid index");
1274 ipv6l3->RemoveMulticastAddress(address, index);
1275 }
1276 else
1277 {
1278 ipv6l3->RemoveMulticastAddress(address);
1279 }
1280 }
1281 else
1282 {
1283 // it is a join or a modification
1284 if (m_boundnetdevice)
1285 {
1286 int32_t index = ipv6l3->GetInterfaceForDevice(m_boundnetdevice);
1287 NS_ASSERT_MSG(index >= 0, "Interface without a valid index");
1288 ipv6l3->AddMulticastAddress(address, index);
1289 }
1290 else
1291 {
1292 ipv6l3->AddMulticastAddress(address);
1293 }
1294 }
1295 }
1296}
1297
1298} // namespace ns3
a polymophic address class
Definition: address.h:100
AttributeValue implementation for Callback.
Definition: callback.h:809
An Inet6 address class.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
uint16_t GetPort() const
Get the port.
static bool IsMatchingType(const Address &addr)
If the address match.
Ipv6Address GetIpv6() const
Get the IPv6 address.
an Inet address class
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
bool IsMulticast() const
static Ipv4Address ConvertFrom(const Address &address)
static Ipv4Address GetZero()
static bool IsMatchingType(const Address &address)
bool IsBroadcast() const
static Ipv4Address GetAny()
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
void SetRxEnabled(bool enabled)
Enable or Disable the endpoint Rx capability.
void SetIcmpCallback(Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
uint16_t GetLocalPort()
Get the local port.
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
Set the reception callback.
Ipv4Address GetLocalAddress()
Get the local address.
Packet header for IPv4.
Definition: ipv4-header.h:34
void SetDestination(Ipv4Address destination)
Definition: ipv4-header.cc:309
Ipv4Address GetSource() const
Definition: ipv4-header.cc:302
uint8_t GetTos() const
Definition: ipv4-header.cc:196
Ipv4Address GetDestination() const
Definition: ipv4-header.cc:316
void SetProtocol(uint8_t num)
Definition: ipv4-header.cc:288
uint8_t GetTtl() const
Definition: ipv4-header.cc:274
void SetSource(Ipv4Address source)
Definition: ipv4-header.cc:295
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
a class to store IPv4 address information on an interface
Ipv4Address GetLocal() const
Get the local address.
Ipv4Address GetBroadcast() const
Get the broadcast address.
Ptr< NetDevice > GetDevice() const
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
void SetAddress(Ipv4Address addr)
Set the tag's address.
void SetTtl(uint8_t ttl)
Set the tag's Time to Live Implemented, but not used in the stack yet.
Describes an IPv6 address.
Definition: ipv6-address.h:49
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
bool IsIpv4MappedAddress() const
If the address is an IPv4-mapped address.
bool IsAny() const
If the IPv6 address is the "Any" address.
static Ipv6Address ConvertFrom(const Address &address)
Convert the Address object into an Ipv6Address ones.
Ipv4Address GetIpv4MappedAddress() const
Return the Ipv4 address.
static bool IsMatchingType(const Address &address)
If the Address matches the type.
Ipv6Address GetLocalAddress()
Get the local address.
uint16_t GetLocalPort() const
Get the local port.
void SetIcmpCallback(Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void SetRxEnabled(bool enabled)
Enable or Disable the endpoint Rx capability.
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > callback)
Set the reception callback.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
Packet header for IPv6.
Definition: ipv6-header.h:35
void SetDestination(Ipv6Address dst)
Set the "Destination address" field.
Definition: ipv6-header.cc:118
void SetSource(Ipv6Address src)
Set the "Source address" field.
Definition: ipv6-header.cc:106
uint8_t GetHopLimit() const
Get the "Hop limit" field (TTL).
Definition: ipv6-header.cc:100
Ipv6Address GetDestination() const
Get the "Destination address" field.
Definition: ipv6-header.cc:124
uint8_t GetTrafficClass() const
Get the "Traffic class" field.
Definition: ipv6-header.cc:52
Ipv6Address GetSource() const
Get the "Source address" field.
Definition: ipv6-header.cc:112
void SetNextHeader(uint8_t next)
Set the "Next header" field.
Definition: ipv6-header.cc:82
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:82
virtual Ptr< NetDevice > GetDevice() const
Get the NetDevice.
IPv6 layer implementation.
This class implements a tag that carries socket ancillary data to the socket interface.
void SetTrafficClass(uint8_t tclass)
Set the tag's Traffic Class.
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
void SetHoplimit(uint8_t ttl)
Set the tag's Hop Limit.
void SetAddress(Ipv6Address addr)
Set the tag's address.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:986
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:862
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition: packet.cc:131
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:979
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:994
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
Definition: socket.cc:345
bool IsIpRecvTtl() const
Ask if the socket is currently passing information about IP_TTL up the stack.
Definition: socket.cc:527
Ptr< Packet > Recv()
Read a single packet from the socket.
Definition: socket.cc:172
virtual void Ipv6LeaveGroup()
Leaves IPv6 multicast group this socket is joined to.
Definition: socket.cc:578
bool IsManualIpTtl() const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:372
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
Definition: socket.cc:432
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:290
virtual uint8_t GetIpTtl() const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:515
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
Definition: socket.cc:359
uint8_t GetIpTos() const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:448
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
Definition: socket.h:1082
SocketType
Enumeration of the possible socket types.
Definition: socket.h:107
@ NS3_SOCK_DGRAM
Definition: socket.h:110
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
Definition: socket.cc:397
void NotifyDataRecv()
Notify through the callback (if set) that some data have been received.
Definition: socket.cc:300
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
Definition: socket.h:143
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1079
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:325
bool IsIpv6RecvTclass() const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack.
Definition: socket.cc:502
bool IsIpv6RecvHopLimit() const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
Definition: socket.cc:552
virtual uint8_t GetIpv6HopLimit() const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:540
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:84
@ ERROR_NOROUTETOHOST
Definition: socket.h:95
@ ERROR_SHUTDOWN
Definition: socket.h:90
@ ERROR_INVAL
Definition: socket.h:93
@ ERROR_ADDRINUSE
Definition: socket.h:98
@ ERROR_AGAIN
Definition: socket.h:89
@ ERROR_OPNOTSUPP
Definition: socket.h:91
@ ERROR_AFNOSUPPORT
Definition: socket.h:92
@ ERROR_BADF
Definition: socket.h:94
@ ERROR_ADDRNOTAVAIL
Definition: socket.h:97
@ ERROR_NOTCONN
Definition: socket.h:87
@ ERROR_MSGSIZE
Definition: socket.h:88
bool IsIpRecvTos() const
Ask if the socket is currently passing information about IP Type of Service up the stack.
Definition: socket.cc:460
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:280
void NotifyConnectionSucceeded()
Notify through the callback (if set) that the connection has been established.
Definition: socket.cc:212
uint8_t GetPriority() const
Query the priority value of this socket.
Definition: socket.cc:391
uint8_t GetIpv6Tclass() const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:490
bool IsManualIpv6HopLimit() const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:378
bool IsManualIpv6Tclass() const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:366
void NotifyConnectionFailed()
Notify through the callback (if set) that the connection has not been established due to an error.
Definition: socket.cc:222
indicates whether the socket has IP_TOS set.
Definition: socket.h:1269
void SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:796
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
Definition: socket.h:1122
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:602
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
Definition: socket.h:1170
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:666
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1364
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
Definition: socket.cc:908
indicates whether the socket has a priority set.
Definition: socket.h:1316
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:852
indicates whether packets should be sent out with the DF (Don't Fragment) flag set.
Definition: socket.h:1218
void Enable()
Enables the DF (Don't Fragment) flag.
Definition: socket.cc:725
void Disable()
Disables the DF (Don't Fragment) flag.
Definition: socket.cc:732
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
static const uint8_t PROT_NUMBER
protocol number (0x11)
(abstract) base class of all UdpSockets
Definition: udp-socket.h:48
A sockets interface to UDP.
void SetUdp(Ptr< UdpL4Protocol > udp)
Set the associated UDP L4 protocol.
uint32_t GetTxAvailable() const override
Returns the number of bytes which can be sent in a single call to Send.
void SetIpMulticastTtl(uint8_t ipTtl) override
Set the IP multicast TTL.
bool m_allowBroadcast
Allow send broadcast packets.
int MulticastJoinGroup(uint32_t interfaceIndex, const Address &groupAddress) override
Corresponds to socket option MCAST_JOIN_GROUP.
static TypeId GetTypeId()
Get the type ID.
bool GetIpMulticastLoop() const override
Get the IP multicast loop capability.
bool GetMtuDiscover() const override
Get the MTU discover capability.
int GetPeerName(Address &address) const override
Get the peer address of a connected socket.
void Destroy()
Kill this socket by zeroing its attributes (IPv4)
void ForwardUp6(Ptr< Packet > packet, Ipv6Header header, uint16_t port, Ptr< Ipv6Interface > incomingInterface)
Called by the L3 protocol when it received a packet to pass on to TCP.
int DoSendTo(Ptr< Packet > p, Ipv4Address daddr, uint16_t dport, uint8_t tos)
Send a packet to a specific destination and port (IPv4)
Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback6
ICMPv6 callback.
void BindToNetDevice(Ptr< NetDevice > netdevice) override
Bind a socket to specific device.
int Close() override
Close a socket.
int FinishBind()
Finish the binding process.
bool m_connected
Connection established.
void ForwardIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
int Listen() override
Listen for incoming connections.
Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
ICMP callback.
SocketErrno m_errno
Socket error code.
uint8_t m_ipMulticastTtl
Multicast TTL.
int GetSockName(Address &address) const override
Get socket address.
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
int32_t m_ipMulticastIf
Multicast Interface.
void SetIpMulticastIf(int32_t ipIf) override
Set the IP multicast interface.
void SetRcvBufSize(uint32_t size) override
Set the receiving buffer size.
uint8_t GetIpMulticastTtl() const override
Get the IP multicast TTL.
std::queue< std::pair< Ptr< Packet >, Address > > m_deliveryQueue
Queue for incoming packets.
uint32_t m_rxAvailable
Number of available bytes to be received.
Ptr< Node > GetNode() const override
Return the node this socket is associated with.
TracedCallback< Ptr< const Packet > > m_dropTrace
Trace for dropped packets.
void Ipv6JoinGroup(Ipv6Address address, Socket::Ipv6MulticastFilterMode filterMode, std::vector< Ipv6Address > sourceAddresses) override
Joins a IPv6 multicast group.
uint32_t m_rcvBufSize
Receive buffer size.
Address m_defaultAddress
Default address.
UdpSocketImpl()
Create an unbound udp socket.
int Bind6() override
Allocate a local IPv6 endpoint for this socket.
~UdpSocketImpl() override
uint16_t m_defaultPort
Default port.
bool m_shutdownSend
Send no longer allowed.
int Send(Ptr< Packet > p, uint32_t flags) override
Send data (or dummy data) to the remote host.
bool m_ipMulticastLoop
Allow multicast loop.
int SendTo(Ptr< Packet > p, uint32_t flags, const Address &address) override
Send data to a specified peer.
int32_t GetIpMulticastIf() const override
Get the IP multicast interface.
Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress) override
Read a single packet from the socket and retrieve the sender address.
bool m_mtuDiscover
Allow MTU discovery.
bool m_shutdownRecv
Receive no longer allowed.
void SetNode(Ptr< Node > node)
Set the associated node.
bool GetAllowBroadcast() const override
Query whether broadcast datagram transmissions are allowed.
void ForwardUp(Ptr< Packet > packet, Ipv4Header header, uint16_t port, Ptr< Ipv4Interface > incomingInterface)
Called by the L3 protocol when it received a packet to pass on to TCP.
int Connect(const Address &address) override
Initiate a connection to a remote host.
Ptr< UdpL4Protocol > m_udp
the associated UDP L4 protocol
void SetMtuDiscover(bool discover) override
Set the MTU discover capability.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
SocketType GetSocketType() const override
SocketErrno GetErrno() const override
Get last error number.
int MulticastLeaveGroup(uint32_t interfaceIndex, const Address &groupAddress) override
Corresponds to socket option MCAST_LEAVE_GROUP.
void Destroy6()
Kill this socket by zeroing its attributes (IPv6)
void DeallocateEndPoint()
Deallocate m_endPoint and m_endPoint6.
int Bind() override
Allocate a local IPv4 endpoint for this socket.
int ShutdownSend() override
int DoSend(Ptr< Packet > p)
Send a packet.
uint32_t GetRxAvailable() const override
Return number of bytes which can be returned from one or multiple calls to Recv.
bool SetAllowBroadcast(bool allowBroadcast) override
Configure whether broadcast datagram transmissions are allowed.
void SetIpMulticastLoop(bool loop) override
Set the IP multicast loop capability.
Ptr< Node > m_node
the associated node
void ForwardIcmp6(Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
uint32_t GetRcvBufSize() const override
Get the receiving buffer size.
int ShutdownRecv() override
uint16_t port
Definition: dsdv-manet.cc:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeCallbackAccessor(T1 a1)
Definition: callback.h:847
Ptr< const AttributeChecker > MakeCallbackChecker()
Definition: callback.cc:82
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:254
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:707
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE
Maximum UDP datagram size.