Skip to content

Commit

Permalink
DELIA-65343 : Updated the trace results (#5410)
Browse files Browse the repository at this point in the history
Updated the trace results
Signed-off-by: kamirt573_comcast <[email protected]>
  • Loading branch information
karuna2git authored Jun 13, 2024
1 parent 00a6207 commit af758c3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 40 deletions.
2 changes: 1 addition & 1 deletion NetworkManager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ find_package(WPEFramework)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)
set(VERSION_PATCH 3)

add_compile_definitions(NETWORKMANAGER_MAJOR_VERSION=${VERSION_MAJOR})
add_compile_definitions(NETWORKMANAGER_MINOR_VERSION=${VERSION_MINOR})
Expand Down
10 changes: 5 additions & 5 deletions NetworkManager/LegacyPlugin_NetworkAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
tmpParameters["guid"] = parameters["guid"];

if (m_networkmanager)
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(5000, _T("Ping"), tmpParameters, response);
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(15000, _T("Ping"), tmpParameters, response);
else
rc = Core::ERROR_UNAVAILABLE;

Expand All @@ -597,12 +597,12 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
LOGINFOMETHOD();
uint32_t rc = Core::ERROR_GENERAL;
JsonObject tmpParameters;
tmpParameters["endpoint"] = parameters["endpoint"].String();
tmpParameters["noOfRequest"] = parameters["packets"].Number();
tmpParameters["guid"] = "";
tmpParameters["endpoint"] = parameters["endpoint"].String();
tmpParameters["packets"] = parameters["packets"].Number();
tmpParameters["guid"] = "";

if(m_networkmanager)
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(5000, _T("Trace"), tmpParameters, response);
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(20000, _T("Trace"), tmpParameters, response);
else
rc = Core::ERROR_UNAVAILABLE;

Expand Down
10 changes: 8 additions & 2 deletions NetworkManager/NetworkManagerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ namespace WPEFramework
uint32_t NetworkManagerImplementation::Trace (const string ipversion /* @in */, const string endpoint /* @in */, const uint32_t noOfRequest /* @in */, const string guid /* @in */, string& response /* @out */)
{
char cmd[256] = "";
string tempResult = "";
if(0 == strcasecmp("IPv6", ipversion.c_str()))
{
snprintf(cmd, 256, "traceroute6 -w 3 -m 6 -q %d %s 64 2>&1", noOfRequest, endpoint.c_str());
Expand All @@ -311,7 +312,12 @@ namespace WPEFramework

NMLOG_INFO ("The Command is %s", cmd);
string commandToExecute(cmd);
executeExternally(NETMGR_TRACE, commandToExecute, response);
executeExternally(NETMGR_TRACE, commandToExecute, tempResult);

JsonObject temp;
temp["target"] = endpoint;
temp["results"] = tempResult;
temp.ToString(response);

return Core::ERROR_NONE;
}
Expand Down Expand Up @@ -427,7 +433,7 @@ namespace WPEFramework
while (!feof(pipe) && fgets(buffer, 1024, pipe) != NULL)
{
// remove newline from buffer
buffer[strcspn(buffer, "\n")] = '\0';
buffer[strcspn(buffer, "\n")] = ' ';
string line(buffer);
list.Add(line);
}
Expand Down
6 changes: 3 additions & 3 deletions NetworkManager/NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,9 @@ namespace WPEFramework
response["ipversion"] = ipversion;
response["success"] = true;

/* TODO :: Cache this public IP Address */
m_publicIPAddress = ipAddress;
m_publicIPAddressType = ipversion;
PublishToThunderAboutInternet();
}
LOGTRACEMETHODFIN();
return rc;
Expand Down Expand Up @@ -661,8 +661,8 @@ namespace WPEFramework
string result{};
const string ipversion = parameters["ipversion"].String();
const string endpoint = parameters["endpoint"].String();
const uint32_t noOfRequest = parameters["noOfRequest"].Number();
const string guid = parameters["guid"].String();
const uint32_t noOfRequest = parameters["packets"].Number();
const string guid = parameters["guid"].String();

if (_NetworkManager)
rc = _NetworkManager->Trace(ipversion, endpoint, noOfRequest, guid, result);
Expand Down
40 changes: 11 additions & 29 deletions docs/api/NetworkManagerPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a name="head.NetworkManager_Plugin"></a>
# NetworkManager Plugin

**Version: [0.2.0]()**
**Version: [0.2.3]()**

A NetworkManager plugin for Thunder framework.

Expand Down Expand Up @@ -1037,29 +1037,21 @@ No Events

### Parameters

| Name | Type | Description |
| :-------- | :-------- | :-------- |
| Name | Type | Description |
| :-------- | :-------- | :-------- |
| params | object | |
| params.endpoint | string | The host name or IP address |
| params.ipversion | string | either IPv4 or IPv6 |
| params.noOfRequest | integer | The number of packets to send. Default is 15 |
| params.guid | string | The globally unique identifier |
| params.ipversion| string | <sup>*(optional)*</sup> The host name or IP address |
| params.endpoint | string | The host name or IP address |
| params.packets | integer | <sup>*(optional)*</sup> The number of packets to send. Default is 10 |
| params.guid | string | <sup>*(optional)*</sup> The globally unique identifier |

### Result

| Name | Type | Description |
| :-------- | :-------- | :-------- |
| result | object | |
| result.target | string | The target IP address |
| result.packetsTransmitted | integer | The number of packets sent |
| result.packetsReceived | integer | The number of packets received |
| result.packetLoss | string | The number of packets lost |
| result.tripMin | string | The minimum amount of time to receive the packets |
| result.tripAvg | string | The average time to receive the packets |
| result.tripMax | string | The maximum amount of time to receive the packets |
| result.tripStdDev | string | The standard deviation for the trip |
| result.error | string | An error message |
| result.guid | string | The globally unique identifier |
| result.results | string | The results from `traceroute` |
| result.success | boolean | Whether the request succeeded |

### Example
Expand All @@ -1073,9 +1065,7 @@ No Events
"method": "org.rdk.NetworkManager.Trace",
"params": {
"endpoint": "45.57.221.20",
"ipversion": "IPv4",
"noOfRequest": 10,
"guid": "..."
"packets": 10
}
}
```
Expand All @@ -1088,16 +1078,8 @@ No Events
"id": 42,
"result": {
"target": "45.57.221.20",
"packetsTransmitted": 10,
"packetsReceived": 10,
"packetLoss": "0.0",
"tripMin": "61.264",
"tripAvg": "130.397",
"tripMax": "230.832",
"tripStdDev": "80.919",
"error": "...",
"guid": "...",
"success": true
"success": true,
"results": "<<<traceroute command results>>>"
}
}
```
Expand Down

0 comments on commit af758c3

Please sign in to comment.