26 #include <ns3/address.h>
32 NS_LOG_COMPONENT_DEFINE(
"SatIdMapper");
37 NS_OBJECT_ENSURE_REGISTERED(SatIdMapper);
43 TypeId(
"ns3::SatIdMapper").SetParent<Object>().AddConstructor<SatIdMapper>();
52 m_enableMapPrint(false)
54 NS_LOG_FUNCTION(
this);
59 NS_LOG_FUNCTION(
this);
67 NS_LOG_FUNCTION(
this);
77 NS_LOG_FUNCTION(
this);
157 std::cout <<
"SatIdMapper GW/UT MAC to satellite ID map" << std::endl;
158 std::map<Mac48Address, uint32_t>::iterator it;
161 std::cout << it->first <<
" " << it->second << std::endl;
163 std::cout << std::endl;
171 NS_LOG_FUNCTION(
this);
175 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToTraceId =
178 if (resultMacToTraceId.second ==
false)
180 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToTraceId - MAC to Trace ID failed. MAC "
184 NS_LOG_INFO(
"Added MAC " << mac <<
" with Trace ID " <<
m_traceIdIndex);
193 NS_LOG_FUNCTION(
this);
196 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToUtId =
199 if (resultMacToUtId.second ==
false)
201 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToUtId - MAC to UT ID failed");
204 NS_LOG_INFO(
"Added MAC " << mac <<
" with UT ID " <<
m_utIdIndex);
213 NS_LOG_FUNCTION(
this);
216 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToUtUserId =
219 if (resultMacToUtUserId.second ==
false)
221 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToUtUserId - MAC to UT user ID failed");
224 NS_LOG_INFO(
"Added MAC " << mac <<
" with UT user ID " <<
m_utUserIdIndex);
233 NS_LOG_FUNCTION(
this);
235 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToSatId =
238 if (resultMacToSatId.second ==
false)
240 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToSatId - MAC to sat ID failed");
243 NS_LOG_INFO(
"Added MAC " << mac <<
" with sat ID " << satId);
249 NS_LOG_FUNCTION(
this);
251 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToBeamId =
254 if (resultMacToBeamId.second ==
false)
256 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToBeamId - MAC to beam ID failed");
259 NS_LOG_INFO(
"Added MAC " << mac <<
" with beam ID " << beamId);
265 NS_LOG_FUNCTION(
this);
267 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToGroupId =
270 if (resultMacToGroupId.second ==
false)
272 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToGroupId - MAC to group ID failed");
275 NS_LOG_INFO(
"Added MAC " << mac <<
" with group ID " << groupId);
281 NS_LOG_FUNCTION(
this);
283 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToGwId =
286 if (resultMacToGwId.second ==
false)
288 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToGwId - MAC to GW ID failed");
291 NS_LOG_INFO(
"Added MAC " << mac <<
" with GW ID " << gwId);
297 NS_LOG_FUNCTION(
this);
300 std::pair<std::map<Address, uint32_t>::iterator,
bool> resultMacToGwUserId =
303 if (resultMacToGwUserId.second ==
false)
305 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToGwUserId - MAC to GW user ID failed");
308 NS_LOG_INFO(
"Added MAC " << mac <<
" with GW user ID " <<
m_gwUserIdIndex);
317 NS_LOG_FUNCTION(
this << mac << satId);
319 std::pair<std::map<Mac48Address, uint32_t>::iterator,
bool> resultMacToSatId =
322 if (resultMacToSatId.second ==
false)
324 NS_FATAL_ERROR(
"SatIdMapper::AttachMacToSatIdIsl - MAC to sat ID failed");
327 NS_LOG_INFO(
"Added MAC " << mac <<
" with sat ISL ID " << satId);
333 NS_LOG_FUNCTION(
this << mac);
337 NS_FATAL_ERROR(
"SatIdMapper::RemoveMacToSatIdIsl - MAC " << mac <<
" not in map");
340 NS_LOG_INFO(
"Removed MAC " << mac <<
" from ISL IDs");
348 NS_LOG_FUNCTION(
this);
363 NS_LOG_FUNCTION(
this);
365 std::map<Address, uint32_t>::const_iterator iter =
m_macToUtIdMap.find(mac);
378 NS_LOG_FUNCTION(
this);
393 NS_LOG_FUNCTION(
this);
395 std::map<Address, uint32_t>::const_iterator iter =
m_macToSatIdMap.find(mac);
408 NS_LOG_FUNCTION(
this);
410 std::map<Address, uint32_t>::const_iterator iter =
m_macToBeamIdMap.find(mac);
423 NS_LOG_FUNCTION(
this);
438 NS_LOG_FUNCTION(
this);
440 std::map<Address, uint32_t>::const_iterator iter =
m_macToGwIdMap.find(mac);
453 NS_LOG_FUNCTION(
this);
468 NS_LOG_FUNCTION(
this);
485 NS_LOG_FUNCTION(
this << gwNode->GetId());
487 if (gwNode->GetNDevices() >= 3)
494 Ptr<NetDevice> dev = gwNode->GetDevice(1);
498 if (Mac48Address::IsMatchingType(dev->GetAddress()))
500 return dev->GetAddress();
504 NS_LOG_WARN(
this <<
" Device 1 of Node " << gwNode->GetId()
505 <<
" is not have a valid Mac48Address");
511 NS_LOG_WARN(
this <<
" Node " << gwNode->GetId() <<
" is not a valid GW");
517 NS_LOG_WARN(
this <<
" Node " << gwNode->GetId() <<
" is not a valid GW");
525 NS_LOG_FUNCTION(
this << satNode->GetId());
527 if (satNode->GetNDevices() >= 1)
529 Ptr<NetDevice> dev = satNode->GetDevice(0);
533 if (Mac48Address::IsMatchingType(dev->GetAddress()))
535 return dev->GetAddress();
539 NS_LOG_WARN(
this <<
" Device 0 of Node " << satNode->GetId()
540 <<
" does not have a valid Mac48Address");
546 NS_LOG_WARN(
this <<
" Node " << satNode->GetId() <<
" is not a valid SAT");
552 NS_LOG_WARN(
this <<
" Node " << satNode->GetId() <<
" is not a valid SAT");
560 NS_LOG_FUNCTION(
this << utNode->GetId());
562 if (utNode->GetNDevices() >= 3)
568 Ptr<NetDevice> dev = utNode->GetDevice(2);
572 if (Mac48Address::IsMatchingType(dev->GetAddress()))
574 return dev->GetAddress();
578 NS_LOG_WARN(
this <<
" Device 2 of Node " << utNode->GetId()
579 <<
" is not have a valid Mac48Address");
585 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
591 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
599 NS_LOG_FUNCTION(
this << utUserNode->GetId());
601 if (utUserNode->GetNDevices() >= 2)
607 Ptr<NetDevice> dev = utUserNode->GetDevice(1);
608 NS_ASSERT(dev !=
nullptr);
610 if (Mac48Address::IsMatchingType(dev->GetAddress()))
612 return dev->GetAddress();
616 NS_LOG_WARN(
this <<
" Device 1 of Node " << utUserNode->GetId()
617 <<
" is not have a valid Mac48Address");
623 NS_LOG_WARN(
this <<
" Node " << utUserNode->GetId() <<
" is not a valid UT user");
631 NS_LOG_FUNCTION(
this);
633 std::stringstream out;
634 bool isInMap =
false;
638 std::map<Address, uint32_t>::const_iterator iterTrace =
m_macToTraceIdMap.find(mac);
642 out <<
"trace ID: " << iterTrace->second <<
" ";
646 std::map<Address, uint32_t>::const_iterator iterSat =
m_macToSatIdMap.find(mac);
650 out <<
"sat ID: " << iterSat->second <<
" ";
654 std::map<Address, uint32_t>::const_iterator iterBeam =
m_macToBeamIdMap.find(mac);
658 out <<
"beam ID: " << iterBeam->second <<
" ";
662 std::map<Address, uint32_t>::const_iterator iterGroup =
m_macToGroupIdMap.find(mac);
666 out <<
"beam ID: " << iterGroup->second <<
" ";
670 std::map<Address, uint32_t>::const_iterator iterUt =
m_macToUtIdMap.find(mac);
674 out <<
"UT ID: " << iterUt->second <<
" ";
678 std::map<Address, uint32_t>::const_iterator iterGw =
m_macToGwIdMap.find(mac);
682 out <<
"GW ID: " << iterGw->second <<
" ";
686 std::string infoString = out.str();
691 out <<
"not found in the mapper";
692 infoString = out.str();
701 NS_LOG_FUNCTION(
this);
703 std::map<Address, uint32_t>::const_iterator iter;
707 std::cout <<
GetMacInfo(iter->first) << std::endl;
SatGeoNetDevice to be utilized in geostationary satellite.
void Reset()
Function for resetting the variables.
int32_t GetTraceIdWithMac(Address mac) const
Function for getting the trace ID with MAC.
std::map< Mac48Address, uint32_t > m_macToSatIdIslMap
Map for GW/UT MAC to associated SAT ID conversion.
~SatIdMapper()
Destructor.
int32_t GetBeamIdWithMac(Address mac) const
Function for getting the beam ID with MAC.
std::map< Address, uint32_t > m_macToGroupIdMap
Map for MAC to group ID conversion.
uint32_t m_utUserIdIndex
Running UT user index number.
SatIdMapper()
Constructor.
int32_t GetUtUserIdWithMac(Address mac) const
Function for getting the UT user ID with MAC.
bool m_enableMapPrint
Is map printing enabled or not.
int32_t GetSatIdWithMac(Address mac) const
Function for getting the SAT ID with MAC.
uint32_t AttachMacToTraceId(Address mac)
Attach MAC address to the Trace ID maps and give it a running trace ID (starting from 1)
uint32_t AttachMacToGwUserId(Address mac)
Attach MAC address to the GW user ID maps and give it a running GW user ID (starting from 1)
std::map< Address, uint32_t > m_macToSatIdMap
Map for MAC to SAT ID conversion.
void PrintTraceMap() const
Function for printing out the trace map.
void ShowIslMap()
Print the map GW/UT address to satellite ID.
std::string GetMacInfo(Address mac) const
Function for getting the IDs related to a MAC address in an info string.
Address GetSatMacWithNode(Ptr< Node > satNode) const
uint32_t AttachMacToUtUserId(Address mac)
Attach MAC address to the UT user ID maps and give it a running UT user ID (starting from 1)
std::map< Address, uint32_t > m_macToBeamIdMap
Map for MAC to beam ID conversion.
std::map< Address, uint32_t > m_macToUtUserIdMap
Map for MAC to UT user ID conversion.
uint32_t m_utIdIndex
Running UT index number.
uint32_t m_traceIdIndex
Running trace index number.
void AttachMacToGwId(Address mac, uint32_t gwId)
Attach MAC address to the GW ID maps.
void RemoveMacToSatIdIsl(Mac48Address mac)
Remove GW/UT MAC address to the satellite this node is connected.
uint32_t m_gwUserIdIndex
Running GW user index number.
std::map< Address, uint32_t > m_macToTraceIdMap
Map for MAC to trace ID conversion.
int32_t GetGwIdWithMac(Address mac) const
Function for getting the GW ID with MAC.
std::map< Address, uint32_t > m_macToGwUserIdMap
Map for MAC to GW user ID conversion.
void AttachMacToBeamId(Address mac, uint32_t beamId)
Attach MAC address to the beam ID maps.
void AttachMacToSatId(Address mac, uint32_t satId)
Attach MAC address to the SAT ID maps and give it a running SAT ID (starting from 1)
static TypeId GetTypeId(void)
NS-3 type id function.
void DoDispose()
Do needed dispose actions.
std::map< Address, uint32_t > m_macToUtIdMap
Map for MAC to UT ID conversion.
int32_t GetSatIdWithMacIsl(Mac48Address mac) const
Function for getting the satellite ID connected to a GW/UT MAC address.
int32_t GetUtIdWithMac(Address mac) const
Function for getting the UT ID with MAC.
Address GetGwMacWithNode(Ptr< Node > gwNode) const
void AttachMacToSatIdIsl(Mac48Address mac, uint32_t satId)
Attach GW/UT MAC address to the satellite this node is connected.
std::map< Address, uint32_t > m_macToGwIdMap
Map for MAC to GW ID conversion.
uint32_t AttachMacToUtId(Address mac)
Attach MAC address to the UT ID maps and give it a running UT ID (starting from 1)
void AttachMacToGroupId(Address mac, uint32_t groupId)
Attach MAC address to the group ID maps.
int32_t GetGwUserIdWithMac(Address mac) const
Function for getting the GW user ID with MAC.
Address GetUtMacWithNode(Ptr< Node > utNode) const
Address GetUtUserMacWithNode(Ptr< Node > utUserNode) const
int32_t GetGroupIdWithMac(Address mac) const
Function for getting the group ID with MAC.
SatNetDevice to be utilized in the UT and GW nodes.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.