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 
33 NS_OBJECT_ENSURE_REGISTERED (UdpSocket);
34 
35 TypeId
37 {
38  static TypeId tid = TypeId ("ns3::UdpSocket")
39  .SetParent<Socket> ()
40  .AddAttribute ("RcvBufSize",
41  "UdpSocket maximum receive buffer size (bytes)",
42  UintegerValue (131072),
43  MakeUintegerAccessor (&UdpSocket::GetRcvBufSize,
45  MakeUintegerChecker<uint32_t> ())
46  .AddAttribute ("IpTtl",
47  "socket-specific TTL for unicast IP packets (if non-zero)",
48  UintegerValue (0),
49  MakeUintegerAccessor (&UdpSocket::GetIpTtl,
51  MakeUintegerChecker<uint8_t> ())
52  .AddAttribute ("IpMulticastTtl",
53  "socket-specific TTL for multicast IP packets (if non-zero)",
54  UintegerValue (0),
55  MakeUintegerAccessor (&UdpSocket::GetIpMulticastTtl,
57  MakeUintegerChecker<uint8_t> ())
58  .AddAttribute ("IpMulticastIf",
59  "interface index for outgoing multicast on this socket; -1 indicates to use default interface",
60  IntegerValue (-1),
61  MakeIntegerAccessor (&UdpSocket::GetIpMulticastIf,
63  MakeIntegerChecker<int32_t> ())
64  .AddAttribute ("IpMulticastLoop",
65  "whether outgoing multicast sent also to loopback interface",
66  BooleanValue (false),
67  MakeBooleanAccessor (&UdpSocket::GetIpMulticastLoop,
69  MakeBooleanChecker ())
70  .AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
71  BooleanValue (false),
72  MakeBooleanAccessor (&UdpSocket::SetMtuDiscover,
74  MakeBooleanChecker ())
75  ;
76  return tid;
77 }
78 
80 {
82 }
83 
85 {
87 }
88 
89 } // 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:470
virtual uint8_t GetIpMulticastTtl(void) const =0
Get the IP multicast TTL.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
virtual void SetIpMulticastTtl(uint8_t ipTtl)=0
Set the IP multicast TTL.
Hold a signed integer type.
Definition: integer.h:45
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
virtual bool GetIpMulticastLoop(void) const =0
Get the IP multicast loop capability.
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-socket.cc:36
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:84
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:610
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Definition: socket.cc:463