A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
udp-socket.cc
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
36 UdpSocket::GetTypeId (void)
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,
44  &UdpSocket::SetRcvBufSize),
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,
50  &UdpSocket::SetIpTtl),
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,
56  &UdpSocket::SetIpMulticastTtl),
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,
62  &UdpSocket::SetIpMulticastIf),
63  MakeIntegerChecker<int32_t> ())
64  .AddAttribute ("IpMulticastLoop",
65  "whether outgoing multicast sent also to loopback interface",
66  BooleanValue (false),
67  MakeBooleanAccessor (&UdpSocket::GetIpMulticastLoop,
68  &UdpSocket::SetIpMulticastLoop),
69  MakeBooleanChecker ())
70  .AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
71  BooleanValue (false),
72  MakeBooleanAccessor (&UdpSocket::SetMtuDiscover,
73  &UdpSocket::GetMtuDiscover),
74  MakeBooleanChecker ())
75  ;
76  return tid;
77 }
78 
79 UdpSocket::UdpSocket ()
80 {
82 }
83 
84 UdpSocket::~UdpSocket ()
85 {
87 }
88 
89 } // namespace ns3
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
#define NS_LOG_FUNCTION_NOARGS()
Definition: log.h:275