Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Duplicate Fields From JSON Output When Using Multiple Streams #1492

Merged
merged 5 commits into from
Apr 5, 2023

Conversation

manedurphy
Copy link
Contributor

PLEASE NOTE the following text from the iperf3 license. Submitting a
pull request to the iperf3 repository constitutes "[making]
Enhancements available...publicly":

You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to Lawrence Berkeley National
Laboratory, without imposing a separate written license agreement for such
Enhancements, then you hereby grant the following license: a non-exclusive,
royalty-free perpetual license to install, use, modify, prepare derivative
works, incorporate into other computer software, distribute, and sublicense
such enhancements or derivative works thereof, in binary and source code form.

The complete iperf3 license is available in the LICENSE file in the
top directory of the iperf3 source tree.

This issue describes the behavior that these code changes are meant to address in more detail. These changes add conditions for adding specific key-value pairs to the JSON output of a measurement.

We can see that instead of adding the key-value pair every time this function is called, we only add it if the field does not exist.

cJSON *sock_bufsize_item = cJSON_GetObjectItem(test->json_start, "sock_bufsize");
if (sock_bufsize_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "sock_bufsize", test->settings->socket_bufsize);
}

cJSON *sndbuf_actual_item = cJSON_GetObjectItem(test->json_start, "sndbuf_actual");
if (sndbuf_actual_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "sndbuf_actual", sndbuf_actual);
}
    
cJSON *rcvbuf_actual_item = cJSON_GetObjectItem(test->json_start, "rcvbuf_actual");
if (rcvbuf_actual_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "rcvbuf_actual", rcvbuf_actual);
}

Demonstration

You will notice that prior to the changes, the following fields appeared the same number of times as the integer value passed to the --parallel flag, and that after the changes this behavior is no longer seen.

Look for the following fields:

  1. sock_bufsize
  2. sndbuf_actual
  3. rcvbuf_actual

Before changes

