Skip to content
This repository was archived by the owner on Sep 7, 2020. It is now read-only.

[agent]: Refactor handlers for AP_METRICS_RESPONSE_MES…#1412

Closed
VladyslavTupikin wants to merge 4 commits intomasterfrom
refactor/ap_link_metrics
Closed

[agent]: Refactor handlers for AP_METRICS_RESPONSE_MES…#1412
VladyslavTupikin wants to merge 4 commits intomasterfrom
refactor/ap_link_metrics

Conversation

@VladyslavTupikin
Copy link
Collaborator

Create new structure sExpectedApMetricsResponse for
saving mid, bssid vector, cmdutx message. Update
current implementation of handle_ap_metrics_query:
clear bssid vector, cmdutx message, save mid, change
sending message to the son_slave on simple forwarding.

Add new structure and member of structure, update
handle_ap_metrics_query method.

…SAGE

Create new structure sExpectedApMetricsResponse for
saving mid, bssid vector, cmdutx message. Update
current implementation of handle_ap_metrics_query:
clear bssid vector, cmdutx message, save mid, change
sending message to the son_slave on simple forwarding.

Add new structure and member of structure, update
handle_ap_metrics_query method.

Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
@VladyslavTupikin VladyslavTupikin self-assigned this Jun 9, 2020
@VladyslavTupikin VladyslavTupikin linked an issue Jun 9, 2020 that may be closed by this pull request
@VladyslavTupikin VladyslavTupikin force-pushed the refactor/ap_link_metrics branch 2 times, most recently from 255dd94 to 6465bd4 Compare June 9, 2020 16:51
According to the issue #1328 need to
do refactoring for the send_slave_ap_metric_query_message
method. This method should create 1 AP_METRICS_QUERY_MESSAGE
with list of bssids instead 1 message per 1 bssid.

Refactored send_slave_ap_metric_query_message, replaced
UINT16_MAX to 0, removed useless commentary.

Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
@VladyslavTupikin VladyslavTupikin force-pushed the refactor/ap_link_metrics branch from 6465bd4 to e19508c Compare June 10, 2020 09:38
According to the refactor issue, need to change the
logic for preparing and sending AP_METRICS_RESPONSE_MESSAGE
to the controller when it was triggered by query.
Need add tlv payload to the response object from
sExpectedApMetricsResponse structure, then after
processing all expected_bssids send response to the
controler.

Update handle_slave_ap_metrics_response according to
the logic described above.

Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
@VladyslavTupikin VladyslavTupikin force-pushed the refactor/ap_link_metrics branch from f57cc52 to afc162d Compare June 10, 2020 14:53
@VladyslavTupikin VladyslavTupikin marked this pull request as ready for review June 10, 2020 14:53
After refactoring need to remove next:

Structures:
  sStaTrafficStats
  sStaLinkMetrics
  sApMetricsQuery
  sApMetrics
  sApMetricsResponse

Objects:
  m_ap_metric_query
  m_ap_metric_response

Also erase all places where that objects
was used.

MAP-4.7.4_ETH_FH24G:netgear-rax40
MAP-4.7.4_ETH_FH5GL:netgear-rax40
MAP-4.7.4_ETH_FH5GH:netgear-rax40
MAP-4.7.5_ETH_FH24G:netgear-rax40
MAP-4.7.5_ETH_FH5GL:netgear-rax40
MAP-4.7.5_ETH_FH5GH:netgear-rax40
MAP-4.7.6_ETH_FH24G:netgear-rax40
MAP-4.7.6_ETH_FH5GL:netgear-rax40
MAP-4.7.6_ETH_FH5GH:netgear-rax40

Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
Copy link
Collaborator

@mariomaz mariomaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully agree with adopted design. Also some of the tests are failing. I'll want to re-review when they pass.

