a point to point ipv4 interface
This commit is contained in:
14
SConstruct
14
SConstruct
@@ -270,18 +270,6 @@ node.add_inst_headers ([
|
||||
'ascii-trace.h',
|
||||
])
|
||||
|
||||
p2p = build.Ns3Module ('p2p', 'src/devices/p2p')
|
||||
#ns3.add (p2p)
|
||||
p2p.add_deps (['node'])
|
||||
p2p.add_sources ([
|
||||
'p2p-net-device.cc',
|
||||
'p2p-channel.cc',
|
||||
])
|
||||
p2p.add_inst_headers ([
|
||||
'p2p-net-device.h',
|
||||
'p2p-channel.h',
|
||||
])
|
||||
|
||||
p2p = build.Ns3Module ('p2p', 'src/devices/p2p')
|
||||
ns3.add (p2p)
|
||||
p2p.add_deps (['node'])
|
||||
@@ -289,6 +277,7 @@ p2p.add_sources ([
|
||||
'p2p-net-device.cc',
|
||||
'p2p-channel.cc',
|
||||
'p2p-topology.cc',
|
||||
'p2p-ipv4-interface.cc',
|
||||
])
|
||||
p2p.add_headers ([
|
||||
'propagator.h',
|
||||
@@ -297,6 +286,7 @@ p2p.add_inst_headers ([
|
||||
'p2p-net-device.h',
|
||||
'p2p-channel.h',
|
||||
'p2p-topology.h',
|
||||
'p2p-ipv4-interface.h',
|
||||
])
|
||||
|
||||
|
||||
|
||||
55
src/devices/p2p/p2p-ipv4-interface.cc
Normal file
55
src/devices/p2p/p2p-ipv4-interface.cc
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Authors:
|
||||
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
|
||||
*/
|
||||
#include "p2p-ipv4-interface.h"
|
||||
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/composite-trace-resolver.h"
|
||||
#include "ns3/ipv4.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
PointToPointIpv4Interface::PointToPointIpv4Interface (Node *node, NetDevice *device)
|
||||
: Ipv4Interface (device),
|
||||
m_node (node)
|
||||
{}
|
||||
PointToPointIpv4Interface::~PointToPointIpv4Interface ()
|
||||
{}
|
||||
|
||||
void
|
||||
PointToPointIpv4Interface::SendTo (Packet p, Ipv4Address dest)
|
||||
{
|
||||
GetDevice ()->Send (p, GetDevice ()->GetBroadcast (), Ipv4::PROT_NUMBER);
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
PointToPointIpv4Interface::DoCreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
resolver->Add ("netdevice",
|
||||
MakeCallback (&NetDevice::CreateTraceResolver, GetDevice ()),
|
||||
PointToPointIpv4Interface::NETDEVICE);
|
||||
return resolver;
|
||||
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
49
src/devices/p2p/p2p-ipv4-interface.h
Normal file
49
src/devices/p2p/p2p-ipv4-interface.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Authors:
|
||||
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
|
||||
*/
|
||||
#ifndef POINT_TO_POINT_IPV4_INTERFACE_H
|
||||
#define POINT_TO_POINT_IPV4_INTERFACE_H
|
||||
|
||||
#include "ns3/ipv4-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Node;
|
||||
|
||||
class PointToPointIpv4Interface : public Ipv4Interface
|
||||
{
|
||||
public:
|
||||
enum TraceType {
|
||||
NETDEVICE,
|
||||
};
|
||||
PointToPointIpv4Interface (Node *node, NetDevice *device);
|
||||
virtual ~PointToPointIpv4Interface ();
|
||||
|
||||
private:
|
||||
virtual void SendTo (Packet p, Ipv4Address dest);
|
||||
virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context);
|
||||
Node *m_node;
|
||||
};
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
|
||||
#endif /* ARP_IPV4_INTERFACE_H */
|
||||
@@ -30,10 +30,10 @@
|
||||
#include "ns3/internet-node.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/drop-tail.h"
|
||||
#include "ns3/arp-ipv4-interface.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/net-device-list.h"
|
||||
|
||||
#include "p2p-ipv4-interface.h"
|
||||
#include "p2p-channel.h"
|
||||
#include "p2p-net-device.h"
|
||||
#include "p2p-topology.h"
|
||||
@@ -67,7 +67,7 @@ PointToPointTopology::AddPointToPointLink(
|
||||
PointToPointNetDevice* net1 = new PointToPointNetDevice(n1);
|
||||
net1->AddQueue(Queue::Default().Copy());
|
||||
ndl1->Add(net1);
|
||||
Ipv4Interface *interf1 = new ArpIpv4Interface (n1, net1);
|
||||
Ipv4Interface *interf1 = new PointToPointIpv4Interface (n1, net1);
|
||||
uint32_t index1 = n1->GetIpv4 ()->AddInterface (interf1);
|
||||
net1->Attach (channel);
|
||||
|
||||
@@ -78,7 +78,7 @@ PointToPointTopology::AddPointToPointLink(
|
||||
PointToPointNetDevice* net2 = new PointToPointNetDevice(n2);
|
||||
net2->AddQueue(Queue::Default().Copy());
|
||||
ndl2->Add(net2);
|
||||
Ipv4Interface *interf2 = new ArpIpv4Interface (n2, net2);
|
||||
Ipv4Interface *interf2 = new PointToPointIpv4Interface (n2, net2);
|
||||
uint32_t index2 = n2->GetIpv4 ()->AddInterface (interf2);
|
||||
net2->Attach (channel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user