00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARP_L3_PROTOCOL_H
00021 #define ARP_L3_PROTOCOL_H
00022
00023 #include <list>
00024 #include "ns3/ipv4-address.h"
00025 #include "ns3/address.h"
00026 #include "ns3/ptr.h"
00027 #include "ns3/traced-callback.h"
00028
00029 #include "ipv4-interface.h"
00030
00031 namespace ns3 {
00032
00033 class ArpCache;
00034 class NetDevice;
00035 class Node;
00036 class Packet;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class ArpL3Protocol : public Object
00049 {
00050 public:
00051 static TypeId GetTypeId (void);
00052 static const uint16_t PROT_NUMBER;
00053
00054 ArpL3Protocol ();
00055 virtual ~ArpL3Protocol ();
00056
00057 void SetNode (Ptr<Node> node);
00058
00059 Ptr<ArpCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
00060
00061
00062
00063
00064 void Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
00065 NetDevice::PacketType packetType);
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 bool Lookup (Ptr<Packet> p, Ipv4Address destination,
00076 Ptr<NetDevice> device,
00077 Ptr<ArpCache> cache,
00078 Address *hardwareDestination);
00079 protected:
00080 virtual void DoDispose (void);
00081 private:
00082 typedef std::list<Ptr<ArpCache> > CacheList;
00083 Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
00084 void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
00085 void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address toIp, Address toMac);
00086 CacheList m_cacheList;
00087 Ptr<Node> m_node;
00088 TracedCallback<Ptr<const Packet> > m_dropTrace;
00089 };
00090
00091 }
00092
00093
00094 #endif