uint16_t length = message_com::get_uds_header(cmdu_rx)->length;
cmdu_rx.swap(); // swap back before forwarding
for (const auto &soc : slaves_sockets) {
if (!message_com::forward_cmdu_to_uds(soc->slave, cmdu_rx, length)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CMDU fails to be forwarded to one slave, backhaul manager will never get the expected response from that slave.
It's pointless forwarding the CMDU to the rest of the slaves, therefore loop should break.

for (const auto &soc : slaves_sockets) {
if (!message_com::forward_cmdu_to_uds(soc->slave, cmdu_rx, length)) {
LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to slave: "
<< tlvf::mac_to_string(soc->radio_mac);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<< tlvf::mac_to_string(soc->radio_mac);
<< soc->radio_mac;

There's no need to convert MAC to string

const sLinkNeighbor &link_neighbor, const sLinkMetrics &link_metrics,
ieee1905_1::eLinkMetricsType link_metrics_type);

struct sExpectedApMetricsResponse {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct sExpectedApMetricsResponse {
struct sApMetricsResponse {

I think we should reconsider the name for this struct, though I'm not happy with this name either. Suggestions are welcome.

ieee1905_1::CmduMessageTx response = {response_buffer, sizeof(response_buffer)};
};

sExpectedApMetricsResponse m_expected_ap_metrics_response;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sExpectedApMetricsResponse m_expected_ap_metrics_response;
sApMetricsResponse m_ap_metrics_response_under_construction;

The same goes for the variable.

if (!message_com::send_cmdu(socket->slave, cmdu_tx)) {
LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to son_slave";
ret = false;
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for continue

}

auto ret = false;
for (auto socket : slaves_sockets) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (auto socket : slaves_sockets) {
for (const auto &socket : slaves_sockets) {

cmdu_rx.swap(); //swap back before forwarding
return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac, length);
if (mid != m_expected_ap_metrics_response.mid) {
LOG(ERROR) << "Received AP_METRICS_RESPONSE_MESSAGE with bad mid=" << std::hex << int(mid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please log expected mid and actual mid

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a "bad" MID.

More importantly: if it's MID 0, it should be forwarded as is, because then it's a channel utlilization treshold crossing (4.7.6). And in fact, I would always forward it if the MID is not the expected MID - it gives us duplicates if we had two parallel events, but as I mentioned dozens of times: that's fine.

if (mid == 0) {
LOG(DEBUG) << "Forward AP_METRICS_RESPONSE_MESSAGE to controller, mid=" << std::hex
<< int(mid);
return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now if mid is equal to 0, it can be either because channel utilization threshold is crossed or because of we are in the middle of a periodic reporting. At this point you don't know it.
However processing of the response should be different in each case: forward as is vs. save response and wait till all slaves have replied.

@arnout arnout assigned RanRegev and unassigned VladyslavTupikin Jun 12, 2020
@arnout arnout added the don't merge This PR is not ready for merge or review label Jun 12, 2020
@arnout
Copy link
Collaborator

arnout commented Jun 12, 2020

I haven't looked at the code, but the current implementation clearly doesn't do the right thing. E.g. the 4.7.5 tests fail because there are still 2 responses being sent (one of which is empty), as can be seen in the pcap file. There should be only one response.

test_flows should verify this. We currently don't have any test flow for 4.7.5 or 4.7.6, so that really should be added.

return false;
}
bssid.push_back(std::get<1>(bssid_tuple));
auto mac = std::get<1>(bssid_tuple);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nitpick) please use bssid for a bssid.

int i = 0;
for (const auto &mac : bssid_list) {
auto list = query->bssid_list(i);
std::get<0>(list) = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong - you have to check the first element of the tuple, not set it.

}
// Save mid and clear previous query
m_expected_ap_metrics_response.mid = mid;
m_expected_ap_metrics_response.expected_bssids.clear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is cleared here, but never set... This should be

Suggested change
m_expected_ap_metrics_response.expected_bssids.clear();
m_expected_ap_metrics_response.expected_bssids = bssid_list;

auto ret = false;
for (auto socket : slaves_sockets) {
if (!message_com::send_cmdu(socket->slave, cmdu_tx)) {
LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to son_slave";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: it's not forwarding, just sending.

cmdu_rx.swap(); //swap back before forwarding
return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac, length);
if (mid != m_expected_ap_metrics_response.mid) {
LOG(ERROR) << "Received AP_METRICS_RESPONSE_MESSAGE with bad mid=" << std::hex << int(mid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a "bad" MID.

More importantly: if it's MID 0, it should be forwarded as is, because then it's a channel utlilization treshold crossing (4.7.6). And in fact, I would always forward it if the MID is not the expected MID - it gives us duplicates if we had two parallel events, but as I mentioned dozens of times: that's fine.

Comment on lines +2588 to 2593
if (mid == 0) {
LOG(DEBUG) << "Forward AP_METRICS_RESPONSE_MESSAGE to controller, mid=" << std::hex
<< int(mid);
return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac,
cmdu_rx.getMessageLength());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire condition should be removed.

@ghost ghost added this to the M3 - Workable product milestone Jun 17, 2020
@RanRegev
Copy link
Collaborator

#1467 replaces this PR.

@RanRegev RanRegev closed this Jun 24, 2020
@mariomaz mariomaz mentioned this pull request Jun 29, 2020
@VladyslavTupikin VladyslavTupikin deleted the refactor/ap_link_metrics branch July 20, 2020 18:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

don't merge This PR is not ready for merge or review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Refactor AP metrics response collection

4 participants