Update README and add contrib dir

This commit is contained in:
2025-12-01 15:56:02 +01:00
parent 1b80de2153
commit cd9ba93d58
150 changed files with 25563 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
#include "switch-channel.h"
#include "ns3/log.h"
/**
* \file
* \ingroup ethernet
* ns3::SwitchChannel implementation.
*/
namespace ns3
{
NS_LOG_COMPONENT_DEFINE("SwitchChannel");
NS_OBJECT_ENSURE_REGISTERED(SwitchChannel);
TypeId
SwitchChannel::GetTypeId()
{
static TypeId tid = TypeId("ns3::SwitchChannel")
.SetParent<Channel>()
.SetGroupName("Ethernet")
.AddConstructor<SwitchChannel>();
return tid;
}
SwitchChannel::SwitchChannel()
: Channel()
{
NS_LOG_FUNCTION_NOARGS();
}
SwitchChannel::~SwitchChannel()
{
NS_LOG_FUNCTION_NOARGS();
for (auto iter = m_switchedChannels.begin(); iter != m_switchedChannels.end(); iter++)
{
*iter = nullptr;
}
m_switchedChannels.clear();
}
void
SwitchChannel::AddChannel(Ptr<Channel> switchedChannel)
{
m_switchedChannels.push_back(switchedChannel);
}
std::size_t
SwitchChannel::GetNDevices() const
{
uint32_t ndevices = 0;
for (auto iter = m_switchedChannels.begin(); iter != m_switchedChannels.end(); iter++)
{
ndevices += (*iter)->GetNDevices();
}
return ndevices;
}
Ptr<NetDevice>
SwitchChannel::GetDevice(std::size_t i) const
{
std::size_t ndevices = 0;
for (auto iter = m_switchedChannels.begin(); iter != m_switchedChannels.end(); iter++)
{
if ((i - ndevices) < (*iter)->GetNDevices())
{
return (*iter)->GetDevice(i - ndevices);
}
ndevices += (*iter)->GetNDevices();
}
return nullptr;
}
} // namespace ns3