A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 "ipv4-header.h"
25#include "ipv4-route.h"
27#include "ipv4.h"
28#include "ipv6-end-point.h"
29#include "ipv6-l3-protocol.h"
31#include "ipv6-route.h"
33#include "ipv6.h"
34#include "udp-l4-protocol.h"
35
36#include "ns3/inet-socket-address.h"
37#include "ns3/inet6-socket-address.h"
38#include "ns3/log.h"
39#include "ns3/node.h"
40#include "ns3/trace-source-accessor.h"
41
42#include <limits>
43
44namespace ns3
45{
46
47NS_LOG_COMPONENT_DEFINE("UdpSocketImpl");
48
49NS_OBJECT_ENSURE_REGISTERED(UdpSocketImpl);
50
51// The correct maximum UDP message size is 65507, as determined by the following formula:
52// 0xffff - (sizeof(IP Header) + sizeof(UDP Header)) = 65535-(20+8) = 65507
53// \todo MAX_IPV4_UDP_DATAGRAM_SIZE is correct only for IPv4
54static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE = 65507; //!< Maximum UDP datagram size
55
56// Add attributes generic to all UdpSockets to base class UdpSocket
59{
60 static TypeId tid =
61 TypeId("ns3::UdpSocketImpl")
63 .SetGroupName("Internet")
64 .AddConstructor<UdpSocketImpl>()
65 .AddTraceSource("Drop",
66 "Drop UDP packet due to receive buffer overflow",
68 "ns3::Packet::TracedCallback")
69 .AddAttribute("IcmpCallback",
70 "Callback invoked whenever an icmp error is received on this socket.",
74 .AddAttribute("IcmpCallback6",
75 "Callback invoked whenever an icmpv6 error is received on this socket.",
79 return tid;
80}
81
83 : m_endPoint(nullptr),
84 m_endPoint6(nullptr),
85 m_node(nullptr),
86 m_udp(nullptr),
87 m_errno(ERROR_NOTERROR),
88 m_shutdownSend(false),
89 m_shutdownRecv(false),
90 m_connected(false),
91 m_rxAvailable(0)
92{
93 NS_LOG_FUNCTION(this);
94 m_allowBroadcast = false;
95}
96
98{
99 NS_LOG_FUNCTION(this);
100
101 /// \todo leave any multicast groups that have been joined
102 m_node = nullptr;
103 /**
104 * Note: actually this function is called AFTER
105 * UdpSocketImpl::Destroy or UdpSocketImpl::Destroy6
106 * so the code below is unnecessary in normal operations
107 */
108 if (m_endPoint != nullptr)
109 {
111 /**
112 * Note that this piece of code is a bit tricky:
113 * when DeAllocate is called, it will call into
114 * Ipv4EndPointDemux::Deallocate which triggers
115 * a delete of the associated endPoint which triggers
116 * in turn a call to the method UdpSocketImpl::Destroy below
117 * will will zero the m_endPoint field.
118 */
119 NS_ASSERT(m_endPoint != nullptr);
120 m_udp->DeAllocate(m_endPoint);
121 NS_ASSERT(m_endPoint == nullptr);
122 }
123 if (m_endPoint6 != nullptr)
124 {
126 /**
127 * Note that this piece of code is a bit tricky:
128 * when DeAllocate is called, it will call into
129 * Ipv4EndPointDemux::Deallocate which triggers
130 * a delete of the associated endPoint which triggers
131 * in turn a call to the method UdpSocketImpl::Destroy below
132 * will will zero the m_endPoint field.
133 */
134 NS_ASSERT(m_endPoint6 != nullptr);
135 m_udp->DeAllocate(m_endPoint6);
136 NS_ASSERT(m_endPoint6 == nullptr);
137 }
138 m_udp = nullptr;
139}
140
141void
143{
144 NS_LOG_FUNCTION(this << node);
145 m_node = node;
146}
147
148void
150{
151 NS_LOG_FUNCTION(this << udp);
152 m_udp = udp;
153}
154
157{
158 NS_LOG_FUNCTION(this);
159 return m_errno;
160}
161
164{
165 return NS3_SOCK_DGRAM;
166}
167
170{
171 NS_LOG_FUNCTION(this);
172 return m_node;
173}
174
175void
177{
178 NS_LOG_FUNCTION(this);
179 if (m_udp)
180 {
181 m_udp->RemoveSocket(this);
182 }
183 m_endPoint = nullptr;
184}
185
186void
188{
189 NS_LOG_FUNCTION(this);
190 if (m_udp)
191 {
192 m_udp->RemoveSocket(this);
193 }
194 m_endPoint6 = nullptr;
195}
196
197/* Deallocate the end point and cancel all the timers */
198void
200{
201 if (m_endPoint != nullptr)
202 {
203 m_udp->DeAllocate(m_endPoint);
204 m_endPoint = nullptr;
205 }
206 if (m_endPoint6 != nullptr)
207 {
208 m_udp->DeAllocate(m_endPoint6);
209 m_endPoint6 = nullptr;
210 }
211}
212
213int
215{
216 NS_LOG_FUNCTION(this);
217 bool done = false;
218 if (m_endPoint != nullptr)
219 {
226 done = true;
227 }
228 if (m_endPoint6 != nullptr)
229 {
236 done = true;
237 }
238 if (done)
239 {
240 m_shutdownRecv = false;
241 m_shutdownSend = false;
242 return 0;
243 }
244 return -1;
245}
246
247int
249{
250 NS_LOG_FUNCTION(this);
251 m_endPoint = m_udp->Allocate();
253 {
255 }
256 return FinishBind();
257}
258
259int
261{
262 NS_LOG_FUNCTION(this);
263 m_endPoint6 = m_udp->Allocate6();
265 {
267 }
268 return FinishBind();
269}
270
271int
273{
274 NS_LOG_FUNCTION(this << address);
275
277 {
278 NS_ASSERT_MSG(m_endPoint == nullptr, "Endpoint already allocated.");
279
281 Ipv4Address ipv4 = transport.GetIpv4();
282 uint16_t port = transport.GetPort();
283 if (ipv4 == Ipv4Address::GetAny() && port == 0)
284 {
285 m_endPoint = m_udp->Allocate();
286 }
287 else if (ipv4 == Ipv4Address::GetAny() && port != 0)
288 {
289 m_endPoint = m_udp->Allocate(GetBoundNetDevice(), port);
290 }
291 else if (ipv4 != Ipv4Address::GetAny() && port == 0)
292 {
293 m_endPoint = m_udp->Allocate(ipv4);
294 }
295 else if (ipv4 != Ipv4Address::GetAny() && port != 0)
296 {
297 m_endPoint = m_udp->Allocate(GetBoundNetDevice(), ipv4, port);
298 }
299 if (nullptr == m_endPoint)
300 {
302 return -1;
303 }
305 {
307 }
308 }
309 else if (Inet6SocketAddress::IsMatchingType(address))
310 {
311 NS_ASSERT_MSG(m_endPoint == nullptr, "Endpoint already allocated.");
312
314 Ipv6Address ipv6 = transport.GetIpv6();
315 uint16_t port = transport.GetPort();
316 if (ipv6 == Ipv6Address::GetAny() && port == 0)
317 {
318 m_endPoint6 = m_udp->Allocate6();
319 }
320 else if (ipv6 == Ipv6Address::GetAny() && port != 0)
321 {
322 m_endPoint6 = m_udp->Allocate6(GetBoundNetDevice(), port);
323 }
324 else if (ipv6 != Ipv6Address::GetAny() && port == 0)
325 {
326 m_endPoint6 = m_udp->Allocate6(ipv6);
327 }
328 else if (ipv6 != Ipv6Address::GetAny() && port != 0)
329 {
330 m_endPoint6 = m_udp->Allocate6(GetBoundNetDevice(), ipv6, port);
331 }
332 if (nullptr == m_endPoint6)
333 {
335 return -1;
336 }
338 {
340 }
341
342 if (ipv6.IsMulticast())
343 {
345 if (ipv6l3)
346 {
347 if (!m_boundnetdevice)
348 {
349 ipv6l3->AddMulticastAddress(ipv6);
350 }
351 else
352 {
353 uint32_t index = ipv6l3->GetInterfaceForDevice(m_boundnetdevice);
354 ipv6l3->AddMulticastAddress(m_endPoint6->GetLocalAddress(), index);
355 }
356 }
357 }
358 }
359 else
360 {
361 NS_LOG_ERROR("Not IsMatchingType");
363 return -1;
364 }
365
366 return FinishBind();
367}
368
369int
371{
372 NS_LOG_FUNCTION(this);
373 m_shutdownSend = true;
374 return 0;
375}
376
377int
379{
380 NS_LOG_FUNCTION(this);
381 m_shutdownRecv = true;
382 if (m_endPoint)
383 {
384 m_endPoint->SetRxEnabled(false);
385 }
386 if (m_endPoint6)
387 {
389 }
390 return 0;
391}
392
393int
395{
396 NS_LOG_FUNCTION(this);
398 {
400 return -1;
401 }
403 m_shutdownRecv = true;
404 m_shutdownSend = true;
406 return 0;
407}
408
409int
411{
412 NS_LOG_FUNCTION(this << address);
414 {
416 m_defaultAddress = Address(transport.GetIpv4());
417 m_defaultPort = transport.GetPort();
418 m_connected = true;
420 }
421 else if (Inet6SocketAddress::IsMatchingType(address))
422 {
424 m_defaultAddress = Address(transport.GetIpv6());
425 m_defaultPort = transport.GetPort();
426 m_connected = true;
428 }
429 else
430 {
432 return -1;
433 }
434
435 return 0;
436}
437
438int
440{
442 return -1;
443}
444
445int
447{
448 NS_LOG_FUNCTION(this << p << flags);
449
450 if (!m_connected)
451 {
453 return -1;
454 }
455
456 return DoSend(p);
457}
458
459int
461{
462 NS_LOG_FUNCTION(this << p);
464 {
465 if (Bind() == -1)
466 {
467 NS_ASSERT(m_endPoint == nullptr);
468 return -1;
469 }
470 NS_ASSERT(m_endPoint != nullptr);
471 }
473 {
474 if (Bind6() == -1)
475 {
476 NS_ASSERT(m_endPoint6 == nullptr);
477 return -1;
478 }
479 NS_ASSERT(m_endPoint6 != nullptr);
480 }
481 if (m_shutdownSend)
482 {
484 return -1;
485 }
486
488 {
490 }
492 {
494 }
495
497 return -1;
498}
499
500int
502{
503 NS_LOG_FUNCTION(this << p << dest << port << (uint16_t)tos);
505 {
506 NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex());
507 }
508 if (m_endPoint == nullptr)
509 {
510 if (Bind() == -1)
511 {
512 NS_ASSERT(m_endPoint == nullptr);
513 return -1;
514 }
515 NS_ASSERT(m_endPoint != nullptr);
516 }
517 if (m_shutdownSend)
518 {
520 return -1;
521 }
522
523 if (p->GetSize() > GetTxAvailable())
524 {
526 return -1;
527 }
528
529 uint8_t priority = GetPriority();
530 if (tos)
531 {
532 SocketIpTosTag ipTosTag;
533 ipTosTag.SetTos(tos);
534 // This packet may already have a SocketIpTosTag (see BUG 2440)
535 p->ReplacePacketTag(ipTosTag);
536 priority = IpTos2Priority(tos);
537 }
538
539 if (priority)
540 {
541 SocketPriorityTag priorityTag;
542 priorityTag.SetPriority(priority);
543 p->ReplacePacketTag(priorityTag);
544 }
545
546 Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4>();
547
548 // Locally override the IP TTL for this socket
549 // We cannot directly modify the TTL at this stage, so we set a Packet tag
550 // The destination can be either multicast, unicast/anycast, or
551 // either all-hosts broadcast or limited (subnet-directed) broadcast.
552 // For the latter two broadcast types, the TTL will later be set to one
553 // irrespective of what is set in these socket options. So, this tagging
554 // may end up setting the TTL of a limited broadcast packet to be
555 // the same as a unicast, but it will be fixed further down the stack
556 if (m_ipMulticastTtl != 0 && dest.IsMulticast())
557 {
558 SocketIpTtlTag tag;
560 p->AddPacketTag(tag);
561 }
562 else if (IsManualIpTtl() && GetIpTtl() != 0 && !dest.IsMulticast() && !dest.IsBroadcast())
563 {
564 SocketIpTtlTag tag;
565 tag.SetTtl(GetIpTtl());
566 p->AddPacketTag(tag);
567 }
568 {
570 bool found = p->RemovePacketTag(tag);
571 if (!found)
572 {
573 if (m_mtuDiscover)
574 {
575 tag.Enable();
576 }
577 else
578 {
579 tag.Disable();
580 }
581 p->AddPacketTag(tag);
582 }
583 }
584
585 // Note that some systems will only send limited broadcast packets
586 // out of the "default" interface; here we send it out all interfaces
587 if (dest.IsBroadcast())
588 {
589 if (!m_allowBroadcast)
590 {
592 return -1;
593 }
594 NS_LOG_LOGIC("Limited broadcast start.");
595 for (uint32_t i = 0; i < ipv4->GetNInterfaces(); i++)
596 {
597 // Get the primary address
598 Ipv4InterfaceAddress iaddr = ipv4->GetAddress(i, 0);
599 Ipv4Address addri = iaddr.GetLocal();
600 if (addri == Ipv4Address("127.0.0.1"))
601 {
602 continue;
603 }
604 // Check if interface-bound socket
606 {
607 if (ipv4->GetNetDevice(i) != m_boundnetdevice)
608 {
609 continue;
610 }
611 }
612 NS_LOG_LOGIC("Sending one copy from " << addri << " to " << dest);
613 m_udp->Send(p->Copy(), addri, dest, m_endPoint->GetLocalPort(), port);
614 NotifyDataSent(p->GetSize());
616 }
617 NS_LOG_LOGIC("Limited broadcast end.");
618 return p->GetSize();
619 }
621 {
622 m_udp->Send(p->Copy(),
624 dest,
626 port,
627 nullptr);
628 NotifyDataSent(p->GetSize());
630 return p->GetSize();
631 }
632 else if (ipv4->GetRoutingProtocol())
633 {
634 Ipv4Header header;
635 header.SetDestination(dest);
637 Socket::SocketErrno errno_;
638 Ptr<Ipv4Route> route;
639 Ptr<NetDevice> oif = m_boundnetdevice; // specify non-zero if bound to a specific device
640 // TBD-- we could cache the route and just check its validity
641 route = ipv4->GetRoutingProtocol()->RouteOutput(p, header, oif, errno_);
642 if (route)
643 {
644 NS_LOG_LOGIC("Route exists");
645 if (!m_allowBroadcast)
646 {
647 // Here we try to route subnet-directed broadcasts
648 uint32_t outputIfIndex = ipv4->GetInterfaceForDevice(route->GetOutputDevice());
649 uint32_t ifNAddr = ipv4->GetNAddresses(outputIfIndex);
650 for (uint32_t addrI = 0; addrI < ifNAddr; ++addrI)
651 {
652 Ipv4InterfaceAddress ifAddr = ipv4->GetAddress(outputIfIndex, addrI);
653 if (dest == ifAddr.GetBroadcast())
654 {
656 return -1;
657 }
658 }
659 }
660
661 header.SetSource(route->GetSource());
662 m_udp->Send(p->Copy(),
663 header.GetSource(),
664 header.GetDestination(),
666 port,
667 route);
668 NotifyDataSent(p->GetSize());
669 return p->GetSize();
670 }
671 else
672 {
673 NS_LOG_LOGIC("No route to destination");
674 NS_LOG_ERROR(errno_);
675 m_errno = errno_;
676 return -1;
677 }
678 }
679 else
680 {
681 NS_LOG_ERROR("ERROR_NOROUTETOHOST");
683 return -1;
684 }
685
686 return 0;
687}
688
689int
691{
692 NS_LOG_FUNCTION(this << p << dest << port);
693
694 if (dest.IsIpv4MappedAddress())
695 {
696 return DoSendTo(p, dest.GetIpv4MappedAddress(), port, 0);
697 }
699 {
700 NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex());
701 }
702 if (m_endPoint6 == nullptr)
703 {
704 if (Bind6() == -1)
705 {
706 NS_ASSERT(m_endPoint6 == nullptr);
707 return -1;
708 }
709 NS_ASSERT(m_endPoint6 != nullptr);
710 }
711 if (m_shutdownSend)
712 {
714 return -1;
715 }
716
717 if (p->GetSize() > GetTxAvailable())
718 {
720 return -1;
721 }
722
723 if (IsManualIpv6Tclass())
724 {
725 SocketIpv6TclassTag ipTclassTag;
726 ipTclassTag.SetTclass(GetIpv6Tclass());
727 p->AddPacketTag(ipTclassTag);
728 }
729
730 uint8_t priority = GetPriority();
731 if (priority)
732 {
733 SocketPriorityTag priorityTag;
734 priorityTag.SetPriority(priority);
735 p->ReplacePacketTag(priorityTag);
736 }
737
738 Ptr<Ipv6> ipv6 = m_node->GetObject<Ipv6>();
739
740 // Locally override the IP TTL for this socket
741 // We cannot directly modify the TTL at this stage, so we set a Packet tag
742 // The destination can be either multicast, unicast/anycast, or
743 // either all-hosts broadcast or limited (subnet-directed) broadcast.
744 // For the latter two broadcast types, the TTL will later be set to one
745 // irrespective of what is set in these socket options. So, this tagging
746 // may end up setting the TTL of a limited broadcast packet to be
747 // the same as a unicast, but it will be fixed further down the stack
748 if (m_ipMulticastTtl != 0 && dest.IsMulticast())
749 {
752 p->AddPacketTag(tag);
753 }
754 else if (IsManualIpv6HopLimit() && GetIpv6HopLimit() != 0 && !dest.IsMulticast())
755 {
758 p->AddPacketTag(tag);
759 }
760 // There is no analogous to an IPv4 broadcast address in IPv6.
761 // Instead, we use a set of link-local, site-local, and global
762 // multicast addresses. The Ipv6 routing layers should all
763 // provide an interface-specific route to these addresses such
764 // that we can treat these multicast addresses as "not broadcast"
765
767 {
768 m_udp->Send(p->Copy(),
770 dest,
772 port,
773 nullptr);
774 NotifyDataSent(p->GetSize());
776 return p->GetSize();
777 }
778 else if (ipv6->GetRoutingProtocol())
779 {
780 Ipv6Header header;
781 header.SetDestination(dest);
783 Socket::SocketErrno errno_;
784 Ptr<Ipv6Route> route;
785 Ptr<NetDevice> oif = m_boundnetdevice; // specify non-zero if bound to a specific device
786 // TBD-- we could cache the route and just check its validity
787 route = ipv6->GetRoutingProtocol()->RouteOutput(p, header, oif, errno_);
788 if (route)
789 {
790 NS_LOG_LOGIC("Route exists");
791 header.SetSource(route->GetSource());
792 m_udp->Send(p->Copy(),
793 header.GetSource(),
794 header.GetDestination(),
796 port,
797 route);
798 NotifyDataSent(p->GetSize());
799 return p->GetSize();
800 }
801 else
802 {
803 NS_LOG_LOGIC("No route to destination");
804 NS_LOG_ERROR(errno_);
805 m_errno = errno_;
806 return -1;
807 }
808 }
809 else
810 {
811 NS_LOG_ERROR("ERROR_NOROUTETOHOST");
813 return -1;
814 }
815
816 return 0;
817}
818
819// maximum message size for UDP broadcast is limited by MTU
820// size of underlying link; we are not checking that now.
821// \todo Check MTU size of underlying link
824{
825 NS_LOG_FUNCTION(this);
826 // No finite send buffer is modelled, but we must respect
827 // the maximum size of an IP datagram (65535 bytes - headers).
829}
830
831int
833{
834 NS_LOG_FUNCTION(this << p << flags << address);
836 {
838 Ipv4Address ipv4 = transport.GetIpv4();
839 uint16_t port = transport.GetPort();
840 return DoSendTo(p, ipv4, port, GetIpTos());
841 }
842 else if (Inet6SocketAddress::IsMatchingType(address))
843 {
845 Ipv6Address ipv6 = transport.GetIpv6();
846 uint16_t port = transport.GetPort();
847 return DoSendTo(p, ipv6, port);
848 }
849 return -1;
850}
851
854{
855 NS_LOG_FUNCTION(this);
856 // We separately maintain this state to avoid walking the queue
857 // every time this might be called
858 return m_rxAvailable;
859}
860
863{
864 NS_LOG_FUNCTION(this << maxSize << flags);
865
866 Address fromAddress;
867 Ptr<Packet> packet = RecvFrom(maxSize, flags, fromAddress);
868 return packet;
869}
870
873{
874 NS_LOG_FUNCTION(this << maxSize << flags);
875
876 if (m_deliveryQueue.empty())
877 {
879 return nullptr;
880 }
881 Ptr<Packet> p = m_deliveryQueue.front().first;
882 fromAddress = m_deliveryQueue.front().second;
883
884 if (p->GetSize() <= maxSize)
885 {
886 m_deliveryQueue.pop();
887 m_rxAvailable -= p->GetSize();
888 }
889 else
890 {
891 p = nullptr;
892 }
893 return p;
894}
895
896int
898{
899 NS_LOG_FUNCTION(this << address);
900 if (m_endPoint != nullptr)
901 {
903 }
904 else if (m_endPoint6 != nullptr)
905 {
907 }
908 else
909 { // It is possible to call this method on a socket without a name
910 // in which case, behavior is unspecified
911 // Should this return an InetSocketAddress or an Inet6SocketAddress?
913 }
914 return 0;
915}
916
917int
919{
920 NS_LOG_FUNCTION(this << address);
921
922 if (!m_connected)
923 {
925 return -1;
926 }
927
929 {
931 address = InetSocketAddress(addr, m_defaultPort);
932 }
934 {
936 address = Inet6SocketAddress(addr, m_defaultPort);
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 {
1068 Address address = InetSocketAddress(header.GetSource(), port);
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 {
1131 Address address = Inet6SocketAddress(header.GetSource(), port);
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:101
AttributeValue implementation for Callback.
Definition: callback.h:808
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.
Ipv4Address GetLocalAddress() const
Get the local address.
uint16_t GetLocalPort() const
Get the local port.
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.
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
Set the reception callback.
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:80
a class to store IPv4 address information on an interface
Ipv4Address GetLocal() const
Get the local address.
Ipv4Address GetBroadcast() const
Get the broadcast address.
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.
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.
Ipv6Address GetLocalAddress() const
Get the local address.
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
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:522
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
Definition: socket.cc:347
bool IsIpRecvTtl() const
Ask if the socket is currently passing information about IP_TTL up the stack.
Definition: socket.cc:529
Ptr< Packet > Recv()
Read a single packet from the socket.
Definition: socket.cc:174
virtual void Ipv6LeaveGroup()
Leaves IPv6 multicast group this socket is joined to.
Definition: socket.cc:580
bool IsManualIpTtl() const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:374
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:292
virtual uint8_t GetIpTtl() const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:517
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
Definition: socket.cc:361
uint8_t GetIpTos() const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:450
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
Definition: socket.h:1084
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:399
void NotifyDataRecv()
Notify through the callback (if set) that some data have been received.
Definition: socket.cc:302
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:1081
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:327
bool IsIpv6RecvTclass() const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack.
Definition: socket.cc:504
bool IsIpv6RecvHopLimit() const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
Definition: socket.cc:554
virtual uint8_t GetIpv6HopLimit() const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:542
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:462
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:282
void NotifyConnectionSucceeded()
Notify through the callback (if set) that the connection has been established.
Definition: socket.cc:214
uint8_t GetPriority() const
Query the priority value of this socket.
Definition: socket.cc:393
uint8_t GetIpv6Tclass() const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:492
bool IsManualIpv6HopLimit() const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:380
bool IsManualIpv6Tclass() const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:368
void NotifyConnectionFailed()
Notify through the callback (if set) that the connection has not been established due to an error.
Definition: socket.cc:224
indicates whether the socket has IP_TOS set.
Definition: socket.h:1271
void SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:798
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
Definition: socket.h:1124
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:604
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
Definition: socket.h:1172
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:668
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1366
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
Definition: socket.cc:910
indicates whether the socket has a priority set.
Definition: socket.h:1318
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:854
indicates whether packets should be sent out with the DF (Don't Fragment) flag set.
Definition: socket.h:1220
void Enable()
Enables the DF (Don't Fragment) flag.
Definition: socket.cc:727
void Disable()
Disables the DF (Don't Fragment) flag.
Definition: socket.cc:734
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
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.
SocketType GetSocketType() const override
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
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
SocketErrno GetErrno() const override
Get last error number.
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:44
#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:840
Ptr< const AttributeChecker > MakeCallbackChecker()
Definition: callback.cc:88
#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.
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:706
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE
Maximum UDP datagram size.