Command
iperf3 -c 127.0.0.1 --port 5201 --version4 --omit 1 --time 2 --parallel 3 --reverse --json
Output
{
        "start":        {
                "connected":    [{
                                "socket":       5,
                                "local_host":   "127.0.0.1",
                                "local_port":   47806,
                                "remote_host":  "127.0.0.1",
                                "remote_port":  5201
                        }, {
                                "socket":       7,
                                "local_host":   "127.0.0.1",
                                "local_port":   47808,
                                "remote_host":  "127.0.0.1",
                                "remote_port":  5201
                        }, {
                                "socket":       9,
                                "local_host":   "127.0.0.1",
                                "local_port":   47812,
                                "remote_host":  "127.0.0.1",
                                "remote_port":  5201
                        }],
                "version":      "iperf 3.12",
                "system_info":  "Linux archbox-nexus 6.2.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 13 Mar 2023 17:02:08 +0000 x86_64",
                "timestamp":    {
                        "time": "Sat, 25 Mar 2023 01:43:00 GMT",
                        "timesecs":     1679708580
                },
                "connecting_to":        {
                        "host": "127.0.0.1",
                        "port": 5201
                },
                "cookie":       "hib3f4e2knuxnmnkaar3anxoxnncxfhk32mn",
                "tcp_mss_default":      32768,
                "target_bitrate":       0,
                "sock_bufsize": 0,
                "sndbuf_actual":        16384,
                "rcvbuf_actual":        131072,
                "sock_bufsize": 0,
                "sndbuf_actual":        16384,
                "rcvbuf_actual":        131072,
                "sock_bufsize": 0,
                "sndbuf_actual":        16384,
                "rcvbuf_actual":        131072,
                "test_start":   {
                        "protocol":     "TCP",
                        "num_streams":  3,
                        "blksize":      131072,
                        "omit": 1,
                        "duration":     2,
                        "bytes":        0,
                        "blocks":       0,
                        "reverse":      1,
                        "tos":  0,
                        "target_bitrate":       0
                }
        },
        "intervals":    [{
                        "streams":      [{
                                        "socket":       5,
                                        "start":        0,
                                        "end":  1.000006,
                                        "seconds":      1.0000059604644775,
                                        "bytes":        1599995904,
                                        "bits_per_second":      12799890938.704744,
                                        "omitted":      true,
                                        "sender":       false
                                }, {
                                        "socket":       7,
                                        "start":        0,
                                        "end":  1.000011,
                                        "seconds":      1.0000109672546387,
                                        "bytes":        1599995904,
                                        "bits_per_second":      12799826853.039572,
                                        "omitted":      true,
                                        "sender":       false
                                }, {
                                        "socket":       9,
                                        "start":        0,
                                        "end":  1.000011,
                                        "seconds":      1.0000109672546387,
                                        "bytes":        1599733760,
                                        "bits_per_second":      12797729724.03932,
                                        "omitted":      true,
                                        "sender":       false
                                }],
                        "sum":  {
                                "start":        0,
                                "end":  1.000006,
                                "seconds":      1.0000059604644775,
                                "bytes":        4799725568,
                                "bits_per_second":      38397575676.614159,
                                "omitted":      true,
                                "sender":       false
                        }
                }, {
                        "streams":      [{
                                        "socket":       5,
                                        "start":        3.7e-05,
                                        "end":  0.999969,
                                        "seconds":      1.0000059604644775,
                                        "bytes":        1618477056,
                                        "bits_per_second":      12947739273.459995,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       7,
                                        "start":        3.2e-05,
                                        "end":  0.999974,
                                        "seconds":      1.0000059604644775,
                                        "bytes":        1618477056,
                                        "bits_per_second":      12947739273.459995,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       9,
                                        "start":        3.2e-05,
                                        "end":  0.999975,
                                        "seconds":      1.0000070333480835,
                                        "bytes":        1618542539,
                                        "bits_per_second":      12948249242.456005,
                                        "omitted":      false,
                                        "sender":       false
                                }],
                        "sum":  {
                                "start":        3.7e-05,
                                "end":  0.999969,
                                "seconds":      1.0000059604644775,
                                "bytes":        4855496651,
                                "bits_per_second":      38843741681.257538,
                                "omitted":      false,
                                "sender":       false
                        }
                }, {
                        "streams":      [{
                                        "socket":       5,
                                        "start":        0.999969,
                                        "end":  1.99997,
                                        "seconds":      1.0000009536743164,
                                        "bytes":        1531052032,
                                        "bits_per_second":      12248404575.011139,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       7,
                                        "start":        0.999974,
                                        "end":  1.999973,
                                        "seconds":      0.99999898672103882,
                                        "bytes":        1531052032,
                                        "bits_per_second":      12248428667.075075,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       9,
                                        "start":        0.999975,
                                        "end":  1.999974,
                                        "seconds":      0.99999898672103882,
                                        "bytes":        1531117621,
                                        "bits_per_second":      12248953379.606756,
                                        "omitted":      false,
                                        "sender":       false
                                }],
                        "sum":  {
                                "start":        0.999969,
                                "end":  1.99997,
                                "seconds":      1.0000009536743164,
                                "bytes":        4593221685,
                                "bits_per_second":      36745738436.533012,
                                "omitted":      false,
                                "sender":       false
                        }
                }],
        "end":  {
                "streams":      [{
                                "sender":       {
                                        "socket":       5,
                                        "start":        0,
                                        "end":  1.999225,
                                        "seconds":      1.999225,
                                        "bytes":        3148349440,
                                        "bits_per_second":      12598279593.342421,
                                        "retransmits":  0,
                                        "max_snd_cwnd": 0,
                                        "max_snd_wnd":  0,
                                        "max_rtt":      0,
                                        "min_rtt":      0,
                                        "mean_rtt":     0,
                                        "sender":       false
                                },
                                "receiver":     {
                                        "socket":       5,
                                        "start":        0,
                                        "end":  1.99997,
                                        "seconds":      1.99997,
                                        "bytes":        3149529088,
                                        "bits_per_second":      12598305326.5799,
                                        "sender":       false
                                }
                        }, {
                                "sender":       {
                                        "socket":       7,
                                        "start":        0,
                                        "end":  1.999225,
                                        "seconds":      1.999225,
                                        "bytes":        3148349440,
                                        "bits_per_second":      12598279593.342421,
                                        "retransmits":  0,
                                        "max_snd_cwnd": 0,
                                        "max_snd_wnd":  0,
                                        "max_rtt":      0,
                                        "min_rtt":      0,
                                        "mean_rtt":     0,
                                        "sender":       false
                                },
                                "receiver":     {
                                        "socket":       7,
                                        "start":        0,
                                        "end":  1.99997,
                                        "seconds":      1.99997,
                                        "bytes":        3149529088,
                                        "bits_per_second":      12598305326.5799,
                                        "sender":       false
                                }
                        }, {
                                "sender":       {
                                        "socket":       9,
                                        "start":        0,
                                        "end":  1.999225,
                                        "seconds":      1.999225,
                                        "bytes":        3148349440,
                                        "bits_per_second":      12598279593.342421,
                                        "retransmits":  0,
                                        "max_snd_cwnd": 0,
                                        "max_snd_wnd":  0,
                                        "max_rtt":      0,
                                        "min_rtt":      0,
                                        "mean_rtt":     0,
                                        "sender":       false
                                },
                                "receiver":     {
                                        "socket":       9,
                                        "start":        0,
                                        "end":  1.99997,
                                        "seconds":      1.99997,
                                        "bytes":        3149660160,
                                        "bits_per_second":      12598829622.444336,
                                        "sender":       false
                                }
                        }],
                "sum_sent":     {
                        "start":        0,
                        "end":  1.999225,
                        "seconds":      1.999225,
                        "bytes":        9445048320,
                        "bits_per_second":      37794838780.02726,
                        "retransmits":  0,
                        "sender":       false
                },
                "sum_received": {
                        "start":        0,
                        "end":  1.99997,
                        "seconds":      1.99997,
                        "bytes":        9448718336,
                        "bits_per_second":      37795440275.604134,
                        "sender":       false
                },
                "cpu_utilization_percent":      {
                        "host_total":   67.3395904942367,
                        "host_user":    2.68315242951208,
                        "host_system":  64.656371496822544,
                        "remote_total": 82.8611093519281,
                        "remote_user":  0.6606380390183092,
                        "remote_system":        82.200437981020826
                },
                "sender_tcp_congestion":        "cubic",
                "receiver_tcp_congestion":      "cubic"
        }
}

After changes

Command
iperf3 -c 127.0.0.1 --port 5201 --version4 --omit 1 --time 2 --parallel 3 --reverse --json
Output
{
        "start":        {
                "connected":    [{
                                "socket":       5,
                                "local_host":   "127.0.0.1",
                                "local_port":   49020,
                                "remote_host":  "127.0.0.1",
                                "remote_port":  5201
                        }, {
                                "socket":       7,
                                "local_host":   "127.0.0.1",
                                "local_port":   49028,
                                "remote_host":  "127.0.0.1",
                                "remote_port":  5201
                        }, {
                                "socket":       9,
                                "local_host":   "127.0.0.1",
                                "local_port":   49040,
                                "remote_host":  "127.0.0.1",
                                "remote_port":  5201
                        }],
                "version":      "iperf 3.13",
                "system_info":  "Linux archbox-nexus 6.2.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 13 Mar 2023 17:02:08 +0000 x86_64",
                "timestamp":    {
                        "time": "Sat, 25 Mar 2023 01:44:05 GMT",
                        "timesecs":     1679708645
                },
                "connecting_to":        {
                        "host": "127.0.0.1",
                        "port": 5201
                },
                "cookie":       "27o373zymfrkjlnmfgntstwhztkqmtezmuyp",
                "tcp_mss_default":      32768,
                "target_bitrate":       0,
                "fq_rate":      0,
                "sock_bufsize": 0,
                "sndbuf_actual":        16384,
                "rcvbuf_actual":        131072,
                "test_start":   {
                        "protocol":     "TCP",
                        "num_streams":  3,
                        "blksize":      131072,
                        "omit": 1,
                        "duration":     2,
                        "bytes":        0,
                        "blocks":       0,
                        "reverse":      1,
                        "tos":  0,
                        "target_bitrate":       0,
                        "bidir":        0,
                        "fqrate":       0
                }
        },
        "intervals":    [{
                        "streams":      [{
                                        "socket":       5,
                                        "start":        0,
                                        "end":  1.000006,
                                        "seconds":      1.0000059604644775,
                                        "bytes":        1442709504,
                                        "bits_per_second":      11541607238.66004,
                                        "omitted":      true,
                                        "sender":       false
                                }, {
                                        "socket":       7,
                                        "start":        0,
                                        "end":  1.000017,
                                        "seconds":      1.0000170469284058,
                                        "bytes":        1442578432,
                                        "bits_per_second":      11540430727.103624,
                                        "omitted":      true,
                                        "sender":       false
                                }, {
                                        "socket":       9,
                                        "start":        0,
                                        "end":  1.000018,
                                        "seconds":      1.0000180006027222,
                                        "bytes":        1441267712,
                                        "bits_per_second":      11529934150.235949,
                                        "omitted":      true,
                                        "sender":       false
                                }],
                        "sum":  {
                                "start":        0,
                                "end":  1.000006,
                                "seconds":      1.0000059604644775,
                                "bytes":        4326555648,
                                "bits_per_second":      34612238878.979675,
                                "omitted":      true,
                                "sender":       false
                        }
                }, {
                        "streams":      [{
                                        "socket":       5,
                                        "start":        0.000142,
                                        "end":  1.000003,
                                        "seconds":      1.0001449584960938,
                                        "bytes":        1531969536,
                                        "bits_per_second":      12253979969.49246,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       7,
                                        "start":        0.000131,
                                        "end":  1.000009,
                                        "seconds":      1.0001399517059326,
                                        "bytes":        1532100608,
                                        "bits_per_second":      12255089743.284071,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       9,
                                        "start":        0.00013,
                                        "end":  1.00001,
                                        "seconds":      1.0001399517059326,
                                        "bytes":        1531969536,
                                        "bits_per_second":      12254041314.013535,
                                        "omitted":      false,
                                        "sender":       false
                                }],
                        "sum":  {
                                "start":        0.000142,
                                "end":  1.000003,
                                "seconds":      1.0001449584960938,
                                "bytes":        4596039680,
                                "bits_per_second":      36762988332.499413,
                                "omitted":      false,
                                "sender":       false
                        }
                }, {
                        "streams":      [{
                                        "socket":       5,
                                        "start":        1.000003,
                                        "end":  1.999879,
                                        "seconds":      0.99987602233886719,
                                        "bytes":        1488977920,
                                        "bits_per_second":      11913300343.112911,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       7,
                                        "start":        1.000009,
                                        "end":  1.9999,
                                        "seconds":      0.99989098310470581,
                                        "bytes":        1488977920,
                                        "bits_per_second":      11913122091.583685,
                                        "omitted":      false,
                                        "sender":       false
                                }, {
                                        "socket":       9,
                                        "start":        1.00001,
                                        "end":  1.999902,
                                        "seconds":      0.999891996383667,
                                        "bytes":        1488977920,
                                        "bits_per_second":      11913110018.963821,
                                        "omitted":      false,
                                        "sender":       false
                                }],
                        "sum":  {
                                "start":        1.000003,
                                "end":  1.999879,
                                "seconds":      0.99987602233886719,
                                "bytes":        4466933760,
                                "bits_per_second":      35739901029.338737,
                                "omitted":      false,
                                "sender":       false
                        }
                }],
        "end":  {
                "streams":      [{
                                "sender":       {
                                        "socket":       5,
                                        "start":        0,
                                        "end":  1.999523,
                                        "seconds":      1.999523,
                                        "bytes":        3019898880,
                                        "bits_per_second":      12082477190.810009,
                                        "retransmits":  0,
                                        "max_snd_cwnd": 0,
                                        "max_snd_wnd":  0,
                                        "max_rtt":      0,
                                        "min_rtt":      0,
                                        "mean_rtt":     0,
                                        "sender":       false
                                },
                                "receiver":     {
                                        "socket":       5,
                                        "start":        0,
                                        "end":  1.999879,
                                        "seconds":      1.999879,
                                        "bytes":        3020947456,
                                        "bits_per_second":      12084520937.51672,
                                        "sender":       false
                                }
                        }, {
                                "sender":       {
                                        "socket":       7,
                                        "start":        0,
                                        "end":  1.999523,
                                        "seconds":      1.999523,
                                        "bytes":        3019898880,
                                        "bits_per_second":      12082477190.810009,
                                        "retransmits":  4,
                                        "max_snd_cwnd": 0,
                                        "max_snd_wnd":  0,
                                        "max_rtt":      0,
                                        "min_rtt":      0,
                                        "mean_rtt":     0,
                                        "sender":       false
                                },
                                "receiver":     {
                                        "socket":       7,
                                        "start":        0,
                                        "end":  1.999879,
                                        "seconds":      1.999879,
                                        "bytes":        3021078528,
                                        "bits_per_second":      12085045257.238064,
                                        "sender":       false
                                }
                        }, {
                                "sender":       {
                                        "socket":       9,
                                        "start":        0,
                                        "end":  1.999523,
                                        "seconds":      1.999523,
                                        "bytes":        3019898880,
                                        "bits_per_second":      12082477190.810009,
                                        "retransmits":  0,
                                        "max_snd_cwnd": 0,
                                        "max_snd_wnd":  0,
                                        "max_rtt":      0,
                                        "min_rtt":      0,
                                        "mean_rtt":     0,
                                        "sender":       false
                                },
                                "receiver":     {
                                        "socket":       9,
                                        "start":        0,
                                        "end":  1.999879,
                                        "seconds":      1.999879,
                                        "bytes":        3020947456,
                                        "bits_per_second":      12084520937.51672,
                                        "sender":       false
                                }
                        }],
                "sum_sent":     {
                        "start":        0,
                        "end":  1.999523,
                        "seconds":      1.999523,
                        "bytes":        9059696640,
                        "bits_per_second":      36247431572.430023,
                        "retransmits":  4,
                        "sender":       false
                },
                "sum_received": {
                        "start":        0,
                        "end":  1.999879,
                        "seconds":      1.999879,
                        "bytes":        9062973440,
                        "bits_per_second":      36254087132.2715,
                        "sender":       false
                },
                "cpu_utilization_percent":      {
                        "host_total":   64.976666445853141,
                        "host_user":    3.2559786927151175,
                        "host_system":  61.720587887723312,
                        "remote_total": 83.3516195280562,
                        "remote_user":  0.66310230292736871,
                        "remote_system":        82.688450568282946
                },
                "sender_tcp_congestion":        "cubic",
                "receiver_tcp_congestion":      "cubic"
        }
}

@manedurphy manedurphy changed the title Removed Duplicate Fields From JSON Output When Using Multiple Streams Remove Duplicate Fields From JSON Output When Using Multiple Streams Mar 28, 2023
@bmah888 bmah888 linked an issue Mar 29, 2023 that may be closed by this pull request
@swlars swlars self-requested a review April 3, 2023 23:07
Copy link
Contributor

@swlars swlars left a comment

Choose a reason for hiding this comment

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

Thank you for the pull request!

Is it possible to get the request without the Makefile.in changes? That might create some merge conflicts down the line.

@manedurphy
Copy link
Contributor Author

Thank you for the pull request!

Is it possible to get the request without the Makefile.in changes? That might create some merge conflicts down the line.

Yes, not sure what happened there but I've reverted the changes.

@swlars swlars merged commit 0059c81 into esnet:master Apr 5, 2023
@swlars
Copy link
Contributor

swlars commented Apr 5, 2023

Thanks again for the pull request!

coolshou pushed a commit to coolshou/iperf that referenced this pull request Jul 13, 2023
…snet#1492)

* removed duplicate fields from json output when using multiple streams

* updated functionality for udp

* wip

* fix Makefile.in

* wip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid JSON Output For Measurements With Parallel Streams
2 participants