131 std::istringstream iss(routingTable);
132 std::ostringstream oss;
135 while (std::getline(iss, line))
137 if (line.find(
"Node: 0") != std::string::npos)
139 oss << line << std::endl;
140 std::getline(iss, line);
141 oss << line << std::endl;
143 std::vector<std::string> standardRoutes;
144 std::vector<std::pair<int, std::string>> hostRoutes;
146 while (std::getline(iss, line) && !line.empty())
148 if (line.find(
"2001::200:ff:fe00:") != std::string::npos)
150 std::regex hexPattern(
"2001::200:ff:fe00:([0-9a-f]+)/128");
153 if (std::regex_search(line, match, hexPattern))
155 int hexValue = std::stoi(match[1].str(),
nullptr, 16);
156 hostRoutes.emplace_back(hexValue, line);
161 standardRoutes.push_back(line);
165 for (
const auto& route : standardRoutes)
167 oss << route << std::endl;
170 std::sort(hostRoutes.begin(),
172 [](
const std::pair<int, std::string>& a,
173 const std::pair<int, std::string>& b) { return a.first < b.first; });
175 for (
const auto& route : hostRoutes)
177 oss << route.second << std::endl;
184 oss << line << std::endl;
185 if (line.find(
"Node:") != std::string::npos)
187 while (std::getline(iss, line))
189 oss << line << std::endl;
static std::string NodeHeader(uint32_t nodeId, Time time, const std::string &protocol)
Format a node/time/protocol header line as printed by ns-3 routing helpers.