A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,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
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  */
21 #ifndef UDP_L4_PROTOCOL_H
22 #define UDP_L4_PROTOCOL_H
24 #include <stdint.h>
26 #include "ns3/packet.h"
27 #include "ns3/ipv4-address.h"
28 #include "ns3/ipv6-address.h"
29 #include "ns3/ptr.h"
30 #include "ns3/ip-l4-protocol.h"
31 #include "ipv6-interface.h"
32 #include "ipv6-header.h"
34 namespace ns3 {
36 class Node;
37 class Socket;
38 class Ipv4EndPointDemux;
39 class Ipv4EndPoint;
40 class Ipv6EndPointDemux;
41 class Ipv6EndPoint;
42 class UdpSocketImpl;
48 class UdpL4Protocol : public IpL4Protocol {
49 public:
54  static TypeId GetTypeId (void);
55  static const uint8_t PROT_NUMBER;
57  UdpL4Protocol ();
58  virtual ~UdpL4Protocol ();
64  void SetNode (Ptr<Node> node);
66  virtual int GetProtocolNumber (void) const;
78  Ipv4EndPoint *Allocate (void);
90  Ipv4EndPoint *Allocate (uint16_t port);
106  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
107  Ipv4Address peerAddress, uint16_t peerPort);
113  Ipv6EndPoint *Allocate6 (void);
125  Ipv6EndPoint *Allocate6 (uint16_t port);
141  Ipv6EndPoint *Allocate6 (Ipv6Address localAddress, uint16_t localPort,
142  Ipv6Address peerAddress, uint16_t peerPort);
148  void DeAllocate (Ipv4EndPoint *endPoint);
153  void DeAllocate (Ipv6EndPoint *endPoint);
155  // called by UdpSocket.
164  void Send (Ptr<Packet> packet,
165  Ipv4Address saddr, Ipv4Address daddr,
166  uint16_t sport, uint16_t dport);
176  void Send (Ptr<Packet> packet,
177  Ipv4Address saddr, Ipv4Address daddr,
178  uint16_t sport, uint16_t dport, Ptr<Ipv4Route> route);
187  void Send (Ptr<Packet> packet,
188  Ipv6Address saddr, Ipv6Address daddr,
189  uint16_t sport, uint16_t dport);
199  void Send (Ptr<Packet> packet,
200  Ipv6Address saddr, Ipv6Address daddr,
201  uint16_t sport, uint16_t dport, Ptr<Ipv6Route> route);
203  // inherited from Ipv4L4Protocol
205  Ipv4Header const &header,
206  Ptr<Ipv4Interface> interface);
208  Ipv6Header const &header,
209  Ptr<Ipv6Interface> interface);
211  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
212  uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
213  Ipv4Address payloadSource,Ipv4Address payloadDestination,
214  const uint8_t payload[8]);
215  virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
216  uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
217  Ipv6Address payloadSource,Ipv6Address payloadDestination,
218  const uint8_t payload[8]);
220  // From IpL4Protocol
223  // From IpL4Protocol
224  virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
227 protected:
228  virtual void DoDispose (void);
229  /*
230  * This function will notify other components connected to the node that a new stack member is now connected
231  * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
232  */
233  virtual void NotifyNewAggregate ();
234 private:
244  UdpL4Protocol (const UdpL4Protocol &);
253  std::vector<Ptr<UdpSocketImpl> > m_sockets;
257 };
259 } // namespace ns3
261 #endif /* UDP_L4_PROTOCOL_H */
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
Ptr< Socket > CreateSocket(void)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual void SetDownTarget(IpL4Protocol::DownTargetCallback cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
UdpL4Protocol & operator=(const UdpL4Protocol &)
Copy constructor.
Ptr< Node > m_node
the node this stack is associated with
virtual void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
void SetNode(Ptr< Node > node)
Set node associated with this stack.
uint16_t port
Definition: dsdv-manet.cc:44
Demultiplexes packets to various transport layer endpoints.
virtual int GetProtocolNumber(void) const
Packet header for IPv4.
Definition: ipv4-header.h:31
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > interface)
Called from lower-level layers to send the packet up in the stack.
Ipv4EndPoint * Allocate(void)
Allocate an IPv4 Endpoint.
static TypeId GetTypeId(void)
Get the type ID.
virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
virtual void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, Ipv4Address payloadSource, Ipv4Address payloadDestination, const uint8_t payload[8])
Called from lower-level layers to send the ICMP packet up in the stack.
Ipv6EndPointDemux * m_endPoints6
A list of IPv6 end points.
L4 Protocol abstract base class.
void DeAllocate(Ipv4EndPoint *endPoint)
Remove an IPv4 Endpoint.
IpL4Protocol::DownTargetCallback6 m_downTarget6
Callback to send packets over IPv6.
virtual IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
IpL4Protocol::DownTargetCallback m_downTarget
Callback to send packets over IPv4.
virtual void NotifyNewAggregate()
This method is invoked whenever two sets of objects are aggregated together.
Implementation of the UDP protocol.
Demultiplexor for end points.
std::vector< Ptr< UdpSocketImpl > > m_sockets
list of sockets
A representation of an internet IPv6 endpoint/connection.
Ipv4EndPointDemux * m_endPoints
A list of IPv4 end points.
void Send(Ptr< Packet > packet, Ipv4Address saddr, Ipv4Address daddr, uint16_t sport, uint16_t dport)
Send a packet via UDP (IPv4)
Ipv6EndPoint * Allocate6(void)
Allocate an IPv6 Endpoint.
Rx status codes.
tuple address
Definition: first.py:37
a unique identifier for an interface.
Definition: type-id.h:49
static const uint8_t PROT_NUMBER
protocol number (0x11)
A representation of an internet endpoint/connection.