samples: net: zperf: Set the proper UDP payload
Use a static buffer for sending UDP payload instead of reading
values from memory.
Change-Id: I037db5cd9b8784966d481c36e8cbe92d19760475
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
diff --git a/samples/net/zperf/src/zperf_udp_uploader.c b/samples/net/zperf/src/zperf_udp_uploader.c
index 5fb2b86..cdff49d 100644
--- a/samples/net/zperf/src/zperf_udp_uploader.c
+++ b/samples/net/zperf/src/zperf_udp_uploader.c
@@ -17,6 +17,8 @@
#define TAG CMD_STR_UDP_UPLOAD" "
+static char sample_packet[PACKET_SIZE_MAX];
+
static inline void zperf_upload_decode_stat(struct net_buf *buf,
struct zperf_results *results)
{
@@ -117,17 +119,9 @@
sizeof(struct zperf_udp_datagram);
uint16_t pos;
- /* We just need some pointer from where to read
- * data that is placed into the packet that is
- * sent. Other option would be to allocate an
- * array, fill some data into it and send that.
- * Using some pointer here saves memory (currently 1K).
- */
- uint8_t *ptr = (uint8_t *)0;
-
frag = net_nbuf_write(buf, net_buf_frag_last(buf),
- sizeof(struct zperf_udp_datagram),
- &pos, size, ptr);
+ sizeof(struct zperf_udp_datagram),
+ &pos, size, sample_packet);
}
/* Send the packet */
@@ -204,6 +198,8 @@
last_print_time = start_time;
last_loop_time = start_time;
+ memset(sample_packet, 'z', sizeof(sample_packet));
+
do {
struct zperf_udp_datagram datagram;
struct net_buf *buf, *frag;
@@ -266,17 +262,9 @@
sizeof(struct zperf_udp_datagram);
uint16_t pos;
- /* We just need some pointer from where to read
- * data that is placed into the packet that is
- * sent. Other option would be to allocate an
- * array, fill some data into it and send that.
- * Using some pointer here saves memory (currently 1K).
- */
- uint8_t *ptr = (uint8_t *)0;
-
frag = net_nbuf_write(buf, net_buf_frag_last(buf),
- sizeof(struct zperf_udp_datagram),
- &pos, size, ptr);
+ sizeof(struct zperf_udp_datagram),
+ &pos, size, sample_packet);
}
/* Send the packet */