Compare commits

..

No commits in common. "9e16bd8f627fdf7c8034111f12a4bd567762b596" and "d9b4e6591f28044430dcec490e93524080ba260f" have entirely different histories.

5 changed files with 14 additions and 743 deletions

View file

@ -49,12 +49,6 @@ pub const IPerfReturn = struct {
seconds: f128,
bytes: u64,
bits_per_second: f128,
retransmits: ?u64 = null,
snd_cwnd: ?u64 = null,
snd_wnd: ?u64 = null,
rtt: ?u64 = null,
rttvar: ?u64 = null,
pmtu: ?u64 = null,
omitted: bool,
sender: bool,
},
@ -64,7 +58,6 @@ pub const IPerfReturn = struct {
seconds: f128,
bytes: u64,
bits_per_second: f128,
retransmits: ?u64 = null,
omitted: bool,
sender: bool,
},
@ -78,12 +71,6 @@ pub const IPerfReturn = struct {
seconds: f128,
bytes: u64,
bits_per_second: f128,
retransmits: ?u64 = null,
max_snd_cwnd: ?u64 = null,
max_snd_wnd: ?u64 = null,
max_rtt: ?u64 = null,
min_rtt: ?u64 = null,
mean_rtt: ?u64 = null,
sender: bool,
},
receiver: struct {
@ -102,7 +89,6 @@ pub const IPerfReturn = struct {
seconds: f128,
bytes: u64,
bits_per_second: f128,
retransmits: ?u64 = null,
sender: bool,
} = null,
sum_received: ?struct {
@ -122,43 +108,17 @@ pub const IPerfReturn = struct {
remote_system: f128,
} = null,
receiver_tcp_congestion: ?[]const u8 = null,
sender_tcp_congestion: ?[]const u8 = null,
},
@"error": ?[]const u8 = null,
};
test "test-receiver-1" {
const input = @embedFile("test/test-receiver-1.json");
const result = try std.json.parseFromSlice(
IPerfReturn,
std.testing.allocator,
input,
.{},
);
defer result.deinit();
try std.testing.expect(result.value.@"error" == null);
}
test "test-receiver-2" {
const input = @embedFile("test/test-receiver-2.json");
const result = try std.json.parseFromSlice(
IPerfReturn,
std.testing.allocator,
input,
.{},
);
defer result.deinit();
try std.testing.expect(result.value.@"error" == null);
}
test "test-sender-1" {
const input = @embedFile("test/test-sender-1.json");
const result = try std.json.parseFromSlice(
IPerfReturn,
std.testing.allocator,
input,
.{},
);
test "test-normal" {
const input = @embedFile("test/test-normal.json");
const result = try std.json.parseFromSlice(IPerfReturn, std.testing.allocator, input, .{});
defer result.deinit();
// std.debug.print("{}\n", .{result.value});
// const test_output = try std.fs.cwd().createFile("test.json", .{});
// try std.json.stringify(result.value, .{}, test_output.writer());
// test_output.close();
try std.testing.expect(result.value.@"error" == null);
}

View file

@ -127,11 +127,7 @@ pub fn main() !void {
var auth_header_buf: [256]u8 = undefined;
var auth_header = try std.fmt.bufPrint(&auth_header_buf, "Basic {s}", .{auth_encoded});
var url_buf: [256]u8 = undefined;
@memcpy(url_buf, config.value.loki.url);
var url = url_buf[0..config.value.loki.url];
const uri = try std.Uri.parse(url);
const uri = try std.Uri.parse(config.value.loki.url);
var client = std.http.Client{ .allocator = allocator };
defer client.deinit();
@ -144,22 +140,12 @@ pub fn main() !void {
port = try std.fmt.bufPrint(&port_buf, "{d}", .{5201});
}
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var path: []u8 = undefined;
if (config.value.iperf3.path) |p| {
@memcpy(path_buf, p);
path = path_buf[0..p.len];
} else {
@memcpy(path_buf, "iperf3");
path = path_buf[0..6];
}
while (true) {
iperf3_log.info("waiting for connection", .{});
// try stderr_bw.flush();
var c = std.process.Child.init(
&[_][]const u8{
path,
if (config.value.iperf3.path) |path| path else "iperf3",
"--server",
"--port",
port,
@ -222,6 +208,10 @@ pub fn main() !void {
);
defer data.deinit();
// try stderr.writeAll(data.items);
// try stderr.writeAll("\n");
// try stderr_bw.flush();
var content_length_buf: [16]u8 = undefined;
var content_length = try std.fmt.bufPrint(
&content_length_buf,
@ -236,8 +226,6 @@ pub fn main() !void {
try headers.append("Content-Length", content_length);
var req = try client.request(.POST, uri, headers, .{});
defer req.deinit();
try req.start();
try req.writeAll(data.items);
try req.finish();

View file

@ -1,310 +0,0 @@
{
"start": {
"connected": [{
"socket": 5,
"local_host": "127.0.0.1",
"local_port": 5201,
"remote_host": "127.0.0.1",
"remote_port": 43398
}],
"version": "iperf 3.14",
"system_info": "Linux localhost 6.5.5 #1-NixOS SMP PREEMPT_DYNAMIC Sat Sep 23 09:14:39 UTC 2023 x86_64",
"sock_bufsize": 0,
"sndbuf_actual": 16384,
"rcvbuf_actual": 131072,
"timestamp": {
"time": "Sun, 15 Oct 2023 04:15:59 GMT",
"timesecs": 1697343359
},
"accepted_connection": {
"host": "127.0.0.1",
"port": 43384
},
"cookie": "qrmdwiyjmzfojrcbndv2ek6wwjv6ewafzw2n",
"tcp_mss_default": 0,
"target_bitrate": 0,
"fq_rate": 0,
"test_start": {
"protocol": "TCP",
"num_streams": 1,
"blksize": 131072,
"omit": 0,
"duration": 10,
"bytes": 0,
"blocks": 0,
"reverse": 0,
"tos": 0,
"target_bitrate": 0,
"bidir": 0,
"fqrate": 0
}
},
"intervals": [{
"streams": [{
"socket": 5,
"start": 0,
"end": 1.000018,
"seconds": 1.0000180006027222,
"bytes": 7176519627,
"bits_per_second": 57411123581.172585,
"omitted": false,
"sender": false
}],
"sum": {
"start": 0,
"end": 1.000018,
"seconds": 1.0000180006027222,
"bytes": 7176519627,
"bits_per_second": 57411123581.172585,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 1.000018,
"end": 2.000009,
"seconds": 0.999990999698639,
"bytes": 7434141696,
"bits_per_second": 59473668848.942688,
"omitted": false,
"sender": false
}],
"sum": {
"start": 1.000018,
"end": 2.000009,
"seconds": 0.999990999698639,
"bytes": 7434141696,
"bits_per_second": 59473668848.942688,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 2.000009,
"end": 3.000004,
"seconds": 0.999994993209839,
"bytes": 7413039104,
"bits_per_second": 59304609757.736649,
"omitted": false,
"sender": false
}],
"sum": {
"start": 2.000009,
"end": 3.000004,
"seconds": 0.999994993209839,
"bytes": 7413039104,
"bits_per_second": 59304609757.736649,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 3.000004,
"end": 4.000004,
"seconds": 1,
"bytes": 7397703680,
"bits_per_second": 59181629440,
"omitted": false,
"sender": false
}],
"sum": {
"start": 3.000004,
"end": 4.000004,
"seconds": 1,
"bytes": 7397703680,
"bits_per_second": 59181629440,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 4.000004,
"end": 5.000017,
"seconds": 1.000012993812561,
"bytes": 7376601088,
"bits_per_second": 59012041912.588547,
"omitted": false,
"sender": false
}],
"sum": {
"start": 4.000004,
"end": 5.000017,
"seconds": 1.000012993812561,
"bytes": 7376601088,
"bits_per_second": 59012041912.588547,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 5.000017,
"end": 6.000006,
"seconds": 0.99998897314071655,
"bytes": 7419592704,
"bits_per_second": 59357396157.654861,
"omitted": false,
"sender": false
}],
"sum": {
"start": 5.000017,
"end": 6.000006,
"seconds": 0.99998897314071655,
"bytes": 7419592704,
"bits_per_second": 59357396157.654861,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 6.000006,
"end": 7.000011,
"seconds": 1.0000050067901611,
"bytes": 7421427712,
"bits_per_second": 59371124437.238312,
"omitted": false,
"sender": false
}],
"sum": {
"start": 6.000006,
"end": 7.000011,
"seconds": 1.0000050067901611,
"bytes": 7421427712,
"bits_per_second": 59371124437.238312,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 7.000011,
"end": 8.000006,
"seconds": 0.999994993209839,
"bytes": 7382106112,
"bits_per_second": 59057144582.730438,
"omitted": false,
"sender": false
}],
"sum": {
"start": 7.000011,
"end": 8.000006,
"seconds": 0.999994993209839,
"bytes": 7382106112,
"bits_per_second": 59057144582.730438,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 8.000006,
"end": 9.000014,
"seconds": 1.0000079870224,
"bytes": 7378567168,
"bits_per_second": 59028065885.515549,
"omitted": false,
"sender": false
}],
"sum": {
"start": 8.000006,
"end": 9.000014,
"seconds": 1.0000079870224,
"bytes": 7378567168,
"bits_per_second": 59028065885.515549,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 9.000014,
"end": 10.000021,
"seconds": 1.0000070333480835,
"bytes": 7368278069,
"bits_per_second": 58945809965.600449,
"omitted": false,
"sender": false
}],
"sum": {
"start": 9.000014,
"end": 10.000021,
"seconds": 1.0000070333480835,
"bytes": 7368278069,
"bits_per_second": 58945809965.600449,
"omitted": false,
"sender": false
}
}, {
"streams": [{
"socket": 5,
"start": 10.000021,
"end": 10.000122,
"seconds": 0.00010099999781232327,
"bytes": 655360,
"bits_per_second": 51909704094.669815,
"omitted": false,
"sender": false
}],
"sum": {
"start": 10.000021,
"end": 10.000122,
"seconds": 0.00010099999781232327,
"bytes": 655360,
"bits_per_second": 51909704094.669815,
"omitted": false,
"sender": false
}
}],
"end": {
"streams": [{
"sender": {
"socket": 5,
"start": 0,
"end": 10.000122,
"seconds": 10.000122,
"bytes": 0,
"bits_per_second": 0,
"sender": false
},
"receiver": {
"socket": 5,
"start": 0,
"end": 10.000122,
"seconds": 10.000122,
"bytes": 73768632320,
"bits_per_second": 59014185882.932236,
"sender": false
}
}],
"sum_sent": {
"start": 0,
"end": 10.000122,
"seconds": 10.000122,
"bytes": 0,
"bits_per_second": 0,
"sender": false
},
"sum_received": {
"start": 0,
"end": 10.000122,
"seconds": 10.000122,
"bytes": 73768632320,
"bits_per_second": 59014185882.932236,
"sender": false
},
"cpu_utilization_percent": {
"host_total": 88.9689744343579,
"host_user": 3.04800732789741,
"host_system": 85.9209771063205,
"remote_total": 0,
"remote_user": 0,
"remote_system": 0
},
"receiver_tcp_congestion": "cubic"
}
}

View file

@ -1,367 +0,0 @@
{
"start": {
"connected": [{
"socket": 5,
"local_host": "127.0.0.1",
"local_port": 5201,
"remote_host": "127.0.0.1",
"remote_port": 53792
}],
"version": "iperf 3.14",
"system_info": "Linux localhost 6.5.5 #1-NixOS SMP PREEMPT_DYNAMIC Sat Sep 23 09:14:39 UTC 2023 x86_64",
"sock_bufsize": 0,
"sndbuf_actual": 16384,
"rcvbuf_actual": 131072,
"timestamp": {
"time": "Sun, 15 Oct 2023 04:15:28 GMT",
"timesecs": 1697343328
},
"accepted_connection": {
"host": "127.0.0.1",
"port": 53780
},
"cookie": "dwrtd4tteunw6ixmyqwigqrn6axjjesxiavl",
"tcp_mss_default": 0,
"target_bitrate": 0,
"fq_rate": 0,
"test_start": {
"protocol": "TCP",
"num_streams": 1,
"blksize": 131072,
"omit": 0,
"duration": 10,
"bytes": 0,
"blocks": 0,
"reverse": 1,
"tos": 0,
"target_bitrate": 0,
"bidir": 0,
"fqrate": 0
}
},
"intervals": [{
"streams": [{
"socket": 5,
"start": 0,
"end": 1.000502,
"seconds": 1.0005019903182983,
"bytes": 7434403840,
"bits_per_second": 59445389709.898163,
"retransmits": 0,
"snd_cwnd": 1113211,
"snd_wnd": 3144704,
"rtt": 21,
"rttvar": 6,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 0,
"end": 1.000502,
"seconds": 1.0005019903182983,
"bytes": 7434403840,
"bits_per_second": 59445389709.898163,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 1.000502,
"end": 2.000387,
"seconds": 0.99988502264022827,
"bytes": 6927155200,
"bits_per_second": 55423614060.813721,
"retransmits": 0,
"snd_cwnd": 1113211,
"snd_wnd": 3145216,
"rtt": 32,
"rttvar": 1,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 1.000502,
"end": 2.000387,
"seconds": 0.99988502264022827,
"bytes": 6927155200,
"bits_per_second": 55423614060.813721,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 2.000387,
"end": 3.000241,
"seconds": 0.999854028224945,
"bytes": 6613893120,
"bits_per_second": 52918869621.332527,
"retransmits": 0,
"snd_cwnd": 1113211,
"snd_wnd": 3145216,
"rtt": 31,
"rttvar": 3,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 2.000387,
"end": 3.000241,
"seconds": 0.999854028224945,
"bytes": 6613893120,
"bits_per_second": 52918869621.332527,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 3.000241,
"end": 4.000234,
"seconds": 0.99999302625656128,
"bytes": 7197163520,
"bits_per_second": 57577709692.175186,
"retransmits": 0,
"snd_cwnd": 1178694,
"snd_wnd": 3145216,
"rtt": 22,
"rttvar": 5,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 3.000241,
"end": 4.000234,
"seconds": 0.99999302625656128,
"bytes": 7197163520,
"bits_per_second": 57577709692.175186,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 4.000234,
"end": 5.000321,
"seconds": 1.0000870227813721,
"bytes": 7333478400,
"bits_per_second": 58662722206.7507,
"retransmits": 0,
"snd_cwnd": 1309660,
"snd_wnd": 3145216,
"rtt": 25,
"rttvar": 4,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 4.000234,
"end": 5.000321,
"seconds": 1.0000870227813721,
"bytes": 7333478400,
"bits_per_second": 58662722206.7507,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 5.000321,
"end": 6.000227,
"seconds": 0.99990600347518921,
"bytes": 7186677760,
"bits_per_second": 57498826769.897064,
"retransmits": 0,
"snd_cwnd": 1309660,
"snd_wnd": 3145216,
"rtt": 25,
"rttvar": 3,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 5.000321,
"end": 6.000227,
"seconds": 0.99990600347518921,
"bytes": 7186677760,
"bits_per_second": 57498826769.897064,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 6.000227,
"end": 7.000188,
"seconds": 0.999961018562317,
"bytes": 7287603200,
"bits_per_second": 58303098338.59462,
"retransmits": 0,
"snd_cwnd": 1375143,
"snd_wnd": 3145216,
"rtt": 25,
"rttvar": 4,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 6.000227,
"end": 7.000188,
"seconds": 0.999961018562317,
"bytes": 7287603200,
"bits_per_second": 58303098338.59462,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 7.000188,
"end": 8.000201,
"seconds": 1.000012993812561,
"bytes": 6805258240,
"bits_per_second": 54441358519.191833,
"retransmits": 0,
"snd_cwnd": 1899007,
"snd_wnd": 3145216,
"rtt": 30,
"rttvar": 2,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 7.000188,
"end": 8.000201,
"seconds": 1.000012993812561,
"bytes": 6805258240,
"bits_per_second": 54441358519.191833,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 8.000201,
"end": 9.000234,
"seconds": 1.0000330209732056,
"bytes": 6675496960,
"bits_per_second": 53402212286.978951,
"retransmits": 0,
"snd_cwnd": 1899007,
"snd_wnd": 3145216,
"rtt": 29,
"rttvar": 2,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 8.000201,
"end": 9.000234,
"seconds": 1.0000330209732056,
"bytes": 6675496960,
"bits_per_second": 53402212286.978951,
"retransmits": 0,
"omitted": false,
"sender": true
}
}, {
"streams": [{
"socket": 5,
"start": 9.000234,
"end": 10.000062,
"seconds": 0.99982798099517822,
"bytes": 6758072320,
"bits_per_second": 54073880295.0752,
"retransmits": 0,
"snd_cwnd": 1899007,
"snd_wnd": 3145216,
"rtt": 27,
"rttvar": 1,
"pmtu": 65535,
"omitted": false,
"sender": true
}],
"sum": {
"start": 9.000234,
"end": 10.000062,
"seconds": 0.99982798099517822,
"bytes": 6758072320,
"bits_per_second": 54073880295.0752,
"retransmits": 0,
"omitted": false,
"sender": true
}
}],
"end": {
"streams": [{
"sender": {
"socket": 5,
"start": 0,
"end": 10.000062,
"seconds": 10.000062,
"bytes": 70219202560,
"bits_per_second": 56175013762.914673,
"retransmits": 0,
"max_snd_cwnd": 1899007,
"max_snd_wnd": 3145216,
"max_rtt": 32,
"min_rtt": 21,
"mean_rtt": 26,
"sender": true
},
"receiver": {
"socket": 5,
"start": 0,
"end": 10.000062,
"seconds": 10.000062,
"bytes": 0,
"bits_per_second": 0,
"sender": true
}
}],
"sum_sent": {
"start": 0,
"end": 10.000062,
"seconds": 10.000062,
"bytes": 70219202560,
"bits_per_second": 56175013762.914673,
"retransmits": 0,
"sender": true
},
"sum_received": {
"start": 0,
"end": 10.000062,
"seconds": 10.000062,
"bytes": 0,
"bits_per_second": 0,
"sender": true
},
"cpu_utilization_percent": {
"host_total": 99.994360043427662,
"host_user": 1.1998407612261386,
"host_system": 98.794509282278526,
"remote_total": 0,
"remote_user": 0,
"remote_system": 0
},
"sender_tcp_congestion": "cubic"
}
}