Merge node and common modules into new network module
This commit is contained in:
756
src/internet-stack/ipv4-address-generator.cc
Normal file
756
src/internet-stack/ipv4-address-generator.cc
Normal file
@@ -0,0 +1,756 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2008 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <list>
|
||||
#include "ns3/abort.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/simulation-singleton.h"
|
||||
#include "ipv4-address-generator.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE("Ipv4AddressGenerator");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Ipv4AddressGeneratorImpl
|
||||
{
|
||||
public:
|
||||
Ipv4AddressGeneratorImpl ();
|
||||
virtual ~Ipv4AddressGeneratorImpl ();
|
||||
|
||||
void Init (const Ipv4Address net, const Ipv4Mask mask,
|
||||
const Ipv4Address addr);
|
||||
|
||||
Ipv4Address GetNetwork (const Ipv4Mask mask) const;
|
||||
Ipv4Address NextNetwork (const Ipv4Mask mask);
|
||||
|
||||
void InitAddress (const Ipv4Address addr, const Ipv4Mask mask);
|
||||
Ipv4Address GetAddress (const Ipv4Mask mask) const;
|
||||
Ipv4Address NextAddress (const Ipv4Mask mask);
|
||||
|
||||
void Reset (void);
|
||||
bool AddAllocated (const Ipv4Address addr);
|
||||
|
||||
void TestMode (void);
|
||||
private:
|
||||
static const uint32_t N_BITS = 32;
|
||||
static const uint32_t MOST_SIGNIFICANT_BIT = 0x80000000;
|
||||
|
||||
uint32_t MaskToIndex (Ipv4Mask mask) const;
|
||||
|
||||
class NetworkState
|
||||
{
|
||||
public:
|
||||
uint32_t mask;
|
||||
uint32_t shift;
|
||||
uint32_t network;
|
||||
uint32_t addr;
|
||||
uint32_t addrMax;
|
||||
};
|
||||
|
||||
NetworkState m_netTable[N_BITS];
|
||||
|
||||
class Entry
|
||||
{
|
||||
public:
|
||||
uint32_t addrLow;
|
||||
uint32_t addrHigh;
|
||||
};
|
||||
|
||||
std::list<Entry> m_entries;
|
||||
bool m_test;
|
||||
};
|
||||
|
||||
Ipv4AddressGeneratorImpl::Ipv4AddressGeneratorImpl ()
|
||||
: m_entries (), m_test (false)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Reset ();
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGeneratorImpl::Reset (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
uint32_t mask = 0;
|
||||
//
|
||||
// There are 32 possible masks in a 32-bit integer. Two of these are illegal
|
||||
// for a network mask (0x00000000 and 0xffffffff). Valid network masks
|
||||
// correspond to some nonzero number of high order bits set to one followed by
|
||||
// some nonzero number of lower order bits set to zero.
|
||||
//
|
||||
// We look at a network number as an n-bit number where n is defined as the
|
||||
// number of bits in each mask. Allocating a new network number is simply
|
||||
// incrementing this number.
|
||||
//
|
||||
// In order to combine an allocated network number with an IP address, we have
|
||||
// to shift the network into the correct alignment with respect to its mask.
|
||||
// For example, a network mask of 0xff000000 admits the possibility of 256
|
||||
// different network numbers since there are eight bits available. To create
|
||||
// IP addresses, we need to shift the network number counter left by 24 bits
|
||||
// to put it in correct alignment. This leaves 24 bits left for addresses.
|
||||
// We make sure we don't overflow by saving a maximum address number which is
|
||||
// just the inverse of the mask (~mask).
|
||||
//
|
||||
for (uint32_t i = 0; i < N_BITS; ++i)
|
||||
{
|
||||
m_netTable[i].mask = mask;
|
||||
mask >>= 1;
|
||||
mask |= MOST_SIGNIFICANT_BIT;
|
||||
m_netTable[i].network = 1;
|
||||
m_netTable[i].addr = 1;
|
||||
m_netTable[i].addrMax = ~mask;
|
||||
m_netTable[i].shift = N_BITS - i;
|
||||
}
|
||||
m_entries.clear ();
|
||||
m_test = false;
|
||||
}
|
||||
|
||||
Ipv4AddressGeneratorImpl::~Ipv4AddressGeneratorImpl ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGeneratorImpl::Init (
|
||||
const Ipv4Address net,
|
||||
const Ipv4Mask mask,
|
||||
const Ipv4Address addr)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
//
|
||||
// We're going to be playing with the actual bits in the network and mask so
|
||||
// pull them out into ints.
|
||||
//
|
||||
uint32_t maskBits = mask.Get ();
|
||||
uint32_t netBits = net.Get ();
|
||||
uint32_t addrBits = addr.Get ();
|
||||
//
|
||||
// Some quick reasonableness testing.
|
||||
//
|
||||
NS_ABORT_MSG_UNLESS ((netBits & ~maskBits) == 0, "Ipv4AddressGeneratorImpl::Init (): Inconsistent network and mask");
|
||||
NS_ABORT_MSG_UNLESS ((addrBits & maskBits) == 0, "Ipv4AddressGeneratorImpl::Init (): Inconsistent address and mask");
|
||||
|
||||
//
|
||||
// Convert the network mask into an index into the network number table.
|
||||
// The network number comes in to us properly aligned for the mask and so
|
||||
// needs to be shifted right into the normalized position (lowest bit of the
|
||||
// network number at bit zero of the int that holds it).
|
||||
//
|
||||
uint32_t index = MaskToIndex (mask);
|
||||
|
||||
m_netTable[index].network = netBits >> m_netTable[index].shift;
|
||||
NS_ABORT_MSG_UNLESS (addrBits <= m_netTable[index].addrMax, "Ipv4AddressGeneratorImpl::Init(): Address overflow");
|
||||
m_netTable[index].addr = addrBits;
|
||||
return;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGeneratorImpl::GetNetwork (
|
||||
const Ipv4Mask mask) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
uint32_t index = MaskToIndex (mask);
|
||||
return Ipv4Address (m_netTable[index].network << m_netTable[index].shift);
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGeneratorImpl::NextNetwork (
|
||||
const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
//
|
||||
// The way this is expected to be used is that an address and network prefix
|
||||
// are initialized, and then NextAddress() is called repeatedly to set the
|
||||
// addresses on a given subnet. The client will expect that the first
|
||||
// addresses will use the network prefix she used to initialize the generator
|
||||
// with. After a subnet is assigned, the client will call NextNetwork to
|
||||
// get the network number of the next subnet. This implies that that this
|
||||
// operation is a pre-increment.
|
||||
//
|
||||
uint32_t index = MaskToIndex (mask);
|
||||
++m_netTable[index].network;
|
||||
return Ipv4Address (m_netTable[index].network << m_netTable[index].shift);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGeneratorImpl::InitAddress (
|
||||
const Ipv4Address addr,
|
||||
const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
uint32_t index = MaskToIndex (mask);
|
||||
uint32_t addrBits = addr.Get ();
|
||||
|
||||
NS_ABORT_MSG_UNLESS (addrBits <= m_netTable[index].addrMax, "Ipv4AddressGeneratorImpl::InitAddress(): Address overflow");
|
||||
m_netTable[index].addr = addrBits;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGeneratorImpl::GetAddress (
|
||||
const Ipv4Mask mask) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
uint32_t index = MaskToIndex (mask);
|
||||
|
||||
return Ipv4Address (
|
||||
(m_netTable[index].network << m_netTable[index].shift) |
|
||||
m_netTable[index].addr);
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGeneratorImpl::NextAddress (const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
//
|
||||
// The way this is expected to be used is that an address and network prefix
|
||||
// are initialized, and then NextAddress() is called repeatedly to set the
|
||||
// addresses on a given subnet. The client will expect that the first address
|
||||
// she gets back is the one she used to initialize the generator with. This
|
||||
// implies that this operation is a post-increment.
|
||||
//
|
||||
uint32_t index = MaskToIndex (mask);
|
||||
|
||||
NS_ABORT_MSG_UNLESS (m_netTable[index].addr <= m_netTable[index].addrMax,
|
||||
"Ipv4AddressGeneratorImpl::NextAddress(): Address overflow");
|
||||
|
||||
Ipv4Address addr = Ipv4Address (
|
||||
(m_netTable[index].network << m_netTable[index].shift) |
|
||||
m_netTable[index].addr);
|
||||
|
||||
++m_netTable[index].addr;
|
||||
//
|
||||
// Make a note that we've allocated this address -- used for address collision
|
||||
// detection.
|
||||
//
|
||||
AddAllocated (addr);
|
||||
return addr;
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4AddressGeneratorImpl::AddAllocated (const Ipv4Address address)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
uint32_t addr = address.Get ();
|
||||
|
||||
NS_ABORT_MSG_UNLESS (addr, "Ipv4AddressGeneratorImpl::Add(): Allocating the broadcast address is not a good idea");
|
||||
|
||||
std::list<Entry>::iterator i;
|
||||
|
||||
for (i = m_entries.begin (); i != m_entries.end (); ++i)
|
||||
{
|
||||
NS_LOG_LOGIC ("examine entry: " << Ipv4Address ((*i).addrLow) <<
|
||||
" to " << Ipv4Address ((*i).addrHigh));
|
||||
//
|
||||
// First things first. Is there an address collision -- that is, does the
|
||||
// new address fall in a previously allocated block of addresses.
|
||||
//
|
||||
if (addr >= (*i).addrLow && addr <= (*i).addrHigh)
|
||||
{
|
||||
NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
|
||||
if (!m_test)
|
||||
{
|
||||
NS_FATAL_ERROR ("Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//
|
||||
// If the new address is less than the lowest address in the current block,
|
||||
// and can't be merged into to the current block, then insert it as a new
|
||||
// block before the current block.
|
||||
//
|
||||
if (addr < (*i).addrLow - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
//
|
||||
// If the new address fits at the end of the block, look ahead to the next
|
||||
// block and make sure it's not a collision there. If we won't overlap, then
|
||||
// just extend the current block by one address. We expect that completely
|
||||
// filled network ranges will be a fairly rare occurrence, so we don't worry
|
||||
// about collapsing address range blocks.
|
||||
//
|
||||
if (addr == (*i).addrHigh + 1)
|
||||
{
|
||||
std::list<Entry>::iterator j = i;
|
||||
++j;
|
||||
|
||||
if (j != m_entries.end ())
|
||||
{
|
||||
if (addr == (*j).addrLow)
|
||||
{
|
||||
NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): "
|
||||
"Address Collision: " << Ipv4Address (addr));
|
||||
if (!m_test)
|
||||
{
|
||||
NS_FATAL_ERROR ("Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
NS_LOG_LOGIC ("New addrHigh = " << Ipv4Address (addr));
|
||||
(*i).addrHigh = addr;
|
||||
return true;
|
||||
}
|
||||
//
|
||||
// If we get here, we know that the next lower block of addresses couldn't
|
||||
// have been extended to include this new address since the code immediately
|
||||
// above would have been executed and that next lower block extended upward.
|
||||
// So we know it's safe to extend the current block down to includ the new
|
||||
// address.
|
||||
//
|
||||
if (addr == (*i).addrLow - 1)
|
||||
{
|
||||
NS_LOG_LOGIC ("New addrLow = " << Ipv4Address (addr));
|
||||
(*i).addrLow = addr;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Entry entry;
|
||||
entry.addrLow = entry.addrHigh = addr;
|
||||
m_entries.insert(i, entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGeneratorImpl::TestMode (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_test = true;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Ipv4AddressGeneratorImpl::MaskToIndex (Ipv4Mask mask) const
|
||||
{
|
||||
//
|
||||
// We've been given a mask that has a higher order bit set for each bit of the
|
||||
// network number. In order to translate this mask into an index, we just need
|
||||
// to count the number of zero bits in the mask. We do this in a loop in which
|
||||
// we shift the mask right until we find the first nonzero bit. This tells us
|
||||
// the number of zero bits, and from this we infer the number of nonzero bits
|
||||
// which is the number of bits in the mask.
|
||||
//
|
||||
// We use the number of bits in the mask as the number of bits in the network
|
||||
// number and as the index into the network number state table.
|
||||
//
|
||||
uint32_t maskBits = mask.Get ();
|
||||
|
||||
for (uint32_t i = 0; i < N_BITS; ++i)
|
||||
{
|
||||
if (maskBits & 1)
|
||||
{
|
||||
uint32_t index = N_BITS - i;
|
||||
NS_ABORT_MSG_UNLESS (index > 0 && index < N_BITS, "Ipv4AddressGenerator::MaskToIndex(): Illegal Mask");
|
||||
return index;
|
||||
}
|
||||
maskBits >>= 1;
|
||||
}
|
||||
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGenerator::Init (
|
||||
const Ipv4Address net,
|
||||
const Ipv4Mask mask,
|
||||
const Ipv4Address addr)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->Init (net, mask, addr);
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGenerator::NextNetwork (const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->NextNetwork (mask);
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGenerator::GetNetwork (const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->GetNetwork (mask);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGenerator::InitAddress (
|
||||
const Ipv4Address addr,
|
||||
const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->InitAddress (addr, mask);
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGenerator::GetAddress (const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->GetAddress (mask);
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4AddressGenerator::NextAddress (const Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->NextAddress (mask);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGenerator::Reset (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->Reset ();
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4AddressGenerator::AddAllocated (const Ipv4Address addr)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->AddAllocated (addr);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4AddressGenerator::TestMode (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
|
||||
->TestMode ();
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#include "ns3/test.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class NetworkNumberAllocatorTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
NetworkNumberAllocatorTestCase ();
|
||||
virtual void DoRun (void);
|
||||
virtual void DoTeardown (void);
|
||||
};
|
||||
|
||||
NetworkNumberAllocatorTestCase::NetworkNumberAllocatorTestCase ()
|
||||
: TestCase ("Make sure the network number allocator is working on some of network prefixes.")
|
||||
{}
|
||||
void
|
||||
NetworkNumberAllocatorTestCase::DoTeardown (void)
|
||||
{
|
||||
Ipv4AddressGenerator::Reset ();
|
||||
}
|
||||
void
|
||||
NetworkNumberAllocatorTestCase::DoRun (void)
|
||||
{
|
||||
Ipv4Address network;
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("1.0.0.0"), Ipv4Mask ("255.0.0.0"),
|
||||
Ipv4Address ("0.0.0.0"));
|
||||
network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("1.0.0.0"), "XXX");
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("2.0.0.0"), "XXX");
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("0.1.0.0"),
|
||||
Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.0"));
|
||||
network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.1.0.0"), "XXX");
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.2.0.0"), "XXX");
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("0.0.1.0"),
|
||||
Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.0"));
|
||||
network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.1.0"), "XXX");
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.2.0"), "XXX");
|
||||
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("3.0.0.0"), "XXX");
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.3.0.0"), "XXX");
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.3.0"), "XXX");
|
||||
}
|
||||
|
||||
class AddressAllocatorTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
AddressAllocatorTestCase ();
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
virtual void DoTeardown (void);
|
||||
};
|
||||
|
||||
AddressAllocatorTestCase::AddressAllocatorTestCase ()
|
||||
: TestCase ("Sanity check on allocation of addresses")
|
||||
{}
|
||||
|
||||
void
|
||||
AddressAllocatorTestCase::DoRun (void)
|
||||
{
|
||||
Ipv4Address address;
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("1.0.0.0"), Ipv4Mask ("255.0.0.0"),
|
||||
Ipv4Address ("0.0.0.3"));
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.3"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.4"), "XXX");
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("0.1.0.0"),
|
||||
Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.3"));
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.3"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.4"), "XXX");
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("0.0.1.0"),
|
||||
Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.3"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.4"), "XXX");
|
||||
}
|
||||
|
||||
void
|
||||
AddressAllocatorTestCase::DoTeardown (void)
|
||||
{
|
||||
Ipv4AddressGenerator::Reset ();
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
|
||||
|
||||
class NetworkAndAddressTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
NetworkAndAddressTestCase ();
|
||||
virtual void DoRun (void);
|
||||
virtual void DoTeardown (void);
|
||||
};
|
||||
|
||||
NetworkAndAddressTestCase::NetworkAndAddressTestCase ()
|
||||
: TestCase ("Make sure Network and address allocation play together.")
|
||||
{}
|
||||
|
||||
void
|
||||
NetworkAndAddressTestCase::DoTeardown (void)
|
||||
{
|
||||
Ipv4AddressGenerator::Reset ();
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
|
||||
void
|
||||
NetworkAndAddressTestCase::DoRun (void)
|
||||
{
|
||||
Ipv4Address address;
|
||||
Ipv4Address network;
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("3.0.0.0"), Ipv4Mask ("255.0.0.0"),
|
||||
Ipv4Address ("0.0.0.3"));
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("3.0.0.3"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("3.0.0.4"), "XXX");
|
||||
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("4.0.0.0"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("4.0.0.5"), "XXX");
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("0.3.0.0"),
|
||||
Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.3"));
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.3.0.3"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.3.0.4"), "XXX");
|
||||
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.4.0.0"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.4.0.5"), "XXX");
|
||||
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("0.0.3.0"),
|
||||
Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.3.3"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.3.4"), "XXX");
|
||||
|
||||
network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.4.0"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.4.5"), "XXX");
|
||||
}
|
||||
|
||||
class ExampleAddressGeneratorTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
ExampleAddressGeneratorTestCase ();
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
virtual void DoTeardown (void);
|
||||
};
|
||||
|
||||
ExampleAddressGeneratorTestCase::ExampleAddressGeneratorTestCase ()
|
||||
: TestCase ("A quick kindof-semi-almost-real example")
|
||||
{}
|
||||
|
||||
void
|
||||
ExampleAddressGeneratorTestCase::DoTeardown (void)
|
||||
{
|
||||
Ipv4AddressGenerator::Reset ();
|
||||
}
|
||||
|
||||
void
|
||||
ExampleAddressGeneratorTestCase::DoRun (void)
|
||||
{
|
||||
Ipv4Address address;
|
||||
//
|
||||
// First, initialize our /24 network to 192.168.0.0 and begin
|
||||
// allocating with ip address 0.0.0.3 out of that prefix.
|
||||
//
|
||||
Ipv4AddressGenerator::Init (Ipv4Address ("192.168.0.0"),
|
||||
Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.0.3"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.0.4"), "XXX");
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.0.5"), "XXX");
|
||||
//
|
||||
// Allocate the next network out of our /24 network (this should be
|
||||
// 192.168.1.0) and begin allocating with IP address 0.0.0.3 out of that
|
||||
// prefix.
|
||||
//
|
||||
Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
|
||||
Ipv4AddressGenerator::InitAddress (Ipv4Address ("0.0.0.3"),
|
||||
Ipv4Mask ("255.255.255.0"));
|
||||
//
|
||||
// The first address we should get is the previous numbers ORed together, which
|
||||
// is 192.168.1.3, of course.
|
||||
//
|
||||
address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
|
||||
NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.1.3"), "XXX");
|
||||
}
|
||||
|
||||
class AddressCollisionTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
AddressCollisionTestCase ();
|
||||
private:
|
||||
void DoRun (void);
|
||||
void DoTeardown (void);
|
||||
};
|
||||
|
||||
AddressCollisionTestCase::AddressCollisionTestCase ()
|
||||
: TestCase ("Make sure that the address collision logic works.")
|
||||
{}
|
||||
|
||||
void
|
||||
AddressCollisionTestCase::DoTeardown (void)
|
||||
{
|
||||
Ipv4AddressGenerator::Reset ();
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
void
|
||||
AddressCollisionTestCase::DoRun (void)
|
||||
{
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.5");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.10");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.15");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.20");
|
||||
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.4");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.3");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.2");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.1");
|
||||
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.6");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.7");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.8");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.9");
|
||||
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.11");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.12");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.13");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.14");
|
||||
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.19");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.18");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.17");
|
||||
Ipv4AddressGenerator::AddAllocated ("0.0.0.16");
|
||||
|
||||
Ipv4AddressGenerator::TestMode ();
|
||||
bool added = Ipv4AddressGenerator::AddAllocated ("0.0.0.21");
|
||||
NS_TEST_EXPECT_MSG_EQ (added, true, "XXX");
|
||||
|
||||
added = Ipv4AddressGenerator::AddAllocated ("0.0.0.4");
|
||||
NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
|
||||
|
||||
added = Ipv4AddressGenerator::AddAllocated ("0.0.0.9");
|
||||
NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
|
||||
|
||||
added = Ipv4AddressGenerator::AddAllocated ("0.0.0.16");
|
||||
NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
|
||||
|
||||
added = Ipv4AddressGenerator::AddAllocated ("0.0.0.21");
|
||||
NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
|
||||
}
|
||||
|
||||
|
||||
static class Ipv4AddressGeneratorTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
Ipv4AddressGeneratorTestSuite ()
|
||||
: TestSuite ("ipv4-address-generator")
|
||||
{
|
||||
AddTestCase (new NetworkNumberAllocatorTestCase ());
|
||||
AddTestCase (new AddressAllocatorTestCase ());
|
||||
AddTestCase (new NetworkAndAddressTestCase ());
|
||||
AddTestCase (new ExampleAddressGeneratorTestCase ());
|
||||
AddTestCase (new AddressCollisionTestCase ());
|
||||
}
|
||||
} g_ipv4AddressGeneratorTestSuite;
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
52
src/internet-stack/ipv4-address-generator.h
Normal file
52
src/internet-stack/ipv4-address-generator.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2008 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef IPV4_ADDRESS_GENERATOR_H
|
||||
#define IPV4_ADDRESS_GENERATOR_H
|
||||
|
||||
#include "ns3/ipv4-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup address
|
||||
*
|
||||
* \brief This generator assigns addresses sequentially from a provided
|
||||
* network address; used in topology code.
|
||||
*/
|
||||
class Ipv4AddressGenerator {
|
||||
public:
|
||||
static void Init (const Ipv4Address net, const Ipv4Mask mask,
|
||||
const Ipv4Address addr = "0.0.0.1");
|
||||
|
||||
static Ipv4Address NextNetwork (const Ipv4Mask mask);
|
||||
static Ipv4Address GetNetwork (const Ipv4Mask mask);
|
||||
|
||||
static void InitAddress (const Ipv4Address addr, const Ipv4Mask mask);
|
||||
static Ipv4Address NextAddress (const Ipv4Mask mask);
|
||||
static Ipv4Address GetAddress (const Ipv4Mask mask);
|
||||
|
||||
static void Reset (void);
|
||||
static bool AddAllocated (const Ipv4Address addr);
|
||||
|
||||
static void TestMode (void);
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* IPV4_ADDRESS_GENERATOR_H */
|
||||
322
src/internet-stack/ipv4-header.cc
Normal file
322
src/internet-stack/ipv4-header.cc
Normal file
@@ -0,0 +1,322 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/header.h"
|
||||
#include "ipv4-header.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Ipv4Header");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv4Header);
|
||||
|
||||
Ipv4Header::Ipv4Header ()
|
||||
: m_calcChecksum (false),
|
||||
m_payloadSize (0),
|
||||
m_identification (0),
|
||||
m_tos (0),
|
||||
m_ttl (0),
|
||||
m_protocol (0),
|
||||
m_flags (0),
|
||||
m_fragmentOffset (0),
|
||||
m_checksum(0),
|
||||
m_goodChecksum (true)
|
||||
{}
|
||||
|
||||
void
|
||||
Ipv4Header::EnableChecksum (void)
|
||||
{
|
||||
m_calcChecksum = true;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::SetPayloadSize (uint16_t size)
|
||||
{
|
||||
m_payloadSize = size;
|
||||
}
|
||||
uint16_t
|
||||
Ipv4Header::GetPayloadSize (void) const
|
||||
{
|
||||
return m_payloadSize;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
Ipv4Header::GetIdentification (void) const
|
||||
{
|
||||
return m_identification;
|
||||
}
|
||||
void
|
||||
Ipv4Header::SetIdentification (uint16_t identification)
|
||||
{
|
||||
m_identification = identification;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
Ipv4Header::SetTos (uint8_t tos)
|
||||
{
|
||||
m_tos = tos;
|
||||
}
|
||||
uint8_t
|
||||
Ipv4Header::GetTos (void) const
|
||||
{
|
||||
return m_tos;
|
||||
}
|
||||
void
|
||||
Ipv4Header::SetMoreFragments (void)
|
||||
{
|
||||
m_flags |= MORE_FRAGMENTS;
|
||||
}
|
||||
void
|
||||
Ipv4Header::SetLastFragment (void)
|
||||
{
|
||||
m_flags &= ~MORE_FRAGMENTS;
|
||||
}
|
||||
bool
|
||||
Ipv4Header::IsLastFragment (void) const
|
||||
{
|
||||
return !(m_flags & MORE_FRAGMENTS);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::SetDontFragment (void)
|
||||
{
|
||||
m_flags |= DONT_FRAGMENT;
|
||||
}
|
||||
void
|
||||
Ipv4Header::SetMayFragment (void)
|
||||
{
|
||||
m_flags &= ~DONT_FRAGMENT;
|
||||
}
|
||||
bool
|
||||
Ipv4Header::IsDontFragment (void) const
|
||||
{
|
||||
return (m_flags & DONT_FRAGMENT);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::SetFragmentOffset (uint16_t offset)
|
||||
{
|
||||
NS_ASSERT (!(offset & (~0x3fff)));
|
||||
m_fragmentOffset = offset;
|
||||
}
|
||||
uint16_t
|
||||
Ipv4Header::GetFragmentOffset (void) const
|
||||
{
|
||||
NS_ASSERT (!(m_fragmentOffset & (~0x3fff)));
|
||||
return m_fragmentOffset;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::SetTtl (uint8_t ttl)
|
||||
{
|
||||
m_ttl = ttl;
|
||||
}
|
||||
uint8_t
|
||||
Ipv4Header::GetTtl (void) const
|
||||
{
|
||||
return m_ttl;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Ipv4Header::GetProtocol (void) const
|
||||
{
|
||||
return m_protocol;
|
||||
}
|
||||
void
|
||||
Ipv4Header::SetProtocol (uint8_t protocol)
|
||||
{
|
||||
m_protocol = protocol;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::SetSource (Ipv4Address source)
|
||||
{
|
||||
m_source = source;
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4Header::GetSource (void) const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::SetDestination (Ipv4Address dst)
|
||||
{
|
||||
m_destination = dst;
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4Header::GetDestination (void) const
|
||||
{
|
||||
return m_destination;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Ipv4Header::IsChecksumOk (void) const
|
||||
{
|
||||
return m_goodChecksum;
|
||||
}
|
||||
|
||||
TypeId
|
||||
Ipv4Header::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv4Header")
|
||||
.SetParent<Header> ()
|
||||
.AddConstructor<Ipv4Header> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
TypeId
|
||||
Ipv4Header::GetInstanceTypeId (void) const
|
||||
{
|
||||
return GetTypeId ();
|
||||
}
|
||||
void
|
||||
Ipv4Header::Print (std::ostream &os) const
|
||||
{
|
||||
// ipv4, right ?
|
||||
std::string flags;
|
||||
if (m_flags == 0)
|
||||
{
|
||||
flags = "none";
|
||||
}
|
||||
else if (m_flags & MORE_FRAGMENTS &&
|
||||
m_flags & DONT_FRAGMENT)
|
||||
{
|
||||
flags = "MF|DF";
|
||||
}
|
||||
else if (m_flags & DONT_FRAGMENT)
|
||||
{
|
||||
flags = "DF";
|
||||
}
|
||||
else if (m_flags & MORE_FRAGMENTS)
|
||||
{
|
||||
flags = "MF";
|
||||
}
|
||||
else
|
||||
{
|
||||
flags = "XX";
|
||||
}
|
||||
os << "tos 0x" << std::hex << m_tos << std::dec << " "
|
||||
<< "ttl " << m_ttl << " "
|
||||
<< "id " << m_identification << " "
|
||||
<< "protocol " << m_protocol << " "
|
||||
<< "offset " << m_fragmentOffset << " "
|
||||
<< "flags [" << flags << "] "
|
||||
<< "length: " << (m_payloadSize + 5 * 4)
|
||||
<< " "
|
||||
<< m_source << " > " << m_destination
|
||||
;
|
||||
}
|
||||
uint32_t
|
||||
Ipv4Header::GetSerializedSize (void) const
|
||||
{
|
||||
return 5 * 4;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Header::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
uint8_t verIhl = (4 << 4) | (5);
|
||||
i.WriteU8 (verIhl);
|
||||
i.WriteU8 (m_tos);
|
||||
i.WriteHtonU16 (m_payloadSize + 5*4);
|
||||
i.WriteHtonU16 (m_identification);
|
||||
uint32_t fragmentOffset = m_fragmentOffset / 8;
|
||||
uint8_t flagsFrag = (fragmentOffset >> 8) & 0x1f;
|
||||
if (m_flags & DONT_FRAGMENT)
|
||||
{
|
||||
flagsFrag |= (1<<6);
|
||||
}
|
||||
if (m_flags & MORE_FRAGMENTS)
|
||||
{
|
||||
flagsFrag |= (1<<5);
|
||||
}
|
||||
i.WriteU8 (flagsFrag);
|
||||
uint8_t frag = fragmentOffset & 0xff;
|
||||
i.WriteU8 (frag);
|
||||
i.WriteU8 (m_ttl);
|
||||
i.WriteU8 (m_protocol);
|
||||
i.WriteHtonU16 (0);
|
||||
i.WriteHtonU32 (m_source.Get ());
|
||||
i.WriteHtonU32 (m_destination.Get ());
|
||||
|
||||
if (m_calcChecksum)
|
||||
{
|
||||
i = start;
|
||||
uint16_t checksum = i.CalculateIpChecksum(20);
|
||||
NS_LOG_LOGIC ("checksum=" <<checksum);
|
||||
i = start;
|
||||
i.Next (10);
|
||||
i.WriteU16 (checksum);
|
||||
}
|
||||
}
|
||||
uint32_t
|
||||
Ipv4Header::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
uint8_t verIhl = i.ReadU8 ();
|
||||
uint8_t ihl = verIhl & 0x0f;
|
||||
uint16_t headerSize = ihl * 4;
|
||||
NS_ASSERT ((verIhl >> 4) == 4);
|
||||
m_tos = i.ReadU8 ();
|
||||
uint16_t size = i.ReadNtohU16 ();
|
||||
m_payloadSize = size - headerSize;
|
||||
m_identification = i.ReadNtohU16 ();
|
||||
uint8_t flags = i.ReadU8 ();
|
||||
m_flags = 0;
|
||||
if (flags & (1<<6))
|
||||
{
|
||||
m_flags |= DONT_FRAGMENT;
|
||||
}
|
||||
if (flags & (1<<5))
|
||||
{
|
||||
m_flags |= MORE_FRAGMENTS;
|
||||
}
|
||||
i.Prev ();
|
||||
m_fragmentOffset = i.ReadU8 () & 0x1f;
|
||||
m_fragmentOffset <<= 8;
|
||||
m_fragmentOffset |= i.ReadU8 ();
|
||||
m_fragmentOffset <<= 3;
|
||||
m_ttl = i.ReadU8 ();
|
||||
m_protocol = i.ReadU8 ();
|
||||
m_checksum = i.ReadU16();
|
||||
/* i.Next (2); // checksum */
|
||||
m_source.Set (i.ReadNtohU32 ());
|
||||
m_destination.Set (i.ReadNtohU32 ());
|
||||
|
||||
if (m_calcChecksum)
|
||||
{
|
||||
i = start;
|
||||
uint16_t checksum = i.CalculateIpChecksum(headerSize);
|
||||
NS_LOG_LOGIC ("checksum=" <<checksum);
|
||||
|
||||
m_goodChecksum = (checksum == 0);
|
||||
}
|
||||
return GetSerializedSize ();
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
172
src/internet-stack/ipv4-header.h
Normal file
172
src/internet-stack/ipv4-header.h
Normal file
@@ -0,0 +1,172 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef IPV4_HEADER_H
|
||||
#define IPV4_HEADER_H
|
||||
|
||||
#include "ns3/header.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
/**
|
||||
* \brief Packet header for IPv4
|
||||
*/
|
||||
class Ipv4Header : public Header
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Construct a null IPv4 header
|
||||
*/
|
||||
Ipv4Header ();
|
||||
/**
|
||||
* \brief Enable checksum calculation for this header.
|
||||
*/
|
||||
void EnableChecksum (void);
|
||||
/**
|
||||
* \param size the size of the payload in bytes
|
||||
*/
|
||||
void SetPayloadSize (uint16_t size);
|
||||
/**
|
||||
* \param identification the Identification field of IPv4 packets.
|
||||
*
|
||||
* By default, set to zero.
|
||||
*/
|
||||
void SetIdentification (uint16_t identification);
|
||||
/**
|
||||
* \param tos the 8 bits of Ipv4 TOS.
|
||||
*/
|
||||
void SetTos (uint8_t tos);
|
||||
/**
|
||||
* This packet is not the last packet of a fragmented ipv4 packet.
|
||||
*/
|
||||
void SetMoreFragments (void);
|
||||
/**
|
||||
* This packet is the last packet of a fragmented ipv4 packet.
|
||||
*/
|
||||
void SetLastFragment (void);
|
||||
/**
|
||||
* Don't fragment this packet: if you need to anyway, drop it.
|
||||
*/
|
||||
void SetDontFragment (void);
|
||||
/**
|
||||
* If you need to fragment this packet, you can do it.
|
||||
*/
|
||||
void SetMayFragment (void);
|
||||
/**
|
||||
* \param offset the ipv4 fragment offset
|
||||
*/
|
||||
void SetFragmentOffset (uint16_t offset);
|
||||
/**
|
||||
* \param ttl the ipv4 TTL
|
||||
*/
|
||||
void SetTtl (uint8_t ttl);
|
||||
/**
|
||||
* \param num the ipv4 protocol field
|
||||
*/
|
||||
void SetProtocol (uint8_t num);
|
||||
/**
|
||||
* \param source the source of this packet
|
||||
*/
|
||||
void SetSource (Ipv4Address source);
|
||||
/**
|
||||
* \param destination the destination of this packet.
|
||||
*/
|
||||
void SetDestination (Ipv4Address destination);
|
||||
/**
|
||||
* \returns the size of the payload in bytes
|
||||
*/
|
||||
uint16_t GetPayloadSize (void) const;
|
||||
/**
|
||||
* \returns the identification field of this packet.
|
||||
*/
|
||||
uint16_t GetIdentification (void) const;
|
||||
/**
|
||||
* \returns the TOS field of this packet.
|
||||
*/
|
||||
uint8_t GetTos (void) const;
|
||||
/**
|
||||
* \returns true if this is the last fragment of a packet, false otherwise.
|
||||
*/
|
||||
bool IsLastFragment (void) const;
|
||||
/**
|
||||
* \returns true if this is this packet can be fragmented.
|
||||
*/
|
||||
bool IsDontFragment (void) const;
|
||||
/**
|
||||
* \returns the offset of this fragment.
|
||||
*/
|
||||
uint16_t GetFragmentOffset (void) const;
|
||||
/**
|
||||
* \returns the TTL field of this packet
|
||||
*/
|
||||
uint8_t GetTtl (void) const;
|
||||
/**
|
||||
* \returns the protocol field of this packet
|
||||
*/
|
||||
uint8_t GetProtocol (void) const;
|
||||
/**
|
||||
* \returns the source address of this packet
|
||||
*/
|
||||
Ipv4Address GetSource (void) const;
|
||||
/**
|
||||
* \returns the destination address of this packet
|
||||
*/
|
||||
Ipv4Address GetDestination (void) const;
|
||||
|
||||
/**
|
||||
* \returns true if the ipv4 checksum is correct, false otherwise.
|
||||
*
|
||||
* If Ipv4Header::EnableChecksums has not been called prior to
|
||||
* deserializing this header, this method will always return true.
|
||||
*/
|
||||
bool IsChecksumOk (void) const;
|
||||
|
||||
static TypeId GetTypeId (void);
|
||||
virtual TypeId GetInstanceTypeId (void) const;
|
||||
virtual void Print (std::ostream &os) const;
|
||||
virtual uint32_t GetSerializedSize (void) const;
|
||||
virtual void Serialize (Buffer::Iterator start) const;
|
||||
virtual uint32_t Deserialize (Buffer::Iterator start);
|
||||
private:
|
||||
|
||||
enum FlagsE {
|
||||
DONT_FRAGMENT = (1<<0),
|
||||
MORE_FRAGMENTS = (1<<1)
|
||||
};
|
||||
|
||||
bool m_calcChecksum;
|
||||
|
||||
uint16_t m_payloadSize;
|
||||
uint16_t m_identification;
|
||||
uint32_t m_tos : 8;
|
||||
uint32_t m_ttl : 8;
|
||||
uint32_t m_protocol : 8;
|
||||
uint32_t m_flags : 3;
|
||||
uint16_t m_fragmentOffset : 13;
|
||||
Ipv4Address m_source;
|
||||
Ipv4Address m_destination;
|
||||
uint16_t m_checksum;
|
||||
bool m_goodChecksum;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
#endif /* IPV4_HEADER_H */
|
||||
141
src/internet-stack/ipv4-interface-address.cc
Normal file
141
src/internet-stack/ipv4-interface-address.cc
Normal file
@@ -0,0 +1,141 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "ipv4-interface-address.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE("Ipv4InterfaceAddress");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Ipv4InterfaceAddress::Ipv4InterfaceAddress ()
|
||||
: m_scope (GLOBAL),
|
||||
m_secondary (false)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
Ipv4InterfaceAddress::Ipv4InterfaceAddress (Ipv4Address local, Ipv4Mask mask)
|
||||
: m_scope (GLOBAL),
|
||||
m_secondary (false)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
m_local = local;
|
||||
m_mask = mask;
|
||||
m_broadcast = Ipv4Address (local.Get () | (~mask.Get ()));
|
||||
}
|
||||
|
||||
Ipv4InterfaceAddress::Ipv4InterfaceAddress (const Ipv4InterfaceAddress &o)
|
||||
: m_local (o.m_local),
|
||||
m_mask (o.m_mask),
|
||||
m_broadcast (o.m_broadcast),
|
||||
m_scope (o.m_scope),
|
||||
m_secondary (o.m_secondary)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4InterfaceAddress::SetLocal (Ipv4Address local)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_local = local;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4InterfaceAddress::GetLocal (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_local;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4InterfaceAddress::SetMask (Ipv4Mask mask)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_mask = mask;
|
||||
}
|
||||
|
||||
Ipv4Mask
|
||||
Ipv4InterfaceAddress::GetMask (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_mask;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4InterfaceAddress::SetBroadcast (Ipv4Address broadcast)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_broadcast = broadcast;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4InterfaceAddress::GetBroadcast (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_broadcast;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4InterfaceAddress::SetScope (Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_scope = scope;
|
||||
}
|
||||
|
||||
Ipv4InterfaceAddress::InterfaceAddressScope_e
|
||||
Ipv4InterfaceAddress::GetScope (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_scope;
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4InterfaceAddress::IsSecondary (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_secondary;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4InterfaceAddress::SetSecondary (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_secondary = true;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4InterfaceAddress::SetPrimary (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_secondary = false;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Ipv4InterfaceAddress &addr)
|
||||
{
|
||||
os << "m_local=" << addr.GetLocal () << "; m_mask=" <<
|
||||
addr.GetMask () << "; m_broadcast=" << addr.GetBroadcast () << "; m_scope=" << addr.GetScope() <<
|
||||
"; m_secondary=" << addr.IsSecondary ();
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
101
src/internet-stack/ipv4-interface-address.h
Normal file
101
src/internet-stack/ipv4-interface-address.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2008 University of Washington
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef IPV4_INTERFACE_ADDRESS_H
|
||||
#define IPV4_INTERFACE_ADDRESS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ostream>
|
||||
#include "ns3/ipv4-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup address
|
||||
*
|
||||
* \brief a class to store IPv4 address information on an interface
|
||||
*
|
||||
* Corresponds to Linux struct in_ifaddr. A list of these addresses
|
||||
* is stored in Ipv4Interface. This class is modelled after how current
|
||||
* Linux handles IP aliasing for IPv4. Notably, aliasing of IPv4
|
||||
* interfaces (e.g., "eth0:1") is not used, and instead an interface
|
||||
* is assigned possibly multiple addresses, with each address being
|
||||
* classified as being primary and secondary. See the iproute2
|
||||
* documentation for this distinction.
|
||||
*/
|
||||
class Ipv4InterfaceAddress
|
||||
{
|
||||
public:
|
||||
enum InterfaceAddressScope_e {
|
||||
HOST,
|
||||
LINK,
|
||||
GLOBAL
|
||||
};
|
||||
|
||||
Ipv4InterfaceAddress ();
|
||||
// Configure m_local, m_mask, and m_broadcast from the below constructor
|
||||
Ipv4InterfaceAddress (Ipv4Address local, Ipv4Mask mask);
|
||||
Ipv4InterfaceAddress (const Ipv4InterfaceAddress &o);
|
||||
|
||||
void SetLocal (Ipv4Address local);
|
||||
Ipv4Address GetLocal (void) const;
|
||||
void SetMask (Ipv4Mask mask);
|
||||
Ipv4Mask GetMask (void) const;
|
||||
void SetBroadcast (Ipv4Address broadcast);
|
||||
Ipv4Address GetBroadcast (void) const;
|
||||
|
||||
void SetScope (Ipv4InterfaceAddress::InterfaceAddressScope_e scope);
|
||||
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope (void) const;
|
||||
|
||||
bool IsSecondary (void) const;
|
||||
void SetSecondary (void);
|
||||
void SetPrimary (void);
|
||||
|
||||
private:
|
||||
|
||||
Ipv4Address m_local; // Interface address
|
||||
// Note: m_peer may be added in future when necessary
|
||||
// Ipv4Address m_peer; // Peer destination address (in Linux: m_address)
|
||||
Ipv4Mask m_mask; // Network mask
|
||||
Ipv4Address m_broadcast; // Broadcast address
|
||||
|
||||
InterfaceAddressScope_e m_scope;
|
||||
bool m_secondary; // For use in multihoming
|
||||
|
||||
friend bool operator == (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
|
||||
friend bool operator != (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Ipv4InterfaceAddress &addr);
|
||||
|
||||
inline bool operator == (const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
|
||||
{
|
||||
return (a.m_local == b.m_local && a.m_mask == b.m_mask &&
|
||||
a.m_broadcast == b.m_broadcast && a.m_scope == b.m_scope && a.m_secondary == b.m_secondary);
|
||||
}
|
||||
inline bool operator != (const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
|
||||
{
|
||||
return (a.m_local != b.m_local || a.m_mask != b.m_mask ||
|
||||
a.m_broadcast != b.m_broadcast || a.m_scope != b.m_scope || a.m_secondary != b.m_secondary);
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* IPV4_ADDRESS_H */
|
||||
35
src/internet-stack/ipv4-raw-socket-factory.cc
Normal file
35
src/internet-stack/ipv4-raw-socket-factory.cc
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "ipv4-raw-socket-factory.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv4RawSocketFactory);
|
||||
|
||||
TypeId Ipv4RawSocketFactory::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv4RawSocketFactory")
|
||||
.SetParent<SocketFactory> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
46
src/internet-stack/ipv4-raw-socket-factory.h
Normal file
46
src/internet-stack/ipv4-raw-socket-factory.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef IPV4_RAW_SOCKET_FACTORY_H
|
||||
#define IPV4_RAW_SOCKET_FACTORY_H
|
||||
|
||||
#include "ns3/socket-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Socket;
|
||||
|
||||
/**
|
||||
* \ingroup socket
|
||||
*
|
||||
* \brief API to create RAW socket instances
|
||||
*
|
||||
* This abstract class defines the API for RAW socket factory.
|
||||
*
|
||||
*/
|
||||
class Ipv4RawSocketFactory : public SocketFactory
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* IPV4_RAW_SOCKET_FACTORY_H */
|
||||
141
src/internet-stack/ipv4-route.cc
Normal file
141
src/internet-stack/ipv4-route.cc
Normal file
@@ -0,0 +1,141 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ipv4-route.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Ipv4Route::Ipv4Route ()
|
||||
{}
|
||||
|
||||
void
|
||||
Ipv4Route::SetDestination (Ipv4Address dest)
|
||||
{
|
||||
m_dest = dest;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4Route::GetDestination (void) const
|
||||
{
|
||||
return m_dest;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Route::SetSource (Ipv4Address src)
|
||||
{
|
||||
m_source = src;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4Route::GetSource (void) const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Route::SetGateway (Ipv4Address gw)
|
||||
{
|
||||
m_gateway = gw;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4Route::GetGateway (void) const
|
||||
{
|
||||
return m_gateway;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Route::SetOutputDevice (Ptr<NetDevice> outputDevice)
|
||||
{
|
||||
m_outputDevice = outputDevice;
|
||||
}
|
||||
|
||||
Ptr<NetDevice>
|
||||
Ipv4Route::GetOutputDevice (void) const
|
||||
{
|
||||
return m_outputDevice;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Route const& route)
|
||||
{
|
||||
os << "source=" << route.GetSource () << " dest="<< route.GetDestination () <<" gw=" << route.GetGateway ();
|
||||
return os;
|
||||
}
|
||||
|
||||
Ipv4MulticastRoute::Ipv4MulticastRoute ()
|
||||
{
|
||||
uint32_t initial_ttl = MAX_TTL;
|
||||
// Initialize array to MAX_TTL, which means that all interfaces are "off"
|
||||
for (uint32_t i = 0; i < MAX_INTERFACES; i++)
|
||||
{
|
||||
m_ttls.push_back(initial_ttl);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4MulticastRoute::SetGroup (const Ipv4Address group)
|
||||
{
|
||||
m_group = group;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4MulticastRoute::GetGroup (void) const
|
||||
{
|
||||
return m_group;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4MulticastRoute::SetOrigin (const Ipv4Address origin)
|
||||
{
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4MulticastRoute::GetOrigin (void) const
|
||||
{
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4MulticastRoute::SetParent (uint32_t parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Ipv4MulticastRoute::GetParent (void) const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl)
|
||||
{
|
||||
m_ttls[oif] = ttl;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Ipv4MulticastRoute::GetOutputTtl (uint32_t oif) const
|
||||
{
|
||||
return m_ttls[oif];
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
162
src/internet-stack/ipv4-route.h
Normal file
162
src/internet-stack/ipv4-route.h
Normal file
@@ -0,0 +1,162 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
#ifndef IPV4_ROUTE_H
|
||||
#define IPV4_ROUTE_H
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
#include "ns3/simple-ref-count.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class NetDevice;
|
||||
|
||||
/**
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
*\brief Ipv4 route cache entry (similar to Linux struct rtable)
|
||||
*
|
||||
* This is a reference counted object. In the future, we will add other
|
||||
* entries from struct dst_entry, struct rtable, and struct dst_ops as needed.
|
||||
*/
|
||||
class Ipv4Route : public SimpleRefCount<Ipv4Route>
|
||||
{
|
||||
public:
|
||||
Ipv4Route ();
|
||||
|
||||
/**
|
||||
* \param dest Destination Ipv4Address
|
||||
*/
|
||||
void SetDestination (Ipv4Address dest);
|
||||
/**
|
||||
* \return Destination Ipv4Address of the route
|
||||
*/
|
||||
Ipv4Address GetDestination (void) const;
|
||||
|
||||
/**
|
||||
* \param src Source Ipv4Address
|
||||
*/
|
||||
void SetSource (Ipv4Address src);
|
||||
/**
|
||||
* \return Source Ipv4Address of the route
|
||||
*/
|
||||
Ipv4Address GetSource (void) const;
|
||||
|
||||
/**
|
||||
* \param gw Gateway (next hop) Ipv4Address
|
||||
*/
|
||||
void SetGateway (Ipv4Address gw);
|
||||
/**
|
||||
* \return Ipv4Address of the gateway (next hop)
|
||||
*/
|
||||
Ipv4Address GetGateway (void) const;
|
||||
|
||||
/**
|
||||
* Equivalent in Linux to dst_entry.dev
|
||||
*
|
||||
* \param outputDevice pointer to NetDevice for outgoing packets
|
||||
*/
|
||||
void SetOutputDevice (Ptr<NetDevice> outputDevice);
|
||||
/**
|
||||
* \return pointer to NetDevice for outgoing packets
|
||||
*/
|
||||
Ptr<NetDevice> GetOutputDevice (void) const;
|
||||
|
||||
#ifdef NOTYET
|
||||
// rtable.idev
|
||||
void SetInputIfIndex (uint32_t iif);
|
||||
uint32_t GetInputIfIndex (void) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
Ipv4Address m_dest;
|
||||
Ipv4Address m_source;
|
||||
Ipv4Address m_gateway;
|
||||
Ptr<NetDevice> m_outputDevice;
|
||||
#ifdef NOTYET
|
||||
uint32_t m_inputIfIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Route const& route);
|
||||
|
||||
/**
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
* \brief Ipv4 multicast route cache entry (similar to Linux struct mfc_cache)
|
||||
*/
|
||||
class Ipv4MulticastRoute : public SimpleRefCount<Ipv4MulticastRoute>
|
||||
{
|
||||
public:
|
||||
Ipv4MulticastRoute ();
|
||||
|
||||
/**
|
||||
* \param group Ipv4Address of the multicast group
|
||||
*/
|
||||
void SetGroup (const Ipv4Address group);
|
||||
/**
|
||||
* \return Ipv4Address of the multicast group
|
||||
*/
|
||||
Ipv4Address GetGroup (void) const;
|
||||
|
||||
/**
|
||||
* \param origin Ipv4Address of the origin address
|
||||
*/
|
||||
void SetOrigin (const Ipv4Address origin);
|
||||
/**
|
||||
* \return Ipv4Address of the origin address
|
||||
*/
|
||||
Ipv4Address GetOrigin (void) const;
|
||||
|
||||
/**
|
||||
* \param iif Parent (input interface) for this route
|
||||
*/
|
||||
void SetParent (uint32_t iif);
|
||||
/**
|
||||
* \return Parent (input interface) for this route
|
||||
*/
|
||||
uint32_t GetParent (void) const;
|
||||
|
||||
/**
|
||||
* \param oif Outgoing interface index
|
||||
* \param ttl time-to-live for this route
|
||||
*/
|
||||
void SetOutputTtl (uint32_t oif, uint32_t ttl);
|
||||
/**
|
||||
* \param oif outgoing interface
|
||||
* \return TTL for this route
|
||||
*/
|
||||
uint32_t GetOutputTtl (uint32_t oif) const;
|
||||
|
||||
static const uint32_t MAX_INTERFACES = 16; // Maximum number of multicast interfaces on a router
|
||||
static const uint32_t MAX_TTL = 255; // Maximum time-to-live (TTL)
|
||||
|
||||
private:
|
||||
Ipv4Address m_group; // Group
|
||||
Ipv4Address m_origin; // Source of packet
|
||||
uint32_t m_parent; // Source interface
|
||||
std::vector<uint32_t> m_ttls;
|
||||
};
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
#endif /* IPV4_ROUTE_H */
|
||||
35
src/internet-stack/ipv4-routing-protocol.cc
Normal file
35
src/internet-stack/ipv4-routing-protocol.cc
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ipv4-route.h"
|
||||
#include "ipv4-routing-protocol.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv4RoutingProtocol);
|
||||
|
||||
TypeId Ipv4RoutingProtocol::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv4RoutingProtocol")
|
||||
.SetParent<Object> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
150
src/internet-stack/ipv4-routing-protocol.h
Normal file
150
src/internet-stack/ipv4-routing-protocol.h
Normal file
@@ -0,0 +1,150 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
#ifndef IPV4_ROUTING_PROTOCOL_H
|
||||
#define IPV4_ROUTING_PROTOCOL_H
|
||||
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ipv4-header.h"
|
||||
#include "ns3/ipv4-interface-address.h"
|
||||
#include "ipv4.h"
|
||||
#include "ns3/output-stream-wrapper.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Ipv4MulticastRoute;
|
||||
class Ipv4Route;
|
||||
class NetDevice;
|
||||
|
||||
/**
|
||||
* \ingroup node
|
||||
* \defgroup ipv4Routing Ipv4RoutingProtocol
|
||||
*/
|
||||
/**
|
||||
* \ingroup ipv4Routing
|
||||
* \brief Abstract base class for IPv4 routing protocols.
|
||||
*
|
||||
* Defines two virtual functions for packet routing and forwarding. The first,
|
||||
* RouteOutput(), is used for locally originated packets, and the second,
|
||||
* RouteInput(), is used for forwarding and/or delivering received packets.
|
||||
* Also defines the signatures of four callbacks used in RouteInput().
|
||||
*
|
||||
*/
|
||||
class Ipv4RoutingProtocol : public Object
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
typedef Callback<void, Ptr<Ipv4Route>, Ptr<const Packet>, const Ipv4Header &> UnicastForwardCallback;
|
||||
typedef Callback<void, Ptr<Ipv4MulticastRoute>, Ptr<const Packet>, const Ipv4Header &> MulticastForwardCallback;
|
||||
typedef Callback<void, Ptr<const Packet>, const Ipv4Header &, uint32_t > LocalDeliverCallback;
|
||||
typedef Callback<void, Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno > ErrorCallback;
|
||||
|
||||
/**
|
||||
* \brief Query routing cache for an existing route, for an outbound packet
|
||||
*
|
||||
* This lookup is used by transport protocols. It does not cause any
|
||||
* packet to be forwarded, and is synchronous. Can be used for
|
||||
* multicast or unicast. The Linux equivalent is ip_route_output()
|
||||
*
|
||||
* \param p packet to be routed. Note that this method may modify the packet.
|
||||
* Callers may also pass in a null pointer.
|
||||
* \param header input parameter (used to form key to search for the route)
|
||||
* \param oif Output interface Netdevice. May be zero, or may be bound via
|
||||
* socket options to a particular output interface.
|
||||
* \param sockerr Output parameter; socket errno
|
||||
*
|
||||
* \returns a code that indicates what happened in the lookup
|
||||
*/
|
||||
virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) = 0;
|
||||
|
||||
/**
|
||||
* \brief Route an input packet (to be forwarded or locally delivered)
|
||||
*
|
||||
* This lookup is used in the forwarding process. The packet is
|
||||
* handed over to the Ipv4RoutingProtocol, and will get forwarded onward
|
||||
* by one of the callbacks. The Linux equivalent is ip_route_input().
|
||||
* There are four valid outcomes, and a matching callbacks to handle each.
|
||||
*
|
||||
* \param p received packet
|
||||
* \param header input parameter used to form a search key for a route
|
||||
* \param idev Pointer to ingress network device
|
||||
* \param ucb Callback for the case in which the packet is to be forwarded
|
||||
* as unicast
|
||||
* \param mcb Callback for the case in which the packet is to be forwarded
|
||||
* as multicast
|
||||
* \param lcb Callback for the case in which the packet is to be locally
|
||||
* delivered
|
||||
* \param ecb Callback to call if there is an error in forwarding
|
||||
* \returns true if the Ipv4RoutingProtocol takes responsibility for
|
||||
* forwarding or delivering the packet, false otherwise
|
||||
*/
|
||||
virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
|
||||
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
|
||||
LocalDeliverCallback lcb, ErrorCallback ecb) = 0;
|
||||
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified of the state change of
|
||||
* an interface in a node.
|
||||
*/
|
||||
virtual void NotifyInterfaceUp (uint32_t interface) = 0;
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified of the state change of
|
||||
* an interface in a node.
|
||||
*/
|
||||
virtual void NotifyInterfaceDown (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified whenever
|
||||
* a new address is added to an interface. Typically used to add a 'network route' on an
|
||||
* interface. Can be invoked on an up or down interface.
|
||||
*/
|
||||
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified whenever
|
||||
* a new address is removed from an interface. Typically used to remove the 'network route' of an
|
||||
* interface. Can be invoked on an up or down interface.
|
||||
*/
|
||||
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \param ipv4 the ipv4 object this routing protocol is being associated with
|
||||
*
|
||||
* Typically, invoked directly or indirectly from ns3::Ipv4::SetRoutingProtocol
|
||||
*/
|
||||
virtual void SetIpv4 (Ptr<Ipv4> ipv4) = 0;
|
||||
|
||||
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const = 0;
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* IPV4_ROUTING_PROTOCOL_H */
|
||||
63
src/internet-stack/ipv4.cc
Normal file
63
src/internet-stack/ipv4.cc
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/boolean.h"
|
||||
#include "ipv4.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv4);
|
||||
|
||||
TypeId
|
||||
Ipv4::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv4")
|
||||
.SetParent<Object> ()
|
||||
.AddAttribute ("IpForward", "Globally enable or disable IP forwarding for all current and future Ipv4 devices.",
|
||||
BooleanValue (true),
|
||||
MakeBooleanAccessor (&Ipv4::SetIpForward,
|
||||
&Ipv4::GetIpForward),
|
||||
MakeBooleanChecker ())
|
||||
.AddAttribute ("WeakEsModel",
|
||||
"RFC1122 term for whether host accepts datagram with a dest. address on another interface",
|
||||
BooleanValue (true),
|
||||
MakeBooleanAccessor (&Ipv4::SetWeakEsModel,
|
||||
&Ipv4::GetWeakEsModel),
|
||||
MakeBooleanChecker ())
|
||||
#if 0
|
||||
.AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&UdpSocket::SetMtuDiscover,
|
||||
&UdpSocket::GetMtuDiscover),
|
||||
MakeBooleanChecker ())
|
||||
#endif
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
Ipv4::Ipv4 ()
|
||||
{}
|
||||
|
||||
Ipv4::~Ipv4 ()
|
||||
{}
|
||||
|
||||
} // namespace ns3
|
||||
326
src/internet-stack/ipv4.h
Normal file
326
src/internet-stack/ipv4.h
Normal file
@@ -0,0 +1,326 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef IPV4_H
|
||||
#define IPV4_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ipv4-interface-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Node;
|
||||
class NetDevice;
|
||||
class Packet;
|
||||
class Ipv4RoutingProtocol;
|
||||
|
||||
/**
|
||||
* \ingroup node
|
||||
* \defgroup ipv4 Ipv4
|
||||
*/
|
||||
/**
|
||||
* \ingroup ipv4
|
||||
* \brief Access to the Ipv4 forwarding table, interfaces, and configuration
|
||||
*
|
||||
* This class defines the API to manipulate the following aspects of
|
||||
* the Ipv4 implementation:
|
||||
* -# set/get an Ipv4RoutingProtocol
|
||||
* -# register a NetDevice for use by the Ipv4 layer (basically, to
|
||||
* create Ipv4-related state such as addressing and neighbor cache that
|
||||
* is associated with a NetDevice)
|
||||
* -# manipulate the status of the NetDevice from the Ipv4 perspective,
|
||||
* such as marking it as Up or Down,
|
||||
* -# adding, deleting, and getting addresses associated to the Ipv4
|
||||
* interfaces.
|
||||
* -# exporting Ipv4 configuration attributes
|
||||
*
|
||||
* Each NetDevice has conceptually a single Ipv4 interface associated
|
||||
* with it (the corresponding structure in the Linux Ipv4 implementation
|
||||
* is struct in_device). Each interface may have one or more Ipv4
|
||||
* addresses associated with it. Each Ipv4 address may have different
|
||||
* subnet mask, scope, etc., so all of this per-address information
|
||||
* is stored in an Ipv4InterfaceAddress class (the corresponding
|
||||
* structure in Linux is struct in_ifaddr)
|
||||
*
|
||||
* Ipv4 attributes such as whether IP forwarding is enabled and disabled
|
||||
* are also stored in this class
|
||||
*
|
||||
* TO DO: Add API to allow access to the Ipv4 neighbor table
|
||||
*
|
||||
* \see Ipv4RoutingProtocol
|
||||
* \see Ipv4InterfaceAddress
|
||||
*/
|
||||
class Ipv4 : public Object
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
Ipv4 ();
|
||||
virtual ~Ipv4 ();
|
||||
|
||||
/**
|
||||
* \brief Register a new routing protocol to be used by this Ipv4 stack
|
||||
*
|
||||
* This call will replace any routing protocol that has been previously
|
||||
* registered. If you want to add multiple routing protocols, you must
|
||||
* add them to a Ipv4ListRoutingProtocol directly.
|
||||
*
|
||||
* \param routingProtocol smart pointer to Ipv4RoutingProtocol object
|
||||
*/
|
||||
virtual void SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get the routing protocol to be used by this Ipv4 stack
|
||||
*
|
||||
* \returns smart pointer to Ipv4RoutingProtocol object, or null pointer if none
|
||||
*/
|
||||
virtual Ptr<Ipv4RoutingProtocol> GetRoutingProtocol (void) const = 0;
|
||||
|
||||
/**
|
||||
* \param device device to add to the list of Ipv4 interfaces
|
||||
* which can be used as output interfaces during packet forwarding.
|
||||
* \returns the index of the Ipv4 interface added.
|
||||
*
|
||||
* Once a device has been added, it can never be removed: if you want
|
||||
* to disable it, you can invoke Ipv4::SetDown which will
|
||||
* make sure that it is never used during packet forwarding.
|
||||
*/
|
||||
virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0;
|
||||
|
||||
/**
|
||||
* \returns the number of interfaces added by the user.
|
||||
*/
|
||||
virtual uint32_t GetNInterfaces (void) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Return the interface number of the interface that has been
|
||||
* assigned the specified IP address.
|
||||
*
|
||||
* \param address The IP address being searched for
|
||||
* \returns The interface number of the Ipv4 interface with the given
|
||||
* address or -1 if not found.
|
||||
*
|
||||
* Each IP interface has one or more IP addresses associated with it.
|
||||
* This method searches the list of interfaces for one that holds a
|
||||
* particular address. This call takes an IP address as a parameter and
|
||||
* returns the interface number of the first interface that has been assigned
|
||||
* that address, or -1 if not found. There must be an exact match; this
|
||||
* method will not match broadcast or multicast addresses.
|
||||
*/
|
||||
virtual int32_t GetInterfaceForAddress (Ipv4Address address) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Determine whether address and interface corresponding to
|
||||
* received packet can be accepted for local delivery
|
||||
*
|
||||
* \param address The IP address being considered
|
||||
* \param iif The incoming Ipv4 interface index
|
||||
*
|
||||
* This method can be used to determine whether a received packet has
|
||||
* an acceptable address for local delivery on the host. The address
|
||||
* may be a unicast, multicast, or broadcast address. This method will
|
||||
* return true if address is an exact match of a unicast address on
|
||||
* one of the host's interfaces (see below), if address corresponds to
|
||||
* a multicast group that the host has joined (and the incoming device
|
||||
* is acceptable), or if address corresponds to a broadcast address.
|
||||
*
|
||||
* If the Ipv4 attribute WeakEsModel is true, the unicast address may
|
||||
* match any of the Ipv4 addresses on any interface. If the attribute is
|
||||
* false, the address must match one assigned to the incoming device.
|
||||
*/
|
||||
virtual bool IsDestinationAddress (Ipv4Address address, uint32_t iif) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Return the interface number of first interface found that
|
||||
* has an Ipv4 address within the prefix specified by the input
|
||||
* address and mask parameters
|
||||
*
|
||||
* \param address The IP address assigned to the interface of interest.
|
||||
* \param mask The IP prefix to use in the mask
|
||||
* \returns The interface number of the Ipv4 interface with the given
|
||||
* address or -1 if not found.
|
||||
*
|
||||
* Each IP interface has one or more IP addresses associated with it.
|
||||
* This method searches the list of interfaces for the first one found
|
||||
* that holds an address that is included within the prefix
|
||||
* formed by the input address and mask parameters. The value -1 is
|
||||
* returned if no match is found.
|
||||
*/
|
||||
virtual int32_t GetInterfaceForPrefix (Ipv4Address address,
|
||||
Ipv4Mask mask) const = 0;
|
||||
|
||||
/**
|
||||
* \param interface The interface number of an Ipv4 interface.
|
||||
* \returns The NetDevice associated with the Ipv4 interface number.
|
||||
*/
|
||||
virtual Ptr<NetDevice> GetNetDevice (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param device The NetDevice for an Ipv4Interface
|
||||
* \returns The interface number of an Ipv4 interface or -1 if not found.
|
||||
*/
|
||||
virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of an Ipv4 interface
|
||||
* \param address Ipv4InterfaceAddress address to associate with the underlying Ipv4 interface
|
||||
* \returns true if the operation succeeded
|
||||
*/
|
||||
virtual bool AddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of an Ipv4 interface
|
||||
* \returns the number of Ipv4InterfaceAddress entries for the interface.
|
||||
*/
|
||||
virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* Because addresses can be removed, the addressIndex is not guaranteed
|
||||
* to be static across calls to this method.
|
||||
*
|
||||
* \param interface Interface number of an Ipv4 interface
|
||||
* \param addressIndex index of Ipv4InterfaceAddress
|
||||
* \returns the Ipv4InterfaceAddress associated to the interface and addressIndex
|
||||
*/
|
||||
virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Remove the address at addressIndex on named interface. The addressIndex
|
||||
* for all higher indices will decrement by one after this method is called;
|
||||
* so, for example, to remove 5 addresses from an interface i, one could
|
||||
* call RemoveAddress (i, 0); 5 times.
|
||||
*
|
||||
* \param interface Interface number of an Ipv4 interface
|
||||
* \param addressIndex index of Ipv4InterfaceAddress to remove
|
||||
* \returns true if the operation succeeded
|
||||
*/
|
||||
virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex) = 0;
|
||||
|
||||
/**
|
||||
* \brief Return the first primary source address with scope less than
|
||||
* or equal to the requested scope, to use in sending a packet to
|
||||
* destination dst out of the specified device.
|
||||
*
|
||||
* This method mirrors the behavior of Linux inet_select_addr() and is
|
||||
* provided because interfaces may have multiple IP addresses configured
|
||||
* on them with different scopes, and with a primary and secondary status.
|
||||
* Secondary addresses are never returned.
|
||||
* \see Ipv4InterfaceAddress
|
||||
*
|
||||
* If a non-zero device pointer is provided, the method first tries to
|
||||
* return a primary address that is configured on that device, and whose
|
||||
* subnet matches that of dst and whose scope is less than or equal to
|
||||
* the requested scope. If a primary address does not match the
|
||||
* subnet of dst but otherwise matches the scope, it is returned.
|
||||
* If no such address on the device is found, the other devices are
|
||||
* searched in order of their interface index, but not considering dst
|
||||
* as a factor in the search. Because a loopback interface is typically
|
||||
* the first one configured on a node, it will be the first alternate
|
||||
* device to be tried. Addresses scoped at LINK scope are not returned
|
||||
* in this phase.
|
||||
*
|
||||
* If no device pointer is provided, the same logic as above applies, only
|
||||
* that there is no preferred device that is consulted first. This means
|
||||
* that if the device pointer is null, input parameter dst will be ignored.
|
||||
*
|
||||
* If there are no possible addresses to return, a warning log message
|
||||
* is issued and the all-zeroes address is returned.
|
||||
*
|
||||
* \param device output NetDevice (optionally provided, only to constrain the search)
|
||||
* \param dst Destination address to match, if device is provided
|
||||
* \param scope Scope of returned address must be less than or equal to this
|
||||
* \returns the first primary Ipv4Address that meets the search criteria
|
||||
*/
|
||||
virtual Ipv4Address SelectSourceAddress (Ptr<const NetDevice> device,
|
||||
Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope) = 0;
|
||||
|
||||
/**
|
||||
* \param interface The interface number of an Ipv4 interface
|
||||
* \param metric routing metric (cost) associated to the underlying
|
||||
* Ipv4 interface
|
||||
*/
|
||||
virtual void SetMetric (uint32_t interface, uint16_t metric) = 0;
|
||||
|
||||
/**
|
||||
* \param interface The interface number of an Ipv4 interface
|
||||
* \returns routing metric (cost) associated to the underlying
|
||||
* Ipv4 interface
|
||||
*/
|
||||
virtual uint16_t GetMetric (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of Ipv4 interface
|
||||
* \returns the Maximum Transmission Unit (in bytes) associated
|
||||
* to the underlying Ipv4 interface
|
||||
*/
|
||||
virtual uint16_t GetMtu (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of Ipv4 interface
|
||||
* \returns true if the underlying interface is in the "up" state,
|
||||
* false otherwise.
|
||||
*/
|
||||
virtual bool IsUp (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of Ipv4 interface
|
||||
*
|
||||
* Set the interface into the "up" state. In this state, it is
|
||||
* considered valid during Ipv4 forwarding.
|
||||
*/
|
||||
virtual void SetUp (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of Ipv4 interface
|
||||
*
|
||||
* Set the interface into the "down" state. In this state, it is
|
||||
* ignored during Ipv4 forwarding.
|
||||
*/
|
||||
virtual void SetDown (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of Ipv4 interface
|
||||
* \returns true if IP forwarding enabled for input datagrams on this device
|
||||
*/
|
||||
virtual bool IsForwarding (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of Ipv4 interface
|
||||
* \param val Value to set the forwarding flag
|
||||
*
|
||||
* If set to true, IP forwarding is enabled for input datagrams on this device
|
||||
*/
|
||||
virtual void SetForwarding (uint32_t interface, bool val) = 0;
|
||||
|
||||
static const uint32_t IF_ANY = 0xffffffff;
|
||||
|
||||
private:
|
||||
// Indirect the Ipv4 attributes through private pure virtual methods
|
||||
virtual void SetIpForward (bool forward) = 0;
|
||||
virtual bool GetIpForward (void) const = 0;
|
||||
virtual void SetWeakEsModel (bool model) = 0;
|
||||
virtual bool GetWeakEsModel (void) const = 0;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* IPV4_H */
|
||||
187
src/internet-stack/ipv6-header.cc
Normal file
187
src/internet-stack/ipv6-header.cc
Normal file
@@ -0,0 +1,187 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007-2008 Louis Pasteur University
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/header.h"
|
||||
|
||||
#include "ns3/address-utils.h"
|
||||
#include "ipv6-header.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Ipv6Header");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv6Header);
|
||||
|
||||
Ipv6Header::Ipv6Header ()
|
||||
: m_version (6),
|
||||
m_trafficClass (0),
|
||||
m_flowLabel (1),
|
||||
m_payloadLength (0),
|
||||
m_nextHeader (0),
|
||||
m_hopLimit (0)
|
||||
{
|
||||
SetSourceAddress (Ipv6Address ("::"));
|
||||
SetDestinationAddress (Ipv6Address ("::"));
|
||||
}
|
||||
|
||||
void Ipv6Header::SetTrafficClass (uint8_t traffic)
|
||||
{
|
||||
m_trafficClass = traffic;
|
||||
}
|
||||
|
||||
uint8_t Ipv6Header::GetTrafficClass () const
|
||||
{
|
||||
return m_trafficClass;
|
||||
}
|
||||
|
||||
void Ipv6Header::SetFlowLabel (uint32_t flow)
|
||||
{
|
||||
m_flowLabel = flow;
|
||||
}
|
||||
|
||||
uint32_t Ipv6Header::GetFlowLabel () const
|
||||
{
|
||||
return m_flowLabel;
|
||||
}
|
||||
|
||||
void Ipv6Header::SetPayloadLength (uint16_t len)
|
||||
{
|
||||
m_payloadLength = len;
|
||||
}
|
||||
|
||||
uint16_t Ipv6Header::GetPayloadLength () const
|
||||
{
|
||||
return m_payloadLength;
|
||||
}
|
||||
|
||||
void Ipv6Header::SetNextHeader (uint8_t next)
|
||||
{
|
||||
m_nextHeader = next;
|
||||
}
|
||||
|
||||
uint8_t Ipv6Header::GetNextHeader () const
|
||||
{
|
||||
return m_nextHeader;
|
||||
}
|
||||
|
||||
void Ipv6Header::SetHopLimit (uint8_t limit)
|
||||
{
|
||||
m_hopLimit = limit;
|
||||
}
|
||||
|
||||
uint8_t Ipv6Header::GetHopLimit () const
|
||||
{
|
||||
return m_hopLimit;
|
||||
}
|
||||
|
||||
void Ipv6Header::SetSourceAddress (Ipv6Address src)
|
||||
{
|
||||
m_sourceAddress = src;
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6Header::GetSourceAddress () const
|
||||
{
|
||||
return m_sourceAddress;
|
||||
}
|
||||
|
||||
void Ipv6Header::SetDestinationAddress (Ipv6Address dst)
|
||||
{
|
||||
m_destinationAddress = dst;
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6Header::GetDestinationAddress () const
|
||||
{
|
||||
return m_destinationAddress;
|
||||
}
|
||||
|
||||
TypeId Ipv6Header::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv6Header")
|
||||
.SetParent<Header> ()
|
||||
.AddConstructor<Ipv6Header> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
TypeId Ipv6Header::GetInstanceTypeId (void) const
|
||||
{
|
||||
return GetTypeId ();
|
||||
}
|
||||
|
||||
void Ipv6Header::Print (std::ostream& os) const
|
||||
{
|
||||
os << "("
|
||||
"Version " << m_version << " "
|
||||
<< "Traffic class 0x" << std::hex << m_trafficClass << std::dec << " "
|
||||
<< "Flow Label 0x" << std::hex << m_flowLabel << std::dec << " "
|
||||
<< "Payload Length " << m_payloadLength << " "
|
||||
<< "Next Header " << std::dec << (uint32_t) m_nextHeader << " "
|
||||
<< "Hop Limit " << std::dec << (uint32_t)m_hopLimit << " )"
|
||||
<< m_sourceAddress << " > " << m_destinationAddress
|
||||
;
|
||||
}
|
||||
|
||||
uint32_t Ipv6Header::GetSerializedSize () const
|
||||
{
|
||||
return 10 * 4;
|
||||
}
|
||||
|
||||
void Ipv6Header::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
uint32_t vTcFl = 0; /* version, Traffic Class and Flow Label fields */
|
||||
|
||||
vTcFl= (6 << 28) | (m_trafficClass << 20) | (m_flowLabel);
|
||||
|
||||
i.WriteHtonU32(vTcFl);
|
||||
i.WriteHtonU16(m_payloadLength);
|
||||
i.WriteU8(m_nextHeader);
|
||||
i.WriteU8(m_hopLimit);
|
||||
|
||||
WriteTo (i, m_sourceAddress);
|
||||
WriteTo (i, m_destinationAddress);
|
||||
}
|
||||
|
||||
uint32_t Ipv6Header::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
Buffer::Iterator i = start;
|
||||
uint32_t vTcFl = 0;
|
||||
|
||||
vTcFl = i.ReadNtohU32();
|
||||
m_version = vTcFl >> 28;
|
||||
|
||||
NS_ASSERT ((m_version) == 6);
|
||||
|
||||
m_trafficClass = (uint8_t)((vTcFl >> 20) & 0x000000ff);
|
||||
m_flowLabel = vTcFl & 0xfff00000;
|
||||
m_payloadLength = i.ReadNtohU16();
|
||||
m_nextHeader = i.ReadU8();
|
||||
m_hopLimit = i.ReadU8();
|
||||
|
||||
ReadFrom (i, m_sourceAddress);
|
||||
ReadFrom (i, m_destinationAddress);
|
||||
|
||||
return GetSerializedSize ();
|
||||
}
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
231
src/internet-stack/ipv6-header.h
Normal file
231
src/internet-stack/ipv6-header.h
Normal file
@@ -0,0 +1,231 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007-2008 Louis Pasteur University
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#ifndef IPV6_HEADER_H
|
||||
#define IPV6_HEADER_H
|
||||
|
||||
#include "ns3/header.h"
|
||||
#include "ns3/ipv6-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \class Ipv6Header
|
||||
* \brief Packet header for IPv6
|
||||
*/
|
||||
class Ipv6Header : public Header
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \enum NextHeader_e
|
||||
* \brief IPv6 next-header value
|
||||
*/
|
||||
enum NextHeader_e
|
||||
{
|
||||
IPV6_EXT_HOP_BY_HOP = 0,
|
||||
IPV6_IPV4 = 4,
|
||||
IPV6_TCP = 6,
|
||||
IPV6_UDP = 17,
|
||||
IPV6_IPV6 = 41,
|
||||
IPV6_EXT_ROUTING = 43,
|
||||
IPV6_EXT_FRAGMENTATION = 44,
|
||||
IPV6_EXT_CONFIDENTIALITY = 50,
|
||||
IPV6_EXT_AUTHENTIFICATION = 51,
|
||||
IPV6_ICMPV6 = 58,
|
||||
IPV6_EXT_END = 59,
|
||||
IPV6_EXT_DESTINATION = 60,
|
||||
IPV6_SCTP = 135,
|
||||
IPV6_EXT_MOBILITY = 135,
|
||||
IPV6_UDP_LITE = 136,
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Get the type identifier.
|
||||
* \return type identifier
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
/**
|
||||
* \brief Return the instance type identifier.
|
||||
* \return instance type ID
|
||||
*/
|
||||
virtual TypeId GetInstanceTypeId (void) const;
|
||||
|
||||
/**
|
||||
* \brief Constructor.
|
||||
*/
|
||||
Ipv6Header (void);
|
||||
|
||||
/**
|
||||
* \brief Set the "Traffic class" field.
|
||||
* \param traffic the 8-bit value
|
||||
*/
|
||||
void SetTrafficClass (uint8_t traffic);
|
||||
|
||||
/**
|
||||
* \brief Get the "Traffic class" field.
|
||||
* \return the traffic value
|
||||
*/
|
||||
uint8_t GetTrafficClass (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set the "Flow label" field.
|
||||
* \param flow the 20-bit value
|
||||
*/
|
||||
void SetFlowLabel (uint32_t flow);
|
||||
|
||||
/**
|
||||
* \brief Get the "Flow label" field.
|
||||
* \return the flow label value
|
||||
*/
|
||||
uint32_t GetFlowLabel (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set the "Payload length" field.
|
||||
* \param len the length of the payload in bytes
|
||||
*/
|
||||
void SetPayloadLength (uint16_t len);
|
||||
|
||||
/**
|
||||
* \brief Get the "Payload length" field.
|
||||
* \return the payload length
|
||||
*/
|
||||
uint16_t GetPayloadLength (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set the "Next header" field.
|
||||
* \param next the next header number
|
||||
*/
|
||||
void SetNextHeader (uint8_t next);
|
||||
|
||||
/**
|
||||
* \brief Get the next header.
|
||||
* \return the next header number
|
||||
*/
|
||||
uint8_t GetNextHeader (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set the "Hop limit" field (TTL).
|
||||
* \param limit the 8-bit value
|
||||
*/
|
||||
void SetHopLimit (uint8_t limit);
|
||||
|
||||
/**
|
||||
* \brief Get the "Hop limit" field (TTL).
|
||||
* \return the hop limit value
|
||||
*/
|
||||
uint8_t GetHopLimit (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set the "Source address" field.
|
||||
* \param src the source address
|
||||
*/
|
||||
void SetSourceAddress (Ipv6Address src);
|
||||
|
||||
/**
|
||||
* \brief Get the "Source address" field.
|
||||
* \return the source address
|
||||
*/
|
||||
Ipv6Address GetSourceAddress (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set the "Destination address" field.
|
||||
* \param dst the destination address
|
||||
*/
|
||||
void SetDestinationAddress (Ipv6Address dst);
|
||||
|
||||
/**
|
||||
* \brief Get the "Destination address" field.
|
||||
* \return the destination address
|
||||
*/
|
||||
Ipv6Address GetDestinationAddress (void) const;
|
||||
|
||||
/**
|
||||
* \brief Print some informations about the packet.
|
||||
* \param os output stream
|
||||
* \return info about this packet
|
||||
*/
|
||||
virtual void Print (std::ostream& os) const;
|
||||
|
||||
/**
|
||||
* \brief Get the serialized size of the packet.
|
||||
* \return size
|
||||
*/
|
||||
virtual uint32_t GetSerializedSize (void) const;
|
||||
|
||||
/**
|
||||
* \brief Serialize the packet.
|
||||
* \param start Buffer iterator
|
||||
*/
|
||||
virtual void Serialize (Buffer::Iterator start) const;
|
||||
|
||||
/**
|
||||
* \brief Deserialize the packet.
|
||||
* \param start Buffer iterator
|
||||
* \return size of the packet
|
||||
*/
|
||||
virtual uint32_t Deserialize (Buffer::Iterator start);
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief The version (always equal to 6).
|
||||
*/
|
||||
uint32_t m_version : 4;
|
||||
/**
|
||||
* \brief The traffic class.
|
||||
*/
|
||||
uint32_t m_trafficClass : 8;
|
||||
|
||||
/**
|
||||
* \brief The flow label.
|
||||
* \note This is 20-bit value.
|
||||
*/
|
||||
uint32_t m_flowLabel : 20;
|
||||
|
||||
/**
|
||||
* \brief The payload length.
|
||||
*/
|
||||
uint16_t m_payloadLength;
|
||||
|
||||
/**
|
||||
* \brief The Next header number.
|
||||
*/
|
||||
uint8_t m_nextHeader;
|
||||
|
||||
/**
|
||||
* \brief The Hop limit value.
|
||||
*/
|
||||
uint8_t m_hopLimit;
|
||||
|
||||
/**
|
||||
* \brief The source address.
|
||||
*/
|
||||
Ipv6Address m_sourceAddress;
|
||||
|
||||
/**
|
||||
* \brief The destination address.
|
||||
*/
|
||||
Ipv6Address m_destinationAddress;
|
||||
};
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
#endif /* IPV6_HEADER_H */
|
||||
|
||||
171
src/internet-stack/ipv6-interface-address.cc
Normal file
171
src/internet-stack/ipv6-interface-address.cc
Normal file
@@ -0,0 +1,171 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Strasbourg University
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
#include "ipv6-interface-address.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Ipv6InterfaceAddress");
|
||||
|
||||
Ipv6InterfaceAddress::Ipv6InterfaceAddress ()
|
||||
: m_address (Ipv6Address ()),
|
||||
m_prefix (Ipv6Prefix ()),
|
||||
m_state (TENTATIVE_OPTIMISTIC),
|
||||
m_scope (HOST),
|
||||
m_nsDadUid (0)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
Ipv6InterfaceAddress::Ipv6InterfaceAddress (Ipv6Address address)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << address);
|
||||
m_prefix = Ipv6Prefix (64);
|
||||
SetAddress (address);
|
||||
SetState (TENTATIVE_OPTIMISTIC);
|
||||
m_nsDadUid = 0;
|
||||
}
|
||||
|
||||
Ipv6InterfaceAddress::Ipv6InterfaceAddress (Ipv6Address address, Ipv6Prefix prefix)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << address << prefix);
|
||||
m_prefix = prefix;
|
||||
SetAddress (address);
|
||||
SetState (TENTATIVE_OPTIMISTIC);
|
||||
m_nsDadUid = 0;
|
||||
}
|
||||
|
||||
Ipv6InterfaceAddress::Ipv6InterfaceAddress (const Ipv6InterfaceAddress& o)
|
||||
: m_address (o.m_address),
|
||||
m_prefix (o.m_prefix),
|
||||
m_state (o.m_state),
|
||||
m_scope (o.m_scope),
|
||||
m_nsDadUid (o.m_nsDadUid)
|
||||
{}
|
||||
|
||||
Ipv6InterfaceAddress::~Ipv6InterfaceAddress ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6InterfaceAddress::GetAddress () const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_address;
|
||||
}
|
||||
|
||||
void Ipv6InterfaceAddress::SetAddress (Ipv6Address address)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << address);
|
||||
m_address = address;
|
||||
|
||||
if (address.IsLocalhost ())
|
||||
{
|
||||
m_scope = HOST;
|
||||
/* localhost address is always /128 prefix */
|
||||
m_prefix = Ipv6Prefix (128);
|
||||
}
|
||||
if (address.IsLinkLocal ())
|
||||
{
|
||||
m_scope = LINKLOCAL;
|
||||
/* link-local address is always /64 prefix */
|
||||
m_prefix = Ipv6Prefix (64);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scope = GLOBAL;
|
||||
}
|
||||
}
|
||||
|
||||
Ipv6Prefix Ipv6InterfaceAddress::GetPrefix () const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_prefix;
|
||||
}
|
||||
|
||||
void Ipv6InterfaceAddress::SetState (Ipv6InterfaceAddress::State_e state)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << state);
|
||||
m_state = state;
|
||||
}
|
||||
|
||||
Ipv6InterfaceAddress::State_e Ipv6InterfaceAddress::GetState () const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void Ipv6InterfaceAddress::SetScope (Ipv6InterfaceAddress::Scope_e scope)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << scope);
|
||||
m_scope = scope;
|
||||
}
|
||||
|
||||
Ipv6InterfaceAddress::Scope_e Ipv6InterfaceAddress::GetScope () const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_scope;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Ipv6InterfaceAddress &addr)
|
||||
{
|
||||
os << "address=" << addr.GetAddress () << "; prefix=" <<
|
||||
addr.GetPrefix () << "; scope=" << addr.GetScope ();
|
||||
return os;
|
||||
}
|
||||
|
||||
uint32_t Ipv6InterfaceAddress::GetNsDadUid () const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_nsDadUid;
|
||||
}
|
||||
|
||||
void Ipv6InterfaceAddress::SetNsDadUid (uint32_t nsDadUid)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << nsDadUid);
|
||||
m_nsDadUid = nsDadUid;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void Ipv6InterfaceAddress::StartDadTimer (Ptr<Ipv6Interface> interface)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << interface);
|
||||
m_dadTimer.SetFunction (&Icmpv6L4Protocol::FunctionDadTimeout);
|
||||
m_dadTimer.SetArguments (interface, m_address);
|
||||
m_dadTimer.Schedule (Seconds (1));
|
||||
m_dadId = Simulator::Schedule (Seconds (1.), &Icmpv6L4Protocol::FunctionDadTimeout, interface, m_address);
|
||||
}
|
||||
|
||||
void Ipv6InterfaceAddress::StopDadTimer ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_dadTimer.Cancel ();
|
||||
Simulator::Cancel (m_dadId);
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
209
src/internet-stack/ipv6-interface-address.h
Normal file
209
src/internet-stack/ipv6-interface-address.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Strasbourg University
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#ifndef IPV6_INTERFACE_ADDRESS_H
|
||||
#define IPV6_INTERFACE_ADDRESS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ns3/ipv6-address.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
/**
|
||||
* \ingroup address
|
||||
* \class Ipv6InterfaceAddress
|
||||
* \brief IPv6 address associated with an interface.
|
||||
*/
|
||||
class Ipv6InterfaceAddress
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \enum State_e
|
||||
* \brief State of an address associated with an interface.
|
||||
*/
|
||||
enum State_e
|
||||
{
|
||||
TENTATIVE, /**< Address is tentative, no packet can be sent unless DAD finished */
|
||||
DEPRECATED, /**< Address is deprecated and should not be used */
|
||||
PREFERRED, /**< Preferred address */
|
||||
PERMANENT, /**< Permanent address */
|
||||
HOMEADDRESS, /**< Address is a HomeAddress */
|
||||
TENTATIVE_OPTIMISTIC, /**< Address is tentative but we are optimistic so we can send packet even if DAD is not yet finished */
|
||||
INVALID, /**< Invalid state (after a DAD failed) */
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum Scope_e
|
||||
* \brief Scope of address.
|
||||
*/
|
||||
enum Scope_e
|
||||
{
|
||||
HOST, /**< Localhost (::1/128) */
|
||||
LINKLOCAL, /**< Link-local address (fe80::/64) */
|
||||
GLOBAL, /**< Global address (2000::/3) */
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Default constructor.
|
||||
*/
|
||||
Ipv6InterfaceAddress ();
|
||||
|
||||
/**
|
||||
* \brief Constructor. Prefix is 64 by default.
|
||||
* \param address the IPv6 address to set
|
||||
*/
|
||||
Ipv6InterfaceAddress (Ipv6Address address);
|
||||
|
||||
/**
|
||||
* \brief Constructor.
|
||||
* \param address IPv6 address to set
|
||||
* \param prefix IPv6 prefix
|
||||
*/
|
||||
Ipv6InterfaceAddress (Ipv6Address address, Ipv6Prefix prefix);
|
||||
|
||||
/**
|
||||
* \brief Copy constructor.
|
||||
* \param o object to copy
|
||||
*/
|
||||
Ipv6InterfaceAddress (const Ipv6InterfaceAddress& o);
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
~Ipv6InterfaceAddress ();
|
||||
|
||||
/**
|
||||
* \brief Set IPv6 address (and scope).
|
||||
* \param address IPv6 address to set
|
||||
*/
|
||||
void SetAddress (Ipv6Address address);
|
||||
|
||||
/**
|
||||
* \brief Get the IPv6 address.
|
||||
* \return IPv6 address
|
||||
*/
|
||||
Ipv6Address GetAddress () const;
|
||||
|
||||
/**
|
||||
* \brief Get the IPv6 prefix.
|
||||
* \return IPv6 prefix
|
||||
*/
|
||||
Ipv6Prefix GetPrefix () const;
|
||||
|
||||
/**
|
||||
* \brief Set the state.
|
||||
* \param state the state
|
||||
*/
|
||||
void SetState (Ipv6InterfaceAddress::State_e state);
|
||||
|
||||
/**
|
||||
* \brief Get the address state.
|
||||
* \return address state
|
||||
*/
|
||||
Ipv6InterfaceAddress::State_e GetState () const;
|
||||
|
||||
/**
|
||||
* \brief Set the scope.
|
||||
* \param scope the scope of address
|
||||
*/
|
||||
void SetScope (Ipv6InterfaceAddress::Scope_e scope);
|
||||
|
||||
/**
|
||||
* \brief Get address scope.
|
||||
* \return scope
|
||||
*/
|
||||
Ipv6InterfaceAddress::Scope_e GetScope () const;
|
||||
|
||||
/**
|
||||
* \brief Set the latest DAD probe packet UID.
|
||||
* \param uid packet uid
|
||||
*/
|
||||
void SetNsDadUid (uint32_t uid);
|
||||
|
||||
/**
|
||||
* \brief Get the latest DAD probe packet UID.
|
||||
* \return uid
|
||||
*/
|
||||
uint32_t GetNsDadUid () const;
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* \brief Start the DAD timer.
|
||||
* \param interface interface
|
||||
*/
|
||||
void StartDadTimer (Ptr<Ipv6Interface> interface);
|
||||
|
||||
/**
|
||||
* \brief Stop the DAD timer.
|
||||
*/
|
||||
void StopDadTimer ();
|
||||
#endif
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief The IPv6 address.
|
||||
*/
|
||||
Ipv6Address m_address;
|
||||
|
||||
/**
|
||||
* \brief The IPv6 prefix.
|
||||
*/
|
||||
Ipv6Prefix m_prefix;
|
||||
|
||||
/**
|
||||
* \brief State of the address.
|
||||
*/
|
||||
State_e m_state;
|
||||
|
||||
/**
|
||||
* \brief Scope of the address.
|
||||
*/
|
||||
Scope_e m_scope;
|
||||
|
||||
friend bool operator == (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b);
|
||||
friend bool operator != (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b);
|
||||
|
||||
/**
|
||||
* \brief Last DAD probe packet UID.
|
||||
*/
|
||||
uint32_t m_nsDadUid;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Ipv6InterfaceAddress &addr);
|
||||
|
||||
/* follow Ipv4InterfaceAddress way, maybe not inline them */
|
||||
inline bool operator == (const Ipv6InterfaceAddress& a, const Ipv6InterfaceAddress& b)
|
||||
{
|
||||
return (a.m_address == b.m_address && a.m_prefix == b.m_prefix &&
|
||||
a.m_state == b.m_state && a.m_scope == b.m_scope);
|
||||
}
|
||||
|
||||
inline bool operator != (const Ipv6InterfaceAddress& a, const Ipv6InterfaceAddress& b)
|
||||
{
|
||||
return (a.m_address != b.m_address || a.m_prefix != b.m_prefix ||
|
||||
a.m_state != b.m_state || a.m_scope != b.m_scope);
|
||||
}
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
#endif /* IPV6_INTERFACE_ADDRESS_H */
|
||||
|
||||
38
src/internet-stack/ipv6-raw-socket-factory.cc
Normal file
38
src/internet-stack/ipv6-raw-socket-factory.cc
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
#include "ipv6-raw-socket-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv6RawSocketFactory);
|
||||
|
||||
TypeId Ipv6RawSocketFactory::GetTypeId ()
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv6RawSocketFactory")
|
||||
.SetParent<SocketFactory> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
52
src/internet-stack/ipv6-raw-socket-factory.h
Normal file
52
src/internet-stack/ipv6-raw-socket-factory.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef IPV6_RAW_SOCKET_FACTORY_H
|
||||
#define IPV6_RAW_SOCKET_FACTORY_H
|
||||
|
||||
#include "ns3/socket-factory.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
class Socket;
|
||||
|
||||
/**
|
||||
* \ingroup socket
|
||||
*
|
||||
* \brief API to create IPv6 RAW socket instances
|
||||
*
|
||||
* This abstract class defines the API for IPv6 RAW socket factory.
|
||||
*
|
||||
*/
|
||||
class Ipv6RawSocketFactory : public SocketFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Get the type ID of this class.
|
||||
* \return type ID
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* IPV6_RAW_SOCKET_FACTORY_H */
|
||||
|
||||
145
src/internet-stack/ipv6-route.cc
Normal file
145
src/internet-stack/ipv6-route.cc
Normal file
@@ -0,0 +1,145 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Strasbourg University
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ns3/net-device.h"
|
||||
#include "ipv6-route.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
Ipv6Route::Ipv6Route ()
|
||||
{
|
||||
}
|
||||
|
||||
Ipv6Route::~Ipv6Route ()
|
||||
{
|
||||
}
|
||||
|
||||
void Ipv6Route::SetDestination (Ipv6Address dest)
|
||||
{
|
||||
m_dest = dest;
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6Route::GetDestination () const
|
||||
{
|
||||
return m_dest;
|
||||
}
|
||||
|
||||
void Ipv6Route::SetSource (Ipv6Address src)
|
||||
{
|
||||
m_source = src;
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6Route::GetSource () const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void Ipv6Route::SetGateway (Ipv6Address gw)
|
||||
{
|
||||
m_gateway = gw;
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6Route::GetGateway () const
|
||||
{
|
||||
return m_gateway;
|
||||
}
|
||||
|
||||
void Ipv6Route::SetOutputDevice (Ptr<NetDevice> outputDevice)
|
||||
{
|
||||
m_outputDevice = outputDevice;
|
||||
}
|
||||
|
||||
Ptr<NetDevice> Ipv6Route::GetOutputDevice () const
|
||||
{
|
||||
return m_outputDevice;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv6Route const& route)
|
||||
{
|
||||
os << "source=" << route.GetSource () << " dest="<< route.GetDestination () <<" gw=" << route.GetGateway ();
|
||||
return os;
|
||||
}
|
||||
|
||||
Ipv6MulticastRoute::Ipv6MulticastRoute ()
|
||||
{
|
||||
uint32_t initial_ttl = MAX_TTL;
|
||||
|
||||
/* Initialize array to MAX_TTL, which means that all interfaces are "off" */
|
||||
for (uint32_t i = 0; i < MAX_INTERFACES; i++)
|
||||
{
|
||||
m_ttls.push_back (initial_ttl);
|
||||
}
|
||||
}
|
||||
|
||||
Ipv6MulticastRoute::~Ipv6MulticastRoute ()
|
||||
{
|
||||
}
|
||||
|
||||
void Ipv6MulticastRoute::SetGroup (const Ipv6Address group)
|
||||
{
|
||||
m_group = group;
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6MulticastRoute::GetGroup () const
|
||||
{
|
||||
return m_group;
|
||||
}
|
||||
|
||||
void Ipv6MulticastRoute::SetOrigin (const Ipv6Address origin)
|
||||
{
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
Ipv6Address Ipv6MulticastRoute::GetOrigin () const
|
||||
{
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
void Ipv6MulticastRoute::SetParent (uint32_t parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
uint32_t Ipv6MulticastRoute::GetParent () const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
void Ipv6MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl)
|
||||
{
|
||||
m_ttls[oif] = ttl;
|
||||
}
|
||||
|
||||
uint32_t Ipv6MulticastRoute::GetOutputTtl (uint32_t oif) const
|
||||
{
|
||||
return m_ttls[oif];
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route)
|
||||
{
|
||||
os << "origin=" << route.GetOrigin () << " group="<< route.GetGroup () <<" parent=" << route.GetParent ();
|
||||
return os;
|
||||
}
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
232
src/internet-stack/ipv6-route.h
Normal file
232
src/internet-stack/ipv6-route.h
Normal file
@@ -0,0 +1,232 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Strasbourg University
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#ifndef IPV6_ROUTE_H
|
||||
#define IPV6_ROUTE_H
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
#include "ns3/simple-ref-count.h"
|
||||
|
||||
#include "ns3/ipv6-address.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
class NetDevice;
|
||||
|
||||
/**
|
||||
* \ingroup ipv6Routing
|
||||
* \class Ipv6Route
|
||||
* \brief IPv6 route cache entry.
|
||||
*/
|
||||
class Ipv6Route : public SimpleRefCount<Ipv6Route>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor.
|
||||
*/
|
||||
Ipv6Route ();
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
virtual ~Ipv6Route ();
|
||||
|
||||
/**
|
||||
* \brief Set destination address.
|
||||
* \param dest IPv6 destination address
|
||||
*/
|
||||
void SetDestination (Ipv6Address dest);
|
||||
|
||||
/**
|
||||
* \brief Get destination address.
|
||||
* \return destination address
|
||||
*/
|
||||
Ipv6Address GetDestination () const;
|
||||
|
||||
/**
|
||||
* \brief Set source address.
|
||||
* \param src IPv6 source address
|
||||
*/
|
||||
void SetSource (Ipv6Address src);
|
||||
|
||||
/**
|
||||
* \brief Get source address.
|
||||
* \return source address
|
||||
*/
|
||||
Ipv6Address GetSource () const;
|
||||
|
||||
/**
|
||||
* \brief Set gateway address.
|
||||
* \param gw IPv6 gateway address
|
||||
*/
|
||||
void SetGateway (Ipv6Address gw);
|
||||
|
||||
/**
|
||||
* \brief Get gateway address.
|
||||
* \return gateway address
|
||||
*/
|
||||
Ipv6Address GetGateway () const;
|
||||
|
||||
/**
|
||||
* \brief Set output device for outgoing packets.
|
||||
* \param outputDevice output device
|
||||
*/
|
||||
void SetOutputDevice (Ptr<NetDevice> outputDevice);
|
||||
|
||||
/**
|
||||
* \brief Get output device.
|
||||
* \return output device
|
||||
*/
|
||||
Ptr<NetDevice> GetOutputDevice () const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief Destination address.
|
||||
*/
|
||||
Ipv6Address m_dest;
|
||||
|
||||
/**
|
||||
* \brief source address.
|
||||
*/
|
||||
Ipv6Address m_source;
|
||||
|
||||
/**
|
||||
* \brief Gateway address.
|
||||
*/
|
||||
Ipv6Address m_gateway;
|
||||
|
||||
/**
|
||||
* \brief Output device.
|
||||
*/
|
||||
Ptr<NetDevice> m_outputDevice;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv6Route const& route);
|
||||
|
||||
/**
|
||||
* \ingroup ipv6Routing
|
||||
* \class Ipv6MulticastRoute
|
||||
* \brief IPv6 multicast route entry.
|
||||
*/
|
||||
class Ipv6MulticastRoute : public SimpleRefCount<Ipv6MulticastRoute>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Maximum number of multicast interfaces on a router.
|
||||
*/
|
||||
static const uint32_t MAX_INTERFACES = 16;
|
||||
|
||||
/**
|
||||
* \brief Maximum Time-To-Live (TTL).
|
||||
*/
|
||||
static const uint32_t MAX_TTL = 255;
|
||||
|
||||
/**
|
||||
* \brief Constructor.
|
||||
*/
|
||||
Ipv6MulticastRoute ();
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
virtual ~Ipv6MulticastRoute ();
|
||||
|
||||
/**
|
||||
* \brief Set IPv6 group.
|
||||
* \param group Ipv6Address of the multicast group
|
||||
*/
|
||||
void SetGroup (const Ipv6Address group);
|
||||
|
||||
/**
|
||||
* \brief Get IPv6 group.
|
||||
* \return Ipv6Address of the multicast group
|
||||
*/
|
||||
Ipv6Address GetGroup (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set origin address.
|
||||
* \param origin Ipv6Address of the origin address
|
||||
*/
|
||||
void SetOrigin (const Ipv6Address origin);
|
||||
|
||||
/**
|
||||
* \brief Get source address.
|
||||
* \return Ipv6Address of the origin address
|
||||
*/
|
||||
Ipv6Address GetOrigin (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set parent for this route.
|
||||
* \param iif Parent (input interface) for this route
|
||||
*/
|
||||
void SetParent (uint32_t iif);
|
||||
|
||||
/**
|
||||
* \brief Get parent for this route.
|
||||
* \return Parent (input interface) for this route
|
||||
*/
|
||||
uint32_t GetParent (void) const;
|
||||
|
||||
/**
|
||||
* \brief set output TTL for this route.
|
||||
* \param oif Outgoing interface index
|
||||
* \param ttl time-to-live for this route
|
||||
*/
|
||||
void SetOutputTtl (uint32_t oif, uint32_t ttl);
|
||||
|
||||
/**
|
||||
* \brief Get output TTL for this route.
|
||||
* \param oif outgoing interface
|
||||
* \return TTL for this route
|
||||
*/
|
||||
uint32_t GetOutputTtl (uint32_t oif) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief IPv6 group.
|
||||
*/
|
||||
Ipv6Address m_group;
|
||||
|
||||
/**
|
||||
* \brief IPv6 origin (source).
|
||||
*/
|
||||
Ipv6Address m_origin;
|
||||
|
||||
/**
|
||||
* \brief Source interface.
|
||||
*/
|
||||
uint32_t m_parent;
|
||||
|
||||
/**
|
||||
* \brief TTLs.
|
||||
*/
|
||||
std::vector<uint32_t> m_ttls;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route);
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
#endif /* IPV6_ROUTE_H */
|
||||
|
||||
40
src/internet-stack/ipv6-routing-protocol.cc
Normal file
40
src/internet-stack/ipv6-routing-protocol.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* taken from src/node/ipv4-routing-protocol.cc and adapted to IPv6 */
|
||||
|
||||
#include "ns3/assert.h"
|
||||
|
||||
#include "ipv6-route.h"
|
||||
#include "ipv6-routing-protocol.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv6RoutingProtocol);
|
||||
|
||||
TypeId Ipv6RoutingProtocol::GetTypeId ()
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv6RoutingProtocol")
|
||||
.SetParent<Object> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
179
src/internet-stack/ipv6-routing-protocol.h
Normal file
179
src/internet-stack/ipv6-routing-protocol.h
Normal file
@@ -0,0 +1,179 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* taken from src/node/ipv4-routing-protocol.h and adapted to IPv6 */
|
||||
|
||||
#ifndef IPV6_ROUTING_PROTOCOL_H
|
||||
#define IPV6_ROUTING_PROTOCOL_H
|
||||
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/socket.h"
|
||||
|
||||
#include "ipv6-header.h"
|
||||
#include "ipv6-interface-address.h"
|
||||
#include "ipv6.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Ipv6MulticastRoute;
|
||||
class Ipv6Route;
|
||||
class NetDevice;
|
||||
|
||||
/**
|
||||
* \ingroup node
|
||||
* \defgroup ipv6Routing Ipv6RoutingProtocol
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup ipv6Routing
|
||||
* \brief Abstract base class for Ipv6 routing protocols.
|
||||
*
|
||||
* Defines two virtual functions for packet routing and forwarding. The first,
|
||||
* RouteOutput (), is used for locally originated packets, and the second,
|
||||
* RouteInput (), is used for forwarding and/or delivering received packets.
|
||||
* Also defines the signatures of four callbacks used in RouteInput ().
|
||||
*/
|
||||
class Ipv6RoutingProtocol : public Object
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
typedef Callback<void, Ptr<Ipv6Route>, Ptr<const Packet>, const Ipv6Header &> UnicastForwardCallback;
|
||||
typedef Callback<void, Ptr<Ipv6MulticastRoute>, Ptr<const Packet>, const Ipv6Header &> MulticastForwardCallback;
|
||||
typedef Callback<void, Ptr<const Packet>, const Ipv6Header &, uint32_t > LocalDeliverCallback;
|
||||
typedef Callback<void, Ptr<const Packet>, const Ipv6Header &, Socket::SocketErrno > ErrorCallback;
|
||||
|
||||
/**
|
||||
* \brief Query routing cache for an existing route, for an outbound packet
|
||||
*
|
||||
* This lookup is used by transport protocols. It does not cause any
|
||||
* packet to be forwarded, and is synchronous. Can be used for
|
||||
* multicast or unicast. The Linux equivalent is ip_route_output ()
|
||||
*
|
||||
* \param p packet to be routed. Note that this method may modify the packet.
|
||||
* Callers may also pass in a null pointer.
|
||||
* \param header input parameter (used to form key to search for the route)
|
||||
* \param oif Output interface device. May be zero, or may be bound via
|
||||
* socket options to a particular output interface.
|
||||
* \param sockerr Output parameter; socket errno
|
||||
*
|
||||
* \returns a code that indicates what happened in the lookup
|
||||
*/
|
||||
virtual Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) = 0;
|
||||
|
||||
/**
|
||||
* \brief Route an input packet (to be forwarded or locally delivered)
|
||||
*
|
||||
* This lookup is used in the forwarding process. The packet is
|
||||
* handed over to the Ipv6RoutingProtocol, and will get forwarded onward
|
||||
* by one of the callbacks. The Linux equivalent is ip_route_input ().
|
||||
* There are four valid outcomes, and a matching callbacks to handle each.
|
||||
*
|
||||
* \param p received packet
|
||||
* \param header input parameter used to form a search key for a route
|
||||
* \param idev Pointer to ingress network device
|
||||
* \param ucb Callback for the case in which the packet is to be forwarded
|
||||
* as unicast
|
||||
* \param mcb Callback for the case in which the packet is to be forwarded
|
||||
* as multicast
|
||||
* \param lcb Callback for the case in which the packet is to be locally
|
||||
* delivered
|
||||
* \param ecb Callback to call if there is an error in forwarding
|
||||
* \returns true if the Ipv6RoutingProtocol takes responsibility for
|
||||
* forwarding or delivering the packet, false otherwise
|
||||
*/
|
||||
virtual bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
|
||||
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
|
||||
LocalDeliverCallback lcb, ErrorCallback ecb) = 0;
|
||||
|
||||
/**
|
||||
* \brief Notify when specified interface goes UP.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified of the state change of
|
||||
* an interface in a node.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
*/
|
||||
virtual void NotifyInterfaceUp (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \brief Notify when specified interface goes DOWN.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified of the state change of
|
||||
* an interface in a node.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
*/
|
||||
virtual void NotifyInterfaceDown (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \brief Notify when specified interface add an address.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified whenever
|
||||
* a new address is added to an interface. Typically used to add a 'network route' on an
|
||||
* interface. Can be invoked on an up or down interface.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
*/
|
||||
virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \brief Notify when specified interface add an address.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified whenever
|
||||
* a new address is removed from an interface. Typically used to remove the 'network route' of an
|
||||
* interface. Can be invoked on an up or down interface.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
*/
|
||||
virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \brief Notify a new route.
|
||||
*
|
||||
* Typically this is used to add another route from IPv6 stack (i.e. ICMPv6
|
||||
* redirect case, ...).
|
||||
* \param dst destination address
|
||||
* \param mask destination mask
|
||||
* \param nextHop nextHop for this destination
|
||||
* \param interface output interface
|
||||
* \param prefixToUse prefix to use as source with this route
|
||||
*/
|
||||
virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ()) = 0;
|
||||
|
||||
/**
|
||||
* \brief Notify route removing.
|
||||
* \param dst destination address
|
||||
* \param mask destination mask
|
||||
* \param nextHop nextHop for this destination
|
||||
* \param interface output interface
|
||||
* \param prefixToUse prefix to use as source with this route
|
||||
*/
|
||||
virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ()) = 0;
|
||||
|
||||
/**
|
||||
* \brief Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol
|
||||
* \param ipv6 the ipv6 object this routing protocol is being associated with
|
||||
*/
|
||||
virtual void SetIpv6 (Ptr<Ipv6> ipv6) = 0;
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* IPV6_ROUTING_PROTOCOL_H */
|
||||
|
||||
61
src/internet-stack/ipv6.cc
Normal file
61
src/internet-stack/ipv6.cc
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
/* taken from src/node/ipv4.h and adapted to IPv6 */
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/boolean.h"
|
||||
|
||||
#include "ipv6.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv6);
|
||||
|
||||
TypeId Ipv6::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv6")
|
||||
.SetParent<Object> ()
|
||||
.AddAttribute ("IpForward", "Globally enable or disable IP forwarding for all current and future IPv6 devices.",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&Ipv6::SetIpForward,
|
||||
&Ipv6::GetIpForward),
|
||||
MakeBooleanChecker ())
|
||||
#if 0
|
||||
.AddAttribute ("MtuDiscover", "If enabled, every outgoing IPv6 packet will have the DF flag set.",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&UdpSocket::SetMtuDiscover,
|
||||
&UdpSocket::GetMtuDiscover),
|
||||
MakeBooleanChecker ())
|
||||
#endif
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
Ipv6::Ipv6 ()
|
||||
{}
|
||||
|
||||
Ipv6::~Ipv6 ()
|
||||
{}
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
319
src/internet-stack/ipv6.h
Normal file
319
src/internet-stack/ipv6.h
Normal file
@@ -0,0 +1,319 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
/* taken from src/node/ipv4.h and adapted to IPv6 */
|
||||
|
||||
#ifndef IPV6_H
|
||||
#define IPV6_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/callback.h"
|
||||
|
||||
#include "ns3/ipv6-address.h"
|
||||
#include "ipv6-interface-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Node;
|
||||
class NetDevice;
|
||||
class Packet;
|
||||
class Ipv6RoutingProtocol;
|
||||
|
||||
/**
|
||||
* \ingroup node
|
||||
* \defgroup ipv6 Ipv6
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup ipv6
|
||||
* \brief Access to the IPv6 forwarding table, interfaces, and configuration
|
||||
*
|
||||
* This class defines the API to manipulate the following aspects of
|
||||
* the IPv6 implementation:
|
||||
* -# set/get an Ipv6RoutingProtocol
|
||||
* -# register a NetDevice for use by the IPv6 layer (basically, to
|
||||
* create IPv6-related state such as addressing and neighbor cache that
|
||||
* is associated with a NetDevice)
|
||||
* -# manipulate the status of the NetDevice from the IPv6 perspective,
|
||||
* such as marking it as Up or Down,
|
||||
* -# adding, deleting, and getting addresses associated to the IPv6
|
||||
* interfaces.
|
||||
* -# exporting IPv6 configuration attributes
|
||||
*
|
||||
* Each NetDevice has conceptually a single IPv6 interface associated
|
||||
* with it (the corresponding structure in the Linux IPv6 implementation
|
||||
* is struct in_device). Each interface may have one or more IPv6
|
||||
* addresses associated with it. Each IPv6 address may have different
|
||||
* subnet mask, scope, etc., so all of this per-address information
|
||||
* is stored in an Ipv6InterfaceAddress class (the corresponding
|
||||
* structure in Linux is struct in6_ifaddr)
|
||||
*
|
||||
* IPv6 attributes such as whether IP forwarding is enabled and disabled
|
||||
* are also stored in this class
|
||||
*
|
||||
* TO DO: Add API to allow access to the IPv6 neighbor table
|
||||
*
|
||||
* \see Ipv6RoutingProtocol
|
||||
* \see Ipv6InterfaceAddress
|
||||
*/
|
||||
class Ipv6 : public Object
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
/**
|
||||
* \brief Constructor.
|
||||
*/
|
||||
Ipv6 ();
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
virtual ~Ipv6 ();
|
||||
|
||||
/**
|
||||
* \brief Register a new routing protocol to be used by this IPv6 stack
|
||||
*
|
||||
* This call will replace any routing protocol that has been previously
|
||||
* registered. If you want to add multiple routing protocols, you must
|
||||
* add them to a Ipv6ListRoutingProtocol directly.
|
||||
*
|
||||
* \param routingProtocol smart pointer to Ipv6RoutingProtocol object
|
||||
*/
|
||||
virtual void SetRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get the routing protocol to be used by this IPv6 stack
|
||||
*
|
||||
* \returns smart pointer to Ipv6RoutingProtocol object, or null pointer if none
|
||||
*/
|
||||
virtual Ptr<Ipv6RoutingProtocol> GetRoutingProtocol (void) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Add a NetDevice interface.
|
||||
*
|
||||
* Once a device has been added, it can never be removed: if you want
|
||||
* to disable it, you can invoke Ipv6::SetDown which will
|
||||
* make sure that it is never used during packet forwarding.
|
||||
* \param device device to add to the list of IPv6 interfaces
|
||||
* which can be used as output interfaces during packet forwarding.
|
||||
* \returns the index of the IPv6 interface added.
|
||||
*/
|
||||
virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get number of interfaces.
|
||||
* \returns the number of interfaces added by the user.
|
||||
*/
|
||||
virtual uint32_t GetNInterfaces (void) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Return the interface number of the interface that has been
|
||||
* assigned the specified IP address.
|
||||
*
|
||||
* \param address The IP address being searched for
|
||||
* \returns The interface number of the IPv6 interface with the given
|
||||
* address or -1 if not found.
|
||||
*
|
||||
* Each IP interface has one or more IP addresses associated with it.
|
||||
* This method searches the list of interfaces for one that holds a
|
||||
* particular address. This call takes an IP address as a parameter and
|
||||
* returns the interface number of the first interface that has been assigned
|
||||
* that address, or -1 if not found. There must be an exact match.
|
||||
*/
|
||||
virtual int32_t GetInterfaceForAddress (Ipv6Address address) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Return the interface number of first interface found that
|
||||
* has an IPv6 address within the prefix specified by the input
|
||||
* address and mask parameters
|
||||
*
|
||||
* \param address The IP address assigned to the interface of interest.
|
||||
* \param mask The IP prefix to use in the mask
|
||||
* \returns The interface number of the IPv6 interface with the given
|
||||
* address or -1 if not found.
|
||||
*
|
||||
* Each IP interface has one or more IP addresses associated with it.
|
||||
* This method searches the list of interfaces for the first one found
|
||||
* that holds an address that is included within the prefix
|
||||
* formed by the input address and mask parameters. The value -1 is
|
||||
* returned if no match is found.
|
||||
*/
|
||||
virtual int32_t GetInterfaceForPrefix (Ipv6Address address,
|
||||
Ipv6Prefix mask) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Get the NetDevice of the specified interface number.
|
||||
* \param interface The interface number of an IPv6 interface.
|
||||
* \returns The NetDevice associated with the IPv6 interface number.
|
||||
*/
|
||||
virtual Ptr<NetDevice> GetNetDevice (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get the interface index of the specified NetDevice.
|
||||
* \param device The NetDevice for an Ipv6Interface
|
||||
* \returns The interface number of an IPv6 interface or -1 if not found.
|
||||
*/
|
||||
virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Add an address on the specified IPv6 interface.
|
||||
* \param interface Interface number of an IPv6 interface
|
||||
* \param address Ipv6InterfaceAddress address to associate with the underlying IPv6 interface
|
||||
* \returns true if the operation succeeded
|
||||
*/
|
||||
virtual bool AddAddress (uint32_t interface, Ipv6InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get number of addresses on specified IPv6 interface.
|
||||
* \param interface Interface number of an IPv6 interface
|
||||
* \returns the number of Ipv6InterfaceAddress entries for the interface.
|
||||
*/
|
||||
virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Get IPv6 address on specified IPv6 interface.
|
||||
*
|
||||
* Because addresses can be removed, the addressIndex is not guaranteed
|
||||
* to be static across calls to this method.
|
||||
*
|
||||
* \param interface Interface number of an IPv6 interface
|
||||
* \param addressIndex index of Ipv6InterfaceAddress
|
||||
* \returns the Ipv6InterfaceAddress associated to the interface and addressIndex
|
||||
*/
|
||||
virtual Ipv6InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Remove an address on specified IPv6 interface.
|
||||
*
|
||||
* Remove the address at addressIndex on named interface. The addressIndex
|
||||
* for all higher indices will decrement by one after this method is called;
|
||||
* so, for example, to remove 5 addresses from an interface i, one could
|
||||
* call RemoveAddress (i, 0); 5 times.
|
||||
*
|
||||
* \param interface Interface number of an IPv6 interface
|
||||
* \param addressIndex index of Ipv6InterfaceAddress to remove
|
||||
* \returns true if the operation succeeded
|
||||
*/
|
||||
virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex) = 0;
|
||||
|
||||
/**
|
||||
* \brief Set metric on specified Ipv6 interface.
|
||||
*
|
||||
* \param interface The interface number of an IPv6 interface
|
||||
* \param metric routing metric (cost) associated to the underlying
|
||||
* IPv6 interface
|
||||
*/
|
||||
virtual void SetMetric (uint32_t interface, uint16_t metric) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get metric for the specified IPv6 interface.
|
||||
*
|
||||
* \param interface The interface number of an IPv6 interface
|
||||
* \returns routing metric (cost) associated to the underlying
|
||||
* IPv6 interface
|
||||
*/
|
||||
virtual uint16_t GetMetric (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Get MTU for the specified IPv6 interface.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \returns the Maximum Transmission Unit (in bytes) associated
|
||||
* to the underlying IPv6 interface
|
||||
*/
|
||||
virtual uint16_t GetMtu (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief If the specified interface index is in "up" state.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \returns true if the underlying interface is in the "up" state,
|
||||
* false otherwise.
|
||||
*/
|
||||
virtual bool IsUp (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Set the interface into the "up" state.
|
||||
*
|
||||
* In this state, it is considered valid during IPv6 forwarding.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
*/
|
||||
virtual void SetUp (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \brief Set the interface into the "down" state.
|
||||
*
|
||||
* In this state, it is ignored during IPv6 forwarding.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
*/
|
||||
virtual void SetDown (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \brief If the specified IPv6 interface has forwarding enabled.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \returns true if IPv6 forwarding enabled for input datagrams on this device
|
||||
*/
|
||||
virtual bool IsForwarding (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Set forwarding on specified IPv6 interface.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \param val Value to set the forwarding flag
|
||||
*
|
||||
* If set to true, IPv6 forwarding is enabled for input datagrams on this device
|
||||
*/
|
||||
virtual void SetForwarding (uint32_t interface, bool val) = 0;
|
||||
|
||||
/**
|
||||
* \brief Register the IPv6 Extensions.
|
||||
*/
|
||||
virtual void RegisterExtensions () = 0;
|
||||
|
||||
/**
|
||||
* \brief Register the IPv6 Options.
|
||||
*/
|
||||
virtual void RegisterOptions () = 0;
|
||||
|
||||
/**
|
||||
* \brief Any interface magic number.
|
||||
*/
|
||||
static const uint32_t IF_ANY = 0xffffffff;
|
||||
|
||||
private:
|
||||
// Indirect the IPv6 attributes through private pure virtual methods
|
||||
/**
|
||||
* \brief Set IPv6 forwarding state.
|
||||
* \param forward IPv6 forwarding enabled or not
|
||||
*/
|
||||
virtual void SetIpForward (bool forward) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get IPv6 forwarding state.
|
||||
* \return forwarding state (enabled or not)
|
||||
*/
|
||||
virtual bool GetIpForward (void) const = 0;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* IPV6_H */
|
||||
|
||||
37
src/internet-stack/tcp-socket-factory.cc
Normal file
37
src/internet-stack/tcp-socket-factory.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 Georgia Tech Research Corporation
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#include "tcp-socket-factory.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/double.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (TcpSocketFactory);
|
||||
|
||||
TypeId
|
||||
TcpSocketFactory::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::TcpSocketFactory")
|
||||
.SetParent<SocketFactory> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
55
src/internet-stack/tcp-socket-factory.h
Normal file
55
src/internet-stack/tcp-socket-factory.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 Georgia Tech Research Corporation
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#ifndef TCP_SOCKET_FACTORY_H
|
||||
#define TCP_SOCKET_FACTORY_H
|
||||
|
||||
#include "ns3/socket-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Socket;
|
||||
|
||||
/**
|
||||
* \ingroup socket
|
||||
*
|
||||
* \brief API to create TCP socket instances
|
||||
*
|
||||
* This abstract class defines the API for TCP sockets.
|
||||
* This class also holds the global default variables used to
|
||||
* initialize newly created sockets, such as values that are
|
||||
* set through the sysctl or proc interfaces in Linux.
|
||||
|
||||
* All TCP socket factory implementations must provide an implementation
|
||||
* of CreateSocket
|
||||
* below, and should make use of the default values configured below.
|
||||
*
|
||||
* \see TcpSocketFactoryImpl
|
||||
*
|
||||
*/
|
||||
class TcpSocketFactory : public SocketFactory
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* TCP_SOCKET_FACTORY_H */
|
||||
116
src/internet-stack/tcp-socket.cc
Normal file
116
src/internet-stack/tcp-socket.cc
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/double.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "ns3/nstime.h"
|
||||
#include "tcp-socket.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("TcpSocket");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (TcpSocket);
|
||||
|
||||
const char* const TcpSocket::TcpStateName[LAST_STATE] = {"CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", "ESTABLISHED", "CLOSE_WAIT", "LAST_ACK", "FIN_WAIT_1", "FIN_WAIT_2", "CLOSING", "TIME_WAIT" };
|
||||
|
||||
TypeId
|
||||
TcpSocket::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::TcpSocket")
|
||||
.SetParent<Socket> ()
|
||||
.AddAttribute ("SndBufSize",
|
||||
"TcpSocket maximum transmit buffer size (bytes)",
|
||||
UintegerValue (131072), // 128k
|
||||
MakeUintegerAccessor (&TcpSocket::GetSndBufSize,
|
||||
&TcpSocket::SetSndBufSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("RcvBufSize",
|
||||
"TcpSocket maximum receive buffer size (bytes)",
|
||||
UintegerValue (131072),
|
||||
MakeUintegerAccessor (&TcpSocket::GetRcvBufSize,
|
||||
&TcpSocket::SetRcvBufSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("SegmentSize",
|
||||
"TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
|
||||
UintegerValue (536),
|
||||
MakeUintegerAccessor (&TcpSocket::GetSegSize,
|
||||
&TcpSocket::SetSegSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("SlowStartThreshold",
|
||||
"TCP slow start threshold (bytes)",
|
||||
UintegerValue (0xffff),
|
||||
MakeUintegerAccessor (&TcpSocket::GetSSThresh,
|
||||
&TcpSocket::SetSSThresh),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("InitialCwnd",
|
||||
"TCP initial congestion window size (segments)",
|
||||
UintegerValue (1),
|
||||
MakeUintegerAccessor (&TcpSocket::GetInitialCwnd,
|
||||
&TcpSocket::SetInitialCwnd),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("ConnTimeout",
|
||||
"TCP retransmission timeout when opening connection (seconds)",
|
||||
TimeValue (Seconds (3)),
|
||||
MakeTimeAccessor (&TcpSocket::GetConnTimeout,
|
||||
&TcpSocket::SetConnTimeout),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("ConnCount",
|
||||
"Number of connection attempts (SYN retransmissions) before returning failure",
|
||||
UintegerValue (6),
|
||||
MakeUintegerAccessor (&TcpSocket::GetConnCount,
|
||||
&TcpSocket::SetConnCount),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DelAckTimeout",
|
||||
"Timeout value for TCP delayed acks, in seconds",
|
||||
TimeValue (Seconds (0.2)),
|
||||
MakeTimeAccessor (&TcpSocket::GetDelAckTimeout,
|
||||
&TcpSocket::SetDelAckTimeout),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("DelAckCount",
|
||||
"Number of packets to wait before sending a TCP ack",
|
||||
UintegerValue (2),
|
||||
MakeUintegerAccessor (&TcpSocket::GetDelAckMaxCount,
|
||||
&TcpSocket::SetDelAckMaxCount),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("PersistTimeout",
|
||||
"Persist timeout to probe for rx window",
|
||||
TimeValue (Seconds (6)),
|
||||
MakeTimeAccessor (&TcpSocket::GetPersistTimeout,
|
||||
&TcpSocket::SetPersistTimeout),
|
||||
MakeTimeChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
TcpSocket::TcpSocket ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
TcpSocket::~TcpSocket ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
101
src/internet-stack/tcp-socket.h
Normal file
101
src/internet-stack/tcp-socket.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 Georgia Tech Research Corporation
|
||||
* 2007 INRIA
|
||||
*
|
||||
* 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: George F. Riley<riley@ece.gatech.edu>
|
||||
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef __TCP_SOCKET_H__
|
||||
#define __TCP_SOCKET_H__
|
||||
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/traced-callback.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Node;
|
||||
class Packet;
|
||||
|
||||
/* Names of the 11 TCP states */
|
||||
typedef enum {
|
||||
CLOSED, // 0
|
||||
LISTEN, // 1
|
||||
SYN_SENT, // 2
|
||||
SYN_RCVD, // 3
|
||||
ESTABLISHED, // 4
|
||||
CLOSE_WAIT, // 5
|
||||
LAST_ACK, // 6
|
||||
FIN_WAIT_1, // 7
|
||||
FIN_WAIT_2, // 8
|
||||
CLOSING, // 9
|
||||
TIME_WAIT, // 10
|
||||
LAST_STATE } TcpStates_t;
|
||||
|
||||
/**
|
||||
* \ingroup socket
|
||||
*
|
||||
* \brief (abstract) base class of all TcpSockets
|
||||
*
|
||||
* This class exists solely for hosting TcpSocket attributes that can
|
||||
* be reused across different implementations.
|
||||
*/
|
||||
class TcpSocket : public Socket
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
TcpSocket (void);
|
||||
virtual ~TcpSocket (void);
|
||||
|
||||
// Literal names of TCP states for use in log messages */
|
||||
static const char* const TcpStateName[LAST_STATE];
|
||||
|
||||
private:
|
||||
// Indirect the attribute setting and getting through private virtual methods
|
||||
virtual void SetSndBufSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetSndBufSize (void) const = 0;
|
||||
virtual void SetRcvBufSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetRcvBufSize (void) const = 0;
|
||||
virtual void SetSegSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetSegSize (void) const = 0;
|
||||
virtual void SetSSThresh (uint32_t threshold) = 0;
|
||||
virtual uint32_t GetSSThresh (void) const = 0;
|
||||
virtual void SetInitialCwnd (uint32_t count) = 0;
|
||||
virtual uint32_t GetInitialCwnd (void) const = 0;
|
||||
virtual void SetConnTimeout (Time timeout) = 0;
|
||||
virtual Time GetConnTimeout (void) const = 0;
|
||||
virtual void SetConnCount (uint32_t count) = 0;
|
||||
virtual uint32_t GetConnCount (void) const = 0;
|
||||
virtual void SetDelAckTimeout (Time timeout) = 0;
|
||||
virtual Time GetDelAckTimeout (void) const = 0;
|
||||
virtual void SetDelAckMaxCount (uint32_t count) = 0;
|
||||
virtual uint32_t GetDelAckMaxCount (void) const = 0;
|
||||
virtual void SetPersistTimeout (Time timeout) = 0;
|
||||
virtual Time GetPersistTimeout (void) const = 0;
|
||||
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* TCP_SOCKET_H */
|
||||
|
||||
|
||||
35
src/internet-stack/udp-socket-factory.cc
Normal file
35
src/internet-stack/udp-socket-factory.cc
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "udp-socket-factory.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (UdpSocketFactory);
|
||||
|
||||
TypeId UdpSocketFactory::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::UdpSocketFactory")
|
||||
.SetParent<SocketFactory> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
49
src/internet-stack/udp-socket-factory.h
Normal file
49
src/internet-stack/udp-socket-factory.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef UDP_SOCKET_FACTORY_H
|
||||
#define UDP_SOCKET_FACTORY_H
|
||||
|
||||
#include "ns3/socket-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Socket;
|
||||
|
||||
/**
|
||||
* \ingroup socket
|
||||
*
|
||||
* \brief API to create UDP socket instances
|
||||
*
|
||||
* This abstract class defines the API for UDP socket factory.
|
||||
* All UDP implementations must provide an implementation of CreateSocket
|
||||
* below.
|
||||
*
|
||||
* \see UdpSocketFactoryImpl
|
||||
*/
|
||||
class UdpSocketFactory : public SocketFactory
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* UDP_SOCKET_FACTORY_H */
|
||||
89
src/internet-stack/udp-socket.cc
Normal file
89
src/internet-stack/udp-socket.cc
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/integer.h"
|
||||
#include "ns3/boolean.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "udp-socket.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("UdpSocket");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (UdpSocket);
|
||||
|
||||
TypeId
|
||||
UdpSocket::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::UdpSocket")
|
||||
.SetParent<Socket> ()
|
||||
.AddAttribute ("RcvBufSize",
|
||||
"UdpSocket maximum receive buffer size (bytes)",
|
||||
UintegerValue (131072),
|
||||
MakeUintegerAccessor (&UdpSocket::GetRcvBufSize,
|
||||
&UdpSocket::SetRcvBufSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("IpTtl",
|
||||
"socket-specific TTL for unicast IP packets (if non-zero)",
|
||||
UintegerValue (0),
|
||||
MakeUintegerAccessor (&UdpSocket::GetIpTtl,
|
||||
&UdpSocket::SetIpTtl),
|
||||
MakeUintegerChecker<uint8_t> ())
|
||||
.AddAttribute ("IpMulticastTtl",
|
||||
"socket-specific TTL for multicast IP packets (if non-zero)",
|
||||
UintegerValue (0),
|
||||
MakeUintegerAccessor (&UdpSocket::GetIpMulticastTtl,
|
||||
&UdpSocket::SetIpMulticastTtl),
|
||||
MakeUintegerChecker<uint8_t> ())
|
||||
.AddAttribute ("IpMulticastIf",
|
||||
"interface index for outgoing multicast on this socket; -1 indicates to use default interface",
|
||||
IntegerValue (-1),
|
||||
MakeIntegerAccessor (&UdpSocket::GetIpMulticastIf,
|
||||
&UdpSocket::SetIpMulticastIf),
|
||||
MakeIntegerChecker<int32_t> ())
|
||||
.AddAttribute ("IpMulticastLoop",
|
||||
"whether outgoing multicast sent also to loopback interface",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&UdpSocket::GetIpMulticastLoop,
|
||||
&UdpSocket::SetIpMulticastLoop),
|
||||
MakeBooleanChecker ())
|
||||
.AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
|
||||
BooleanValue (false),
|
||||
MakeBooleanAccessor (&UdpSocket::SetMtuDiscover,
|
||||
&UdpSocket::GetMtuDiscover),
|
||||
MakeBooleanChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
UdpSocket::UdpSocket ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
UdpSocket::~UdpSocket ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
120
src/internet-stack/udp-socket.h
Normal file
120
src/internet-stack/udp-socket.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 Georgia Tech Research Corporation
|
||||
* 2007 INRIA
|
||||
*
|
||||
* 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: George F. Riley<riley@ece.gatech.edu>
|
||||
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef __UDP_SOCKET_H__
|
||||
#define __UDP_SOCKET_H__
|
||||
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/traced-callback.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/object.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Node;
|
||||
class Packet;
|
||||
|
||||
/**
|
||||
* \ingroup socket
|
||||
*
|
||||
* \brief (abstract) base class of all UdpSockets
|
||||
*
|
||||
* This class exists solely for hosting UdpSocket attributes that can
|
||||
* be reused across different implementations, and for declaring
|
||||
* UDP-specific multicast API.
|
||||
*/
|
||||
class UdpSocket : public Socket
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
UdpSocket (void);
|
||||
virtual ~UdpSocket (void);
|
||||
|
||||
/**
|
||||
* \brief Corresponds to socket option MCAST_JOIN_GROUP
|
||||
*
|
||||
* \param interface interface number, or 0
|
||||
* \param groupAddress multicast group address
|
||||
* \returns on success, zero is returned. On error, -1 is returned,
|
||||
* and errno is set appropriately
|
||||
*
|
||||
* Enable reception of multicast datagrams for this socket on the
|
||||
* interface number specified. If zero is specified as
|
||||
* the interface, then a single local interface is chosen by
|
||||
* system. In the future, this function will generate trigger IGMP
|
||||
* joins as necessary when IGMP is implemented, but for now, this
|
||||
* just enables multicast datagram reception in the system if not already
|
||||
* enabled for this interface/groupAddress combination.
|
||||
*
|
||||
* \attention IGMP is not yet implemented in ns-3
|
||||
*
|
||||
* This function may be called repeatedly on a given socket but each
|
||||
* join must be for a different multicast address, or for the same
|
||||
* multicast address but on a different interface from previous joins.
|
||||
* This enables host multihoming, and the ability to join the same
|
||||
* group on different interfaces.
|
||||
*/
|
||||
virtual int MulticastJoinGroup (uint32_t interface, const Address &groupAddress) = 0;
|
||||
|
||||
/**
|
||||
* \brief Corresponds to socket option MCAST_LEAVE_GROUP
|
||||
*
|
||||
* \param interface interface number, or 0
|
||||
* \param groupAddress multicast group address
|
||||
* \returns on success, zero is returned. On error, -1 is returned,
|
||||
* and errno is set appropriately
|
||||
*
|
||||
* Disable reception of multicast datagrams for this socket on the
|
||||
* interface number specified. If zero is specified as
|
||||
* the interfaceIndex, then a single local interface is chosen by
|
||||
* system. In the future, this function will generate trigger IGMP
|
||||
* leaves as necessary when IGMP is implemented, but for now, this
|
||||
* just disables multicast datagram reception in the system if this
|
||||
* socket is the last for this interface/groupAddress combination.
|
||||
*
|
||||
* \attention IGMP is not yet implemented in ns-3
|
||||
*/
|
||||
virtual int MulticastLeaveGroup (uint32_t interface, const Address &groupAddress) = 0;
|
||||
|
||||
private:
|
||||
// Indirect the attribute setting and getting through private virtual methods
|
||||
virtual void SetRcvBufSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetRcvBufSize (void) const = 0;
|
||||
virtual void SetIpTtl (uint8_t ipTtl) = 0;
|
||||
virtual uint8_t GetIpTtl (void) const = 0;
|
||||
virtual void SetIpMulticastTtl (uint8_t ipTtl) = 0;
|
||||
virtual uint8_t GetIpMulticastTtl (void) const = 0;
|
||||
virtual void SetIpMulticastIf (int32_t ipIf) = 0;
|
||||
virtual int32_t GetIpMulticastIf (void) const = 0;
|
||||
virtual void SetIpMulticastLoop (bool loop) = 0;
|
||||
virtual bool GetIpMulticastLoop (void) const = 0;
|
||||
virtual void SetMtuDiscover (bool discover) = 0;
|
||||
virtual bool GetMtuDiscover (void) const = 0;
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* UDP_SOCKET_H */
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ def configure(conf):
|
||||
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_module('internet-stack', ['node'])
|
||||
obj = bld.create_ns3_module('internet-stack', ['network'])
|
||||
obj.source = [
|
||||
'tcp-test.cc',
|
||||
'udp-test.cc',
|
||||
@@ -147,6 +147,23 @@ def build(bld):
|
||||
'tcp-tx-buffer.cc',
|
||||
'ipv4-packet-info-tag.cc',
|
||||
'ipv6-packet-info-tag.cc',
|
||||
'ipv4-interface-address.cc',
|
||||
'ipv4-address-generator.cc',
|
||||
'ipv4-header.cc',
|
||||
'ipv4-route.cc',
|
||||
'ipv4-routing-protocol.cc',
|
||||
'udp-socket.cc',
|
||||
'udp-socket-factory.cc',
|
||||
'tcp-socket.cc',
|
||||
'tcp-socket-factory.cc',
|
||||
'ipv4.cc',
|
||||
'ipv4-raw-socket-factory.cc',
|
||||
'ipv6-header.cc',
|
||||
'ipv6-interface-address.cc',
|
||||
'ipv6-route.cc',
|
||||
'ipv6.cc',
|
||||
'ipv6-raw-socket-factory.cc',
|
||||
'ipv6-routing-protocol.cc',
|
||||
]
|
||||
|
||||
headers = bld.new_task_gen('ns3header')
|
||||
@@ -176,6 +193,23 @@ def build(bld):
|
||||
'loopback-net-device.h',
|
||||
'ipv4-packet-info-tag.h',
|
||||
'ipv6-packet-info-tag.h',
|
||||
'ipv4-interface-address.h',
|
||||
'ipv4-address-generator.h',
|
||||
'ipv4-header.h',
|
||||
'ipv4-route.h',
|
||||
'ipv4-routing-protocol.h',
|
||||
'udp-socket.h',
|
||||
'udp-socket-factory.h',
|
||||
'tcp-socket.h',
|
||||
'tcp-socket-factory.h',
|
||||
'ipv4.h',
|
||||
'ipv4-raw-socket-factory.h',
|
||||
'ipv6-header.h',
|
||||
'ipv6-interface-address.h',
|
||||
'ipv6-route.h',
|
||||
'ipv6.h',
|
||||
'ipv6-raw-socket-factory.h',
|
||||
'ipv6-routing-protocol.h',
|
||||
]
|
||||
|
||||
if bld.env['NSC_ENABLED']:
|
||||
|
||||
Reference in New Issue
Block a user