Skip to content

Commit

Permalink
Initial QoE implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Feb 11, 2025
1 parent 1381be0 commit ce7615f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
11 changes: 3 additions & 8 deletions include/Flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,9 @@ class Flow : public GenericHashEntry {
void updateQUICStats(bool src2dst_direction, const struct timeval *tv,
u_int8_t *payload, u_int16_t payload_len);
void updateUDPTimestamp(bool src2dst_direction, const struct timeval *tv);
u_int8_t computeQoEscore(u_int8_t l4_protocol,
u_int16_t ndpi_protocol,
float live_rtt_average,
float live_rtt_stddev,
float live_rtt_jitter,
float percentage_pkts_ooo,
float percentage_pkts_retransmissions);
void computeQoEscore(u_int8_t *cli_to_srv_qoe, u_int8_t *srv_to_cli_qoe);
u_int8_t computeQoETCPscore(QoELimits *l, bool cli_to_srv);
u_int8_t computeQoEUDPscore(QoELimits *l, bool cli_to_srv);
#endif
void endProtocolDissection();
inline void setCustomApp(custom_app_t ca) {
Expand Down Expand Up @@ -1139,7 +1135,6 @@ inline float get_goodput_bytes_thpt() const { return (goodput_bytes_thpt); };
#if defined(NTOPNG_PRO)
void updateTCPAck(const struct bpf_timeval *when,
bool src2dst_direction, u_int32_t ack_id);
u_int8_t getNetworkQOEScore();

#if !defined(HAVE_NEDGE)
inline void updateProfile() { trafficProfile = iface->getFlowProfile(this); }
Expand Down
4 changes: 4 additions & 0 deletions include/ntop_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1229,4 +1229,8 @@ typedef enum {
core_host_connected_to_non_whitelisted_server
} HostPolicyAlertReason;

typedef struct {
u_int16_t max_rtt, ideal_rtt, max_jitter, ideal_jitter;
} QoELimits;

#endif /* _NTOP_TYPEDEFS_H_ */
6 changes: 6 additions & 0 deletions scripts/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3347,6 +3347,12 @@ local lang = {
["profile_name"] = "Profile Name",
["pseudo_mos"] = "(Pseudo) MOS",
["purge_time"] = "Flow Idle Timeout: %{purge_time} sec <span title='A Flow is purged when no traffic is seen for the time set; to change it jump to the Flow Idle Timeout preferences. To set in combination with nProbe, set -d configuration option in nProbe' style='cursor: help;'><i class='fas fa-question-circle'></i></span> <a href='%{prefs_url}' target='_blank'><i class='fas fa-cog fa-sm'></i></a>",
["qoe"] = "<A class='ntopng-external-link' HREF='https://en.wikipedia.org/wiki/Quality_of_experience'>QoE <i class='fas fa-external-link-alt'></i></A> [ Client->Server / Server ->Client ]",
["qoe_excellent"] = "<span class='badge bg-success'>Excellent (%{value} %%)</span>",
["qoe_good"] = "<span class='badge bg-primary'>Good (%{value} %%)</span>",
["qoe_fair"] = "<span class='badge bg-info'>Acceptable (%{value} %%)</span>",
["qoe_degraded"] = "<span class='badge bg-warning'>Degraded (%{value} %%)</span>",
["qoe_poor"] = "<span class='badge bg-danger'>Poor (%{value} %%)</span>",
["r_factor"] = "R-Factor",
["reach_connection_label"] = "Reach Connection",
["remote_to_remote"] = "Remote Client and Remote Server",
Expand Down
16 changes: 8 additions & 8 deletions scripts/lua/flow_details.lua
Original file line number Diff line number Diff line change
Expand Up @@ -998,14 +998,14 @@ else
print("<tr><th>" .. i18n("download") .. "&nbsp;<i class=\"fas fa-download fa-lg\"></i></th><td><A HREF=\"" ..
url .. "\" download=\"iec104-" .. flow_key .. ".json\">JSON</A></td></tr>")
end

print("<tr><th width=10%>" .. i18n("flow_details.tos") .. "</th>")
print("<td>" .. (dscp_consts.dscp_descr(flow.tos.client.DSCP)) .. " / " ..
(dscp_consts.ecn_descr(flow.tos.client.ECN)) .. "</td>")
print("<td>" .. (dscp_consts.dscp_descr(flow.tos.server.DSCP)) .. " / " ..
(dscp_consts.ecn_descr(flow.tos.server.ECN)) .. "</td>")
print("</tr>")

if((flow.qoe ~= nil) and (flow.qoe.score ~= nil)) then
print("<tr><th width=10%>" .. i18n("flow_details.qoe") .. "</th>")
print("<td>" .. formatQoE(flow.qoe.score.cli_to_srv) .. "</td>")
print("<td>" .. formatQoE(flow.qoe.score.srv_to_cli) .. "</td>")
print("</tr>")
end
if (flow["tcp.nw_latency.3wh_client_rtt"] ~= nil) then
local rtt = flow["tcp.nw_latency.3wh_client_rtt"] + flow["tcp.nw_latency.3wh_server_rtt"]

Expand Down
11 changes: 11 additions & 0 deletions scripts/lua/modules/lua_utils_print.lua
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,20 @@ function print_copy_button(id, data)
print("<script>$('#btn-copy-" .. id .. "').click(function(e) { NtopUtils.copyToClipboard($(this).attr('data'), '" .. i18n('copied') .. "', '" .. i18n('request_failed_message') .. "', $(this));});</script>")
end

-- ##############################################

function formatQoE(value)
if(value > 90) then label = i18n("flow_details.qoe_excellent", { value = value })
elseif(value > 75) then label = i18n("flow_details.qoe_good", { value = value })
elseif(value > 60) then label = i18n("flow_details.qoe_fair", { value = value })
elseif(value > 50) then label = i18n("flow_details.qoe_degraded", { value = value })
else label = i18n("flow_details.qoe_poor", { value = value })
end

return(label)
end

-- ##############################################

if(trace_script_duration ~= nil) then
io.write(debug.getinfo(1,'S').source .." executed in ".. (os.clock()-clock_start)*1000 .. " ms\n")
Expand Down
10 changes: 4 additions & 6 deletions src/Flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2821,12 +2821,6 @@ void Flow::luaScore(lua_State *vm) {
lua_pushstring(vm, "score");
lua_insert(vm, -2);
lua_settable(vm, -3);

/* ***************************************** */

#if defined(NTOPNG_PRO)
lua_get_qoe_score(vm);
#endif
}

/* *************************************** */
Expand Down Expand Up @@ -3162,6 +3156,10 @@ void Flow::lua(lua_State *vm, AddressTree *ptree,

if(riskInfo)
lua_push_str_table_entry(vm, "riskInfo", riskInfo);

#if defined(NTOPNG_PRO)
lua_get_qoe_score(vm);
#endif
}

lua_get_status(vm);
Expand Down

0 comments on commit ce7615f

Please sign in to comment.