26 #include <ns3/node-container.h>
29 NS_LOG_COMPONENT_DEFINE(
"SatIslArbiterUnicastHelper");
34 NS_OBJECT_ENSURE_REGISTERED(SatIslArbiterUnicastHelper);
39 static TypeId tid = TypeId(
"ns3::SatIslArbiterUnicastHelper")
41 .AddConstructor<SatIslArbiterUnicastHelper>();
47 NS_FATAL_ERROR(
"Default constructor not in use");
51 NodeContainer geoNodes,
52 std::vector<std::pair<uint32_t, uint32_t>> isls)
53 : m_geoNodes(geoNodes),
56 NS_LOG_FUNCTION(
this);
62 NS_LOG_FUNCTION(
this);
66 for (uint32_t satIndex = 0; satIndex < globalState.size(); satIndex++)
68 Ptr<Node> satelliteNode =
m_geoNodes.Get(satIndex);
69 Ptr<SatGeoNetDevice> satelliteGeoNetDevice;
70 for (uint32_t ndIndex = 0; ndIndex < satelliteNode->GetNDevices(); ndIndex++)
72 Ptr<SatGeoNetDevice> nd =
73 DynamicCast<SatGeoNetDevice>(satelliteNode->GetDevice(ndIndex));
76 satelliteGeoNetDevice = nd;
80 NS_ASSERT_MSG(satelliteGeoNetDevice !=
nullptr,
"SatGeoNetDevice not found on satellite");
82 std::vector<Ptr<PointToPointIslNetDevice>> islNetDevices =
83 satelliteGeoNetDevice->GetIslsNetDevices();
84 Ptr<SatIslArbiterUnicast> arbiter = CreateObject<SatIslArbiterUnicast>(satelliteNode);
86 for (uint32_t islInterfaceIndex = 0; islInterfaceIndex < islNetDevices.size();
89 uint32_t interfaceNextHopNodeId =
90 islNetDevices[islInterfaceIndex]->GetDestinationNode()->GetId();
91 for (std::map<uint32_t, uint32_t>::iterator it = globalState[satIndex].begin();
92 it != globalState[satIndex].end();
95 uint32_t destinationNodeId = it->first;
96 uint32_t nextHopNodeId = it->second;
98 if (interfaceNextHopNodeId == nextHopNodeId)
100 arbiter->AddNextHopEntry(destinationNodeId, islInterfaceIndex);
104 satelliteGeoNetDevice->SetArbiter(arbiter);
111 NS_LOG_FUNCTION(
this);
116 std::vector<std::map<uint32_t, uint32_t>>
119 NS_LOG_FUNCTION(
this);
122 std::vector<std::vector<std::vector<uint32_t>>> globalCandidateList;
133 NS_FATAL_ERROR(
"Cannot handle more than 40000 nodes");
138 int32_t* dist =
new int32_t[n2];
139 for (
int i = 0; i < n; i++)
141 for (
int j = 0; j < n; j++)
149 dist[n * i + j] = 100000000;
155 for (std::pair<uint64_t, uint64_t> edge :
m_isls)
157 dist[n * edge.first + edge.second] = 1;
158 dist[n * edge.second + edge.first] = 1;
162 for (
int k = 0; k < n; k++)
164 for (
int i = 0; i < n; i++)
166 for (
int j = 0; j < n; j++)
168 if (dist[n * i + j] > dist[n * i + k] + dist[n * k + j])
170 dist[n * i + j] = dist[n * i + k] + dist[n * k + j];
181 globalCandidateList.reserve(n);
182 for (
int i = 0; i < n; i++)
184 std::vector<std::vector<uint32_t>> v;
186 for (
int j = 0; j < n; j++)
188 v.push_back(std::vector<uint32_t>());
190 globalCandidateList.push_back(v);
197 for (std::pair<uint64_t, uint64_t> edge :
m_isls)
199 for (
int j = 0; j < n; j++)
201 if (dist[edge.first * n + j] - 1 == dist[edge.second * n + j])
203 globalCandidateList[edge.first][j].push_back(edge.second);
205 if (dist[edge.second * n + j] - 1 == dist[edge.first * n + j])
207 globalCandidateList[edge.second][j].push_back(edge.first);
215 std::vector<std::map<uint32_t, uint32_t>> returnList;
216 for (uint32_t i = 0; i < globalCandidateList.size(); i++)
218 returnList.push_back(std::map<uint32_t, uint32_t>());
219 std::vector<std::vector<uint32_t>> v = globalCandidateList[i];
220 for (uint32_t j = 0; j < v.size(); j++)
224 returnList[i].insert(
225 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.