A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udp-socket.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "ns3/object.h"
22 #include "ns3/log.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/integer.h"
25 #include "ns3/boolean.h"
26 #include "ns3/trace-source-accessor.h"
27 #include "udp-socket.h"
28 
29 NS_LOG_COMPONENT_DEFINE ("UdpSocket");
30 
31 namespace ns3 {
32 
34  ;
35 
36 TypeId
38 {
39  static TypeId tid = TypeId ("ns3::UdpSocket")
40  .SetParent<Socket> ()
41  .AddAttribute ("RcvBufSize",
42  "UdpSocket maximum receive buffer size (bytes)",
43  UintegerValue (131072),
44  MakeUintegerAccessor (&UdpSocket::GetRcvBufSize,
46  MakeUintegerChecker<uint32_t> ())
47  .AddAttribute ("IpTtl",
48  "socket-specific TTL for unicast IP packets (if non-zero)",
49  UintegerValue (0),
50  MakeUintegerAccessor (&UdpSocket::GetIpTtl,
52  MakeUintegerChecker<uint8_t> ())
53  .AddAttribute ("IpMulticastTtl",
54  "socket-specific TTL for multicast IP packets (if non-zero)",
55  UintegerValue (0),
56  MakeUintegerAccessor (&UdpSocket::GetIpMulticastTtl,
58  MakeUintegerChecker<uint8_t> ())
59  .AddAttribute ("IpMulticastIf",
60  "interface index for outgoing multicast on this socket; -1 indicates to use default interface",
61  IntegerValue (-1),
62  MakeIntegerAccessor (&UdpSocket::GetIpMulticastIf,
64  MakeIntegerChecker<int32_t> ())
65  .AddAttribute ("IpMulticastLoop",
66  "whether outgoing multicast sent also to loopback interface",
67  BooleanValue (false),
68  MakeBooleanAccessor (&UdpSocket::GetIpMulticastLoop,
70  MakeBooleanChecker ())
71  .AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
72  BooleanValue (false),
73  MakeBooleanAccessor (&UdpSocket::SetMtuDiscover,
75  MakeBooleanChecker ())
76  ;
77  return tid;
78 }
79 
81 {
83 }
84 
86 {
88 }
89 
90 } // namespace ns3
Hold a bool native type.
Definition: boolean.h:38
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:471
virtual uint8_t GetIpMulticastTtl(void) const =0
Get the IP multicast TTL.
NS_LOG_COMPONENT_DEFINE("UdpSocket")
virtual void SetIpMulticastTtl(uint8_t ipTtl)=0
Set the IP multicast TTL.
Hold a signed integer type.
Definition: integer.h:45
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
virtual bool GetIpMulticastLoop(void) const =0
Get the IP multicast loop capability.
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-socket.cc:37
virtual void SetIpMulticastIf(int32_t ipIf)=0
Set the IP multicast interface.
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:66
Hold an unsigned integer type.
Definition: uinteger.h:46
virtual int32_t GetIpMulticastIf(void) const =0
Get the IP multicast interface.
virtual void SetRcvBufSize(uint32_t size)=0
Set the receiving buffer size.
virtual uint32_t GetRcvBufSize(void) const =0
Get the receiving buffer size.
virtual bool GetMtuDiscover(void) const =0
Get the MTU discover capability.
virtual ~UdpSocket(void)
Definition: udp-socket.cc:85
virtual void SetIpMulticastLoop(bool loop)=0
Set the IP multicast loop capability.
virtual void SetMtuDiscover(bool discover)=0
Set the MTU discover capability.
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Definition: socket.cc:464