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 return 0;
236 }
237 return -1;
238}
239
240int
242{
243 NS_LOG_FUNCTION(this);
244 m_endPoint = m_udp->Allocate();
246 {
248 }
249 return FinishBind();
250}
251
252int
254{
255 NS_LOG_FUNCTION(this);
256 m_endPoint6 = m_udp->Allocate6();
258 {
260 }
261 return FinishBind();
262}
263
264int
266{
267 NS_LOG_FUNCTION(this << address);
268
270 {
271 NS_ASSERT_MSG(m_endPoint == nullptr, "Endpoint already allocated.");
272
274 Ipv4Address ipv4 = transport.GetIpv4();
275 uint16_t port = transport.GetPort();
276 SetIpTos(transport.GetTos());
277 if (ipv4 == Ipv4Address::GetAny() && port == 0)
278 {
279 m_endPoint = m_udp->Allocate();
280 }
281 else if (ipv4 == Ipv4Address::GetAny() && port != 0)
282 {
283 m_endPoint = m_udp->Allocate(GetBoundNetDevice(), port);
284 }
285 else if (ipv4 != Ipv4Address::GetAny() && port == 0)
286 {
287 m_endPoint = m_udp->Allocate(ipv4);
288 }
289 else if (ipv4 != Ipv4Address::GetAny() && port != 0)
290 {
291 m_endPoint = m_udp->Allocate(GetBoundNetDevice(), ipv4, port);
292 }
293 if (nullptr == m_endPoint)
294 {
296 return -1;
297 }
299 {
301 }
302 }
304 {
305 NS_ASSERT_MSG(m_endPoint == nullptr, "Endpoint already allocated.");
306
308 Ipv6Address ipv6 = transport.GetIpv6();
309 uint16_t port = transport.GetPort();
310 if (ipv6 == Ipv6Address::GetAny() && port == 0)
311 {
312 m_endPoint6 = m_udp->Allocate6();
313 }
314 else if (ipv6 == Ipv6Address::GetAny() && port != 0)
315 {
316 m_endPoint6 = m_udp->Allocate6(GetBoundNetDevice(), port);
317 }
318 else if (ipv6 != Ipv6Address::GetAny() && port == 0)
319 {
320 m_endPoint6 = m_udp->Allocate6(ipv6);
321 }
322 else if (ipv6 != Ipv6Address::GetAny() && port != 0)
323 {
324 m_endPoint6 = m_udp->Allocate6(GetBoundNetDevice(), ipv6, port);
325 }
326 if (nullptr == m_endPoint6)
327 {
329 return -1;
330 }
332 {
334 }
335
336 if (ipv6.IsMulticast())
337 {
339 if (ipv6l3)
340 {
341 if (!m_boundnetdevice)
342 {
343 ipv6l3->AddMulticastAddress(ipv6);
344 }
345 else
346 {
347 uint32_t index = ipv6l3->GetInterfaceForDevice(m_boundnetdevice);
348 ipv6l3->AddMulticastAddress(m_endPoint6->GetLocalAddress(), index);
349 }
350 }
351 }
352 }
353 else
354 {
355 NS_LOG_ERROR("Not IsMatchingType");
357 return -1;
358 }
359
360 return FinishBind();
361}
362
363int
365{
366 NS_LOG_FUNCTION(this);
367 m_shutdownSend = true;
368 return 0;
369}
370
371int
373{
374 NS_LOG_FUNCTION(this);
375 m_shutdownRecv = true;
376 if (m_endPoint)
377 {
378 m_endPoint->SetRxEnabled(false);
379 }
380 if (m_endPoint6)
381 {
383 }
384 return 0;
385}
386
387int
389{
390 NS_LOG_FUNCTION(this);
391 if (m_shutdownRecv == true && m_shutdownSend == true)
392 {
394 return -1;
395 }
397 m_shutdownRecv = true;
398 m_shutdownSend = true;
400 return 0;
401}
402
403int
405{
406 NS_LOG_FUNCTION(this << address);
408 {
410 m_defaultAddress = Address(transport.GetIpv4());
411 m_defaultPort = transport.GetPort();
412 SetIpTos(transport.GetTos());
413 m_connected = true;
415 }
417 {
419 m_defaultAddress = Address(transport.GetIpv6());
420 m_defaultPort = transport.GetPort();
421 m_connected = true;
423 }
424 else
425 {
427 return -1;
428 }
429
430 return 0;
431}
432
433int
435{
437 return -1;
438}
439
440int
442{
443 NS_LOG_FUNCTION(this << p << flags);
444
445 if (!m_connected)
446 {
448 return -1;
449 }
450
451 return DoSend(p);
452}
453
454int
456{
457 NS_LOG_FUNCTION(this << p);
458 if ((m_endPoint == nullptr) && (Ipv4Address::IsMatchingType(m_defaultAddress) == true))
459 {
460 if (Bind() == -1)
461 {
462 NS_ASSERT(m_endPoint == nullptr);
463 return -1;
464 }
465 NS_ASSERT(m_endPoint != nullptr);
466 }
467 else if ((m_endPoint6 == nullptr) && (Ipv6Address::IsMatchingType(m_defaultAddress) == true))
468 {
469 if (Bind6() == -1)
470 {
471 NS_ASSERT(m_endPoint6 == nullptr);
472 return -1;
473 }
474 NS_ASSERT(m_endPoint6 != nullptr);
475 }
476 if (m_shutdownSend)
477 {
479 return -1;
480 }
481
483 {
485 }
487 {
489 }
490
492 return (-1);
493}
494
495int
497{
498 NS_LOG_FUNCTION(this << p << dest << port << (uint16_t)tos);
500 {
501 NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex());
502 }
503 if (m_endPoint == nullptr)
504 {
505 if (Bind() == -1)
506 {
507 NS_ASSERT(m_endPoint == nullptr);
508 return -1;
509 }
510 NS_ASSERT(m_endPoint != nullptr);
511 }
512 if (m_shutdownSend)
513 {
515 return -1;
516 }
517
518 if (p->GetSize() > GetTxAvailable())
519 {
521 return -1;
522 }
523
524 uint8_t priority = GetPriority();
525 if (tos)
526 {
527 SocketIpTosTag ipTosTag;
528 ipTosTag.SetTos(tos);
529 // This packet may already have a SocketIpTosTag (see BUG 2440)
530 p->ReplacePacketTag(ipTosTag);
531 priority = IpTos2Priority(tos);
532 }
533
534 if (priority)
535 {
536 SocketPriorityTag priorityTag;
537 priorityTag.SetPriority(priority);
538 p->ReplacePacketTag(priorityTag);
539 }
540
541 Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4>();
542
543 // Locally override the IP TTL for this socket
544 // We cannot directly modify the TTL at this stage, so we set a Packet tag
545 // The destination can be either multicast, unicast/anycast, or
546 // either all-hosts broadcast or limited (subnet-directed) broadcast.
547 // For the latter two broadcast types, the TTL will later be set to one
548 // irrespective of what is set in these socket options. So, this tagging
549 // may end up setting the TTL of a limited broadcast packet to be
550 // the same as a unicast, but it will be fixed further down the stack
551 if (m_ipMulticastTtl != 0 && dest.IsMulticast())
552 {
553 SocketIpTtlTag tag;
555 p->AddPacketTag(tag);
556 }
557 else if (IsManualIpTtl() && GetIpTtl() != 0 && !dest.IsMulticast() && !dest.IsBroadcast())
558 {
559 SocketIpTtlTag tag;
560 tag.SetTtl(GetIpTtl());
561 p->AddPacketTag(tag);
562 }
563 {
565 bool found = p->RemovePacketTag(tag);
566 if (!found)
567 {
568 if (m_mtuDiscover)
569 {
570 tag.Enable();
571 }
572 else
573 {
574 tag.Disable();
575 }
576 p->AddPacketTag(tag);
577 }
578 }
579
580 // Note that some systems will only send limited broadcast packets
581 // out of the "default" interface; here we send it out all interfaces
582 if (dest.IsBroadcast())
583 {
584 if (!m_allowBroadcast)
585 {
587 return -1;
588 }
589 NS_LOG_LOGIC("Limited broadcast start.");
590 for (uint32_t i = 0; i < ipv4->GetNInterfaces(); i++)
591 {
592 // Get the primary address
593 Ipv4InterfaceAddress iaddr = ipv4->GetAddress(i, 0);
594 Ipv4Address addri = iaddr.GetLocal();
595 if (addri == Ipv4Address("127.0.0.1"))
596 {
597 continue;
598 }
599 // Check if interface-bound socket
601 {
602 if (ipv4->GetNetDevice(i) != m_boundnetdevice)
603 {
604 continue;
605 }
606 }
607 NS_LOG_LOGIC("Sending one copy from " << addri << " to " << dest);
608 m_udp->Send(p->Copy(), addri, dest, m_endPoint->GetLocalPort(), port);
611 }
612 NS_LOG_LOGIC("Limited broadcast end.");
613 return p->GetSize();
614 }
616 {
617 m_udp->Send(p->Copy(),
619 dest,
621 port,
622 nullptr);
625 return p->GetSize();
626 }
627 else if (ipv4->GetRoutingProtocol())
628 {
629 Ipv4Header header;
630 header.SetDestination(dest);
632 Socket::SocketErrno errno_;
633 Ptr<Ipv4Route> route;
634 Ptr<NetDevice> oif = m_boundnetdevice; // specify non-zero if bound to a specific device
635 // TBD-- we could cache the route and just check its validity
636 route = ipv4->GetRoutingProtocol()->RouteOutput(p, header, oif, errno_);
637 if (route)
638 {
639 NS_LOG_LOGIC("Route exists");
640 if (!m_allowBroadcast)
641 {
642 // Here we try to route subnet-directed broadcasts
643 uint32_t outputIfIndex = ipv4->GetInterfaceForDevice(route->GetOutputDevice());
644 uint32_t ifNAddr = ipv4->GetNAddresses(outputIfIndex);
645 for (uint32_t addrI = 0; addrI < ifNAddr; ++addrI)
646 {
647 Ipv4InterfaceAddress ifAddr = ipv4->GetAddress(outputIfIndex, addrI);
648 if (dest == ifAddr.GetBroadcast())
649 {
651 return -1;
652 }
653 }
654 }
655
656 header.SetSource(route->GetSource());
657 m_udp->Send(p->Copy(),
658 header.GetSource(),
659 header.GetDestination(),
661 port,
662 route);
664 return p->GetSize();
665 }
666 else
667 {
668 NS_LOG_LOGIC("No route to destination");
669 NS_LOG_ERROR(errno_);
670 m_errno = errno_;
671 return -1;
672 }
673 }
674 else
675 {
676 NS_LOG_ERROR("ERROR_NOROUTETOHOST");
678 return -1;
679 }
680
681 return 0;
682}
683
684int
686{
687 NS_LOG_FUNCTION(this << p << dest << port);
688
689 if (dest.IsIpv4MappedAddress())
690 {
691 return (DoSendTo(p, dest.GetIpv4MappedAddress(), port, 0));
692 }
694 {
695 NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex());
696 }
697 if (m_endPoint6 == nullptr)
698 {
699 if (Bind6() == -1)
700 {
701 NS_ASSERT(m_endPoint6 == nullptr);
702 return -1;
703 }
704 NS_ASSERT(m_endPoint6 != nullptr);
705 }
706 if (m_shutdownSend)
707 {
709 return -1;
710 }
711
712 if (p->GetSize() > GetTxAvailable())
713 {
715 return -1;
716 }
717
718 if (IsManualIpv6Tclass())
719 {
720 SocketIpv6TclassTag ipTclassTag;
721 ipTclassTag.SetTclass(GetIpv6Tclass());
722 p->AddPacketTag(ipTclassTag);
723 }
724
725 uint8_t priority = GetPriority();
726 if (priority)
727 {
728 SocketPriorityTag priorityTag;
729 priorityTag.SetPriority(priority);
730 p->ReplacePacketTag(priorityTag);
731 }
732
733 Ptr<Ipv6> ipv6 = m_node->GetObject<Ipv6>();
734
735 // Locally override the IP TTL for this socket
736 // We cannot directly modify the TTL at this stage, so we set a Packet tag
737 // The destination can be either multicast, unicast/anycast, or
738 // either all-hosts broadcast or limited (subnet-directed) broadcast.
739 // For the latter two broadcast types, the TTL will later be set to one
740 // irrespective of what is set in these socket options. So, this tagging
741 // may end up setting the TTL of a limited broadcast packet to be
742 // the same as a unicast, but it will be fixed further down the stack
743 if (m_ipMulticastTtl != 0 && dest.IsMulticast())
744 {
747 p->AddPacketTag(tag);
748 }
749 else if (IsManualIpv6HopLimit() && GetIpv6HopLimit() != 0 && !dest.IsMulticast())
750 {
753 p->AddPacketTag(tag);
754 }
755 // There is no analgous to an IPv4 broadcast address in IPv6.
756 // Instead, we use a set of link-local, site-local, and global
757 // multicast addresses. The Ipv6 routing layers should all
758 // provide an interface-specific route to these addresses such
759 // that we can treat these multicast addresses as "not broadcast"
760
762 {
763 m_udp->Send(p->Copy(),
765 dest,
767 port,
768 nullptr);
771 return p->GetSize();
772 }
773 else if (ipv6->GetRoutingProtocol())
774 {
775 Ipv6Header header;
776 header.SetDestination(dest);
778 Socket::SocketErrno errno_;
779 Ptr<Ipv6Route> route;
780 Ptr<NetDevice> oif = m_boundnetdevice; // specify non-zero if bound to a specific device
781 // TBD-- we could cache the route and just check its validity
782 route = ipv6->GetRoutingProtocol()->RouteOutput(p, header, oif, errno_);
783 if (route)
784 {
785 NS_LOG_LOGIC("Route exists");
786 header.SetSource(route->GetSource());
787 m_udp->Send(p->Copy(),
788 header.GetSource(),
789 header.GetDestination(),
791 port,
792 route);
794 return p->GetSize();
795 }
796 else
797 {
798 NS_LOG_LOGIC("No route to destination");
799 NS_LOG_ERROR(errno_);
800 m_errno = errno_;
801 return -1;
802 }
803 }
804 else
805 {
806 NS_LOG_ERROR("ERROR_NOROUTETOHOST");
808 return -1;
809 }
810
811 return 0;
812}
813
814// maximum message size for UDP broadcast is limited by MTU
815// size of underlying link; we are not checking that now.
816// \todo Check MTU size of underlying link
819{
820 NS_LOG_FUNCTION(this);
821 // No finite send buffer is modelled, but we must respect
822 // the maximum size of an IP datagram (65535 bytes - headers).
824}
825
826int
828{
829 NS_LOG_FUNCTION(this << p << flags << address);
831 {
833 Ipv4Address ipv4 = transport.GetIpv4();
834 uint16_t port = transport.GetPort();
835 uint8_t tos = transport.GetTos();
836 return DoSendTo(p, ipv4, port, tos);
837 }
839 {
841 Ipv6Address ipv6 = transport.GetIpv6();
842 uint16_t port = transport.GetPort();
843 return DoSendTo(p, ipv6, port);
844 }
845 return -1;
846}
847
850{
851 NS_LOG_FUNCTION(this);
852 // We separately maintain this state to avoid walking the queue
853 // every time this might be called
854 return m_rxAvailable;
855}
856
859{
860 NS_LOG_FUNCTION(this << maxSize << flags);
861
862 Address fromAddress;
863 Ptr<Packet> packet = RecvFrom(maxSize, flags, fromAddress);
864 return packet;
865}
866
869{
870 NS_LOG_FUNCTION(this << maxSize << flags);
871
872 if (m_deliveryQueue.empty())
873 {
875 return nullptr;
876 }
877 Ptr<Packet> p = m_deliveryQueue.front().first;
878 fromAddress = m_deliveryQueue.front().second;
879
880 if (p->GetSize() <= maxSize)
881 {
882 m_deliveryQueue.pop();
883 m_rxAvailable -= p->GetSize();
884 }
885 else
886 {
887 p = nullptr;
888 }
889 return p;
890}
891
892int
894{
895 NS_LOG_FUNCTION(this << address);
896 if (m_endPoint != nullptr)
897 {
899 }
900 else if (m_endPoint6 != nullptr)
901 {
903 }
904 else
905 { // It is possible to call this method on a socket without a name
906 // in which case, behavior is unspecified
907 // Should this return an InetSocketAddress or an Inet6SocketAddress?
909 }
910 return 0;
911}
912
913int
915{
916 NS_LOG_FUNCTION(this << address);
917
918 if (!m_connected)
919 {
921 return -1;
922 }
923
925 {
928 inet.SetTos(GetIpTos());
929 address = inet;
930 }
932 {
935 }
936 else
937 {
938 NS_ASSERT_MSG(false, "unexpected address type");
939 }
940
941 return 0;
942}
943
944int
946{
947 NS_LOG_FUNCTION(interface << groupAddress);
948 /*
949 1) sanity check interface
950 2) sanity check that it has not been called yet on this interface/group
951 3) determine address family of groupAddress
952 4) locally store a list of (interface, groupAddress)
953 5) call ipv4->MulticastJoinGroup () or Ipv6->MulticastJoinGroup ()
954 */
955 return 0;
956}
957
958int
960{
961 NS_LOG_FUNCTION(interface << groupAddress);
962 /*
963 1) sanity check interface
964 2) determine address family of groupAddress
965 3) delete from local list of (interface, groupAddress); raise a LOG_WARN
966 if not already present (but return 0)
967 5) call ipv4->MulticastLeaveGroup () or Ipv6->MulticastLeaveGroup ()
968 */
969 return 0;
970}
971
972void
974{
975 NS_LOG_FUNCTION(netdevice);
976
977 Ptr<NetDevice> oldBoundNetDevice = m_boundnetdevice;
978
979 Socket::BindToNetDevice(netdevice); // Includes sanity check
980 if (m_endPoint != nullptr)
981 {
982 m_endPoint->BindToNetDevice(netdevice);
983 }
984
985 if (m_endPoint6 != nullptr)
986 {
987 m_endPoint6->BindToNetDevice(netdevice);
988
989 // The following is to fix the multicast distribution inside the node
990 // and to upgrade it to the actual bound NetDevice.
992 {
994 if (ipv6l3)
995 {
996 // Cleanup old one
997 if (oldBoundNetDevice)
998 {
999 uint32_t index = ipv6l3->GetInterfaceForDevice(oldBoundNetDevice);
1000 ipv6l3->RemoveMulticastAddress(m_endPoint6->GetLocalAddress(), index);
1001 }
1002 else
1003 {
1004 ipv6l3->RemoveMulticastAddress(m_endPoint6->GetLocalAddress());
1005 }
1006 // add new one
1007 if (netdevice)
1008 {
1009 uint32_t index = ipv6l3->GetInterfaceForDevice(netdevice);
1010 ipv6l3->AddMulticastAddress(m_endPoint6->GetLocalAddress(), index);
1011 }
1012 else
1013 {
1014 ipv6l3->AddMulticastAddress(m_endPoint6->GetLocalAddress());
1015 }
1016 }
1017 }
1018 }
1019}
1020
1021void
1023 Ipv4Header header,
1024 uint16_t port,
1025 Ptr<Ipv4Interface> incomingInterface)
1026{
1027 NS_LOG_FUNCTION(this << packet << header << port);
1028
1029 if (m_shutdownRecv)
1030 {
1031 return;
1032 }
1033
1034 // Should check via getsockopt ()..
1035 if (IsRecvPktInfo())
1036 {
1038 packet->RemovePacketTag(tag);
1039 tag.SetAddress(header.GetDestination());
1040 tag.SetTtl(header.GetTtl());
1041 tag.SetRecvIf(incomingInterface->GetDevice()->GetIfIndex());
1042 packet->AddPacketTag(tag);
1043 }
1044
1045 // Check only version 4 options
1046 if (IsIpRecvTos())
1047 {
1048 SocketIpTosTag ipTosTag;
1049 ipTosTag.SetTos(header.GetTos());
1050 packet->AddPacketTag(ipTosTag);
1051 }
1052
1053 if (IsIpRecvTtl())
1054 {
1055 SocketIpTtlTag ipTtlTag;
1056 ipTtlTag.SetTtl(header.GetTtl());
1057 packet->AddPacketTag(ipTtlTag);
1058 }
1059
1060 // in case the packet still has a priority tag attached, remove it
1061 SocketPriorityTag priorityTag;
1062 packet->RemovePacketTag(priorityTag);
1063
1064 if ((m_rxAvailable + packet->GetSize()) <= m_rcvBufSize)
1065 {
1067 m_deliveryQueue.emplace(packet, address);
1068 m_rxAvailable += packet->GetSize();
1070 }
1071 else
1072 {
1073 // In general, this case should not occur unless the
1074 // receiving application reads data from this socket slowly
1075 // in comparison to the arrival rate
1076 //
1077 // drop and trace packet
1078 NS_LOG_WARN("No receive buffer space available. Drop.");
1079 m_dropTrace(packet);
1080 }
1081}
1082
1083void
1085 Ipv6Header header,
1086 uint16_t port,
1087 Ptr<Ipv6Interface> incomingInterface)
1088{
1089 NS_LOG_FUNCTION(this << packet << header.GetSource() << port);
1090
1091 if (m_shutdownRecv)
1092 {
1093 return;
1094 }
1095
1096 // Should check via getsockopt ().
1097 if (IsRecvPktInfo())
1098 {
1100 packet->RemovePacketTag(tag);
1101 tag.SetAddress(header.GetDestination());
1102 tag.SetHoplimit(header.GetHopLimit());
1103 tag.SetTrafficClass(header.GetTrafficClass());
1104 tag.SetRecvIf(incomingInterface->GetDevice()->GetIfIndex());
1105 packet->AddPacketTag(tag);
1106 }
1107
1108 // Check only version 6 options
1109 if (IsIpv6RecvTclass())
1110 {
1111 SocketIpv6TclassTag ipTclassTag;
1112 ipTclassTag.SetTclass(header.GetTrafficClass());
1113 packet->AddPacketTag(ipTclassTag);
1114 }
1115
1116 if (IsIpv6RecvHopLimit())
1117 {
1118 SocketIpv6HopLimitTag ipHopLimitTag;
1119 ipHopLimitTag.SetHopLimit(header.GetHopLimit());
1120 packet->AddPacketTag(ipHopLimitTag);
1121 }
1122
1123 // in case the packet still has a priority tag attached, remove it
1124 SocketPriorityTag priorityTag;
1125 packet->RemovePacketTag(priorityTag);
1126
1127 if ((m_rxAvailable + packet->GetSize()) <= m_rcvBufSize)
1128 {
1130 m_deliveryQueue.emplace(packet, address);
1131 m_rxAvailable += packet->GetSize();
1133 }
1134 else
1135 {
1136 // In general, this case should not occur unless the
1137 // receiving application reads data from this socket slowly
1138 // in comparison to the arrival rate
1139 //
1140 // drop and trace packet
1141 NS_LOG_WARN("No receive buffer space available. Drop.");
1142 m_dropTrace(packet);
1143 }
1144}
1145
1146void
1148 uint8_t icmpTtl,
1149 uint8_t icmpType,
1150 uint8_t icmpCode,
1151 uint32_t icmpInfo)
1152{
1153 NS_LOG_FUNCTION(this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType
1154 << (uint32_t)icmpCode << icmpInfo);
1155 if (!m_icmpCallback.IsNull())
1156 {
1157 m_icmpCallback(icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
1158 }
1159}
1160
1161void
1163 uint8_t icmpTtl,
1164 uint8_t icmpType,
1165 uint8_t icmpCode,
1166 uint32_t icmpInfo)
1167{
1168 NS_LOG_FUNCTION(this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType
1169 << (uint32_t)icmpCode << icmpInfo);
1170 if (!m_icmpCallback6.IsNull())
1171 {
1172 m_icmpCallback6(icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
1173 }
1174}
1175
1176void
1178{
1179 m_rcvBufSize = size;
1180}
1181
1184{
1185 return m_rcvBufSize;
1186}
1187
1188void
1190{
1191 m_ipMulticastTtl = ipTtl;
1192}
1193
1194uint8_t
1196{
1197 return m_ipMulticastTtl;
1198}
1199
1200void
1202{
1203 m_ipMulticastIf = ipIf;
1204}
1205
1206int32_t
1208{
1209 return m_ipMulticastIf;
1210}
1211
1212void
1214{
1215 m_ipMulticastLoop = loop;
1216}
1217
1218bool
1220{
1221 return m_ipMulticastLoop;
1222}
1223
1224void
1226{
1227 m_mtuDiscover = discover;
1228}
1229
1230bool
1232{
1233 return m_mtuDiscover;
1234}
1235
1236bool
1238{
1239 m_allowBroadcast = allowBroadcast;
1240 return true;
1241}
1242
1243bool
1245{
1246 return m_allowBroadcast;
1247}
1248
1249void
1252 std::vector<Ipv6Address> sourceAddresses)
1253{
1254 NS_LOG_FUNCTION(this << address << &filterMode << &sourceAddresses);
1255
1256 // We can join only one multicast group (or change its params)
1258 "Can join only one IPv6 multicast group.");
1259
1261
1263 if (ipv6l3)
1264 {
1265 if (filterMode == INCLUDE && sourceAddresses.empty())
1266 {
1267 // it is a leave
1268 if (m_boundnetdevice)
1269 {
1270 int32_t index = ipv6l3->GetInterfaceForDevice(m_boundnetdevice);
1271 NS_ASSERT_MSG(index >= 0, "Interface without a valid index");
1272 ipv6l3->RemoveMulticastAddress(address, index);
1273 }
1274 else
1275 {
1276 ipv6l3->RemoveMulticastAddress(address);
1277 }
1278 }
1279 else
1280 {
1281 // it is a join or a modification
1282 if (m_boundnetdevice)
1283 {
1284 int32_t index = ipv6l3->GetInterfaceForDevice(m_boundnetdevice);
1285 NS_ASSERT_MSG(index >= 0, "Interface without a valid index");
1286 ipv6l3->AddMulticastAddress(address, index);
1287 }
1288 else
1289 {
1290 ipv6l3->AddMulticastAddress(address);
1291 }
1292 }
1293 }
1294}
1295
1296} // namespace ns3
a polymophic address class
Definition: address.h:92
AttributeValue implementation for Callback.
Definition: callback.h:793
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:43
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:50
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()
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:36
void SetDestination(Ipv6Address dst)
Set the "Destination address" field.
Definition: ipv6-header.cc:130
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:142
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:118
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:863
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:60
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.
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.
enum SocketErrno m_errno
Socket error code.
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
enum SocketType GetSocketType() const override
enum 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:831
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:45
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:691
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE
Maximum UDP datagram size.