26 #include <ns3/node-container.h>
28 #include <ns3/satellite-topology.h>
29 #include <ns3/singleton.h>
35 NS_LOG_COMPONENT_DEFINE(
"SatIslArbiterUnicastHelper");
40 NS_OBJECT_ENSURE_REGISTERED(SatIslArbiterUnicastHelper);
45 static TypeId tid = TypeId(
"ns3::SatIslArbiterUnicastHelper")
47 .AddConstructor<SatIslArbiterUnicastHelper>();
53 NS_FATAL_ERROR(
"Default constructor not in use");
57 std::vector<std::pair<uint32_t, uint32_t>> isls)
60 NS_LOG_FUNCTION(
this);
66 NS_LOG_FUNCTION(
this);
70 for (uint32_t satIndex = 0; satIndex < globalState.size(); satIndex++)
72 Ptr<Node> satelliteNode = Singleton<SatTopology>::Get()->GetOrbiterNode(satIndex);
73 Ptr<SatOrbiterNetDevice> satelliteOrbiterNetDevice;
74 for (uint32_t ndIndex = 0; ndIndex < satelliteNode->GetNDevices(); ndIndex++)
76 Ptr<SatOrbiterNetDevice> nd =
77 DynamicCast<SatOrbiterNetDevice>(satelliteNode->GetDevice(ndIndex));
80 satelliteOrbiterNetDevice = nd;
84 NS_ASSERT_MSG(satelliteOrbiterNetDevice !=
nullptr,
85 "SatOrbiterNetDevice not found on satellite");
87 std::vector<Ptr<PointToPointIslNetDevice>> islNetDevices =
88 satelliteOrbiterNetDevice->GetIslsNetDevices();
89 Ptr<SatIslArbiterUnicast> arbiter = CreateObject<SatIslArbiterUnicast>(satelliteNode);
91 for (uint32_t islInterfaceIndex = 0; islInterfaceIndex < islNetDevices.size();
94 uint32_t interfaceNextHopNodeId =
95 islNetDevices[islInterfaceIndex]->GetDestinationNode()->GetId();
96 for (std::map<uint32_t, uint32_t>::iterator it = globalState[satIndex].begin();
97 it != globalState[satIndex].end();
100 uint32_t destinationNodeId = it->first;
101 uint32_t nextHopNodeId = it->second;
103 if (interfaceNextHopNodeId == nextHopNodeId)
105 arbiter->AddNextHopEntry(destinationNodeId, islInterfaceIndex);
109 satelliteOrbiterNetDevice->SetArbiter(arbiter);
116 NS_LOG_FUNCTION(
this);
121 std::vector<std::map<uint32_t, uint32_t>>
124 NS_LOG_FUNCTION(
this);
127 std::vector<std::vector<std::vector<uint32_t>>> globalCandidateList;
132 int64_t n = Singleton<SatTopology>::Get()->GetNOrbiterNodes();
138 NS_FATAL_ERROR(
"Cannot handle more than 40000 nodes");
143 int32_t* dist =
new int32_t[n2];
144 for (
int i = 0; i < n; i++)
146 for (
int j = 0; j < n; j++)
154 dist[n * i + j] = 100000000;
160 for (std::pair<uint64_t, uint64_t> edge :
m_isls)
162 dist[n * edge.first + edge.second] = 1;
163 dist[n * edge.second + edge.first] = 1;
167 for (
int k = 0; k < n; k++)
169 for (
int i = 0; i < n; i++)
171 for (
int j = 0; j < n; j++)
173 if (dist[n * i + j] > dist[n * i + k] + dist[n * k + j])
175 dist[n * i + j] = dist[n * i + k] + dist[n * k + j];
186 globalCandidateList.reserve(n);
187 for (
int i = 0; i < n; i++)
189 std::vector<std::vector<uint32_t>> v;
191 for (
int j = 0; j < n; j++)
193 v.push_back(std::vector<uint32_t>());
195 globalCandidateList.push_back(v);
202 for (std::pair<uint64_t, uint64_t> edge :
m_isls)
204 for (
int j = 0; j < n; j++)
206 if (dist[edge.first * n + j] - 1 == dist[edge.second * n + j])
208 globalCandidateList[edge.first][j].push_back(edge.second);
210 if (dist[edge.second * n + j] - 1 == dist[edge.first * n + j])
212 globalCandidateList[edge.second][j].push_back(edge.first);
220 std::vector<std::map<uint32_t, uint32_t>> returnList;
221 for (uint32_t i = 0; i < globalCandidateList.size(); i++)
223 returnList.push_back(std::map<uint32_t, uint32_t>());
224 std::vector<std::vector<uint32_t>> v = globalCandidateList[i];
225 for (uint32_t j = 0; j < v.size(); j++)
229 returnList[i].insert(
230 std::make_pair(j, v[j][0]));
SatIslArbiterUnicastHelper()
Default constructor.
std::vector< std::pair< uint32_t, uint32_t > > m_isls
static TypeId GetTypeId(void)
void InstallArbiters()
Install arbiter on all satellite nodes.
void UpdateArbiters()
Update arbiter on all satellite nodes.
std::vector< std::map< uint32_t, uint32_t > > CalculateGlobalState()
Compute routing tables for all satellite nodes.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.