neels has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36539?usp=email )
Change subject: nft_kpi: add rate_ctr gtpu:ue_bytes:ul,dl
......................................................................
nft_kpi: add rate_ctr gtpu:ue_bytes:ul,dl
So far we have the nftables based counters for total GTP-U bytes (UL,
DL), as well as a packet count.
Add another counter for the computed UE payload bytes:
total_bytes - packets * (20 + 8 + 8)
Related: SYS#6773
Change-Id: Ib2f0a9252715ea4b2fe9c367aa65f771357768ca
---
M include/osmocom/hnbgw/hnbgw.h
M include/osmocom/hnbgw/nft_kpi.h
M src/osmo-hnbgw/hnbgw.c
M src/osmo-hnbgw/nft_kpi.c
4 files changed, 46 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/39/36539/1
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index d323bdf..c9142e9 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -139,8 +139,10 @@
HNB_CTR_GTPU_PACKETS_UL,
HNB_CTR_GTPU_TOTAL_BYTES_UL,
+ HNB_CTR_GTPU_UE_BYTES_UL,
HNB_CTR_GTPU_PACKETS_DL,
HNB_CTR_GTPU_TOTAL_BYTES_DL,
+ HNB_CTR_GTPU_UE_BYTES_DL,
};
enum hnb_stat {
diff --git a/include/osmocom/hnbgw/nft_kpi.h b/include/osmocom/hnbgw/nft_kpi.h
index 95304ce..7b3153d 100644
--- a/include/osmocom/hnbgw/nft_kpi.h
+++ b/include/osmocom/hnbgw/nft_kpi.h
@@ -6,7 +6,8 @@
struct nft_kpi_val {
uint64_t packets;
- uint64_t bytes;
+ uint64_t total_bytes;
+ uint64_t ue_bytes;
bool handle_present;
int64_t handle;
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index a3ea265..6340d10 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -468,6 +468,10 @@
"gtpu:total_bytes:ul",
"Count of total GTP-U bytes received from the HNB, including the GTP-U/UDP/IP
headers",
},
+ [HNB_CTR_GTPU_UE_BYTES_UL] = {
+ "gtpu:ue_bytes:ul",
+ "Assuming an IP header length of 20 bytes, GTP-U bytes received from the HNB,
excluding the GTP-U/UDP/IP headers",
+ },
[HNB_CTR_GTPU_PACKETS_DL] = {
"gtpu:packets:dl",
"Count of GTP-U packets sent to the HNB",
@@ -476,6 +480,10 @@
"gtpu:total_bytes:dl",
"Count of total GTP-U bytes sent to the HNB, including the GTP-U/UDP/IP
headers",
},
+ [HNB_CTR_GTPU_UE_BYTES_DL] = {
+ "gtpu:ue_bytes:dl",
+ "Assuming an IP header length of 20 bytes, GTP-U bytes sent to the HNB, excluding
the GTP-U/UDP/IP headers",
+ },
};
diff --git a/src/osmo-hnbgw/nft_kpi.c b/src/osmo-hnbgw/nft_kpi.c
index 2eb5496..f585415 100644
--- a/src/osmo-hnbgw/nft_kpi.c
+++ b/src/osmo-hnbgw/nft_kpi.c
@@ -268,7 +268,24 @@
&val->packets, packets);
update_ctr(hnbp->ctrs,
ul ? HNB_CTR_GTPU_TOTAL_BYTES_UL : HNB_CTR_GTPU_TOTAL_BYTES_DL,
- &val->bytes, bytes);
+ &val->total_bytes, bytes);
+
+ LOGP(DLGLOBAL, LOGL_ERROR, "XXX %s(): packets=%ld btes=%ld ueb=%ld\n",
__func__,
+ packets, bytes, bytes - packets * 36);
+
+ /* Assuming an IP header of 20 bytes, derive the GTP-U payload size:
+ *
+ * [...] \ \
+ * [ UDP ][ TCP ] | UE payload | nft reports these bytes
+ * [ IP ] / |
+ * -- payload -- |
+ * [ GTP-U 8 bytes ] | \
+ * [ UDP 8 bytes ] | | need to subtract these, ~20 + 8 + 8
+ * [ IP 20 bytes ] / /
+ */
+ update_ctr(hnbp->ctrs,
+ ul ? HNB_CTR_GTPU_UE_BYTES_UL : HNB_CTR_GTPU_UE_BYTES_DL,
+ &val->ue_bytes, bytes - OSMO_MIN(bytes, packets * (20 + 8 + 8)));
}
/* In the string section *pos .. end, find the first occurrence of after_str and return
the following token, which ends
--
To view, visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36539?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Ib2f0a9252715ea4b2fe9c367aa65f771357768ca
Gerrit-Change-Number: 36539
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange