A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
arp-l3-protocol.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 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 #ifndef ARP_L3_PROTOCOL_H
21 #define ARP_L3_PROTOCOL_H
22 
23 #include <list>
24 #include "ns3/ipv4-address.h"
25 #include "ns3/net-device.h"
26 #include "ns3/address.h"
27 #include "ns3/ptr.h"
28 #include "ns3/traced-callback.h"
29 #include "ns3/random-variable-stream.h"
30 
31 namespace ns3 {
32 
33 class ArpCache;
34 class NetDevice;
35 class Node;
36 class Packet;
37 class Ipv4Interface;
38 
49 class ArpL3Protocol : public Object
50 {
51 public:
52  static TypeId GetTypeId (void);
53  static const uint16_t PROT_NUMBER;
54 
55  ArpL3Protocol ();
56  virtual ~ArpL3Protocol ();
57 
58  void SetNode (Ptr<Node> node);
59 
61 
65  void Receive (Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
66  NetDevice::PacketType packetType);
76  bool Lookup (Ptr<Packet> p, Ipv4Address destination,
77  Ptr<NetDevice> device,
78  Ptr<ArpCache> cache,
79  Address *hardwareDestination);
80 
89  int64_t AssignStreams (int64_t stream);
90 
91 protected:
92  virtual void DoDispose (void);
93  /*
94  * This function will notify other components connected to the node that a new stack member is now connected
95  * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
96  */
97  virtual void NotifyNewAggregate ();
98 private:
99  typedef std::list<Ptr<ArpCache> > CacheList;
100  ArpL3Protocol (const ArpL3Protocol &o);
104  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
109 
110 };
111 
112 } // namespace ns3
113 
114 
115 #endif /* ARP_L3_PROTOCOL_H */
void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Receive a packet.
void SendArpReply(Ptr< const ArpCache > cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac)
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
std::list< Ptr< ArpCache > > CacheList
ArpL3Protocol & operator=(const ArpL3Protocol &o)
Ptr< ArpCache > CreateCache(Ptr< NetDevice > device, Ptr< Ipv4Interface > interface)
TracedCallback< Ptr< const Packet > > m_dropTrace
void SendArpRequest(Ptr< const ArpCache >cache, Ipv4Address to)
a polymophic address class
Definition: address.h:86
virtual void NotifyNewAggregate()
virtual void DoDispose(void)
static const uint16_t PROT_NUMBER
int64_t AssignStreams(int64_t stream)
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
bool Lookup(Ptr< Packet > p, Ipv4Address destination, Ptr< NetDevice > device, Ptr< ArpCache > cache, Address *hardwareDestination)
Perform an ARP lookup.
void SetNode(Ptr< Node > node)
Ptr< RandomVariableStream > m_requestJitter
An implementation of the ARP protocol.
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:49
Ptr< ArpCache > FindCache(Ptr< NetDevice > device)
static TypeId GetTypeId(void)