Skip to content

Commit 5e79f4a

Browse files
authored
Merge pull request #1837 from private-octopus/add-ns-suspension
Simulate link variation in picoquic_ns
2 parents ce01a62 + 834db2e commit 5e79f4a

File tree

8 files changed

+551
-13
lines changed

8 files changed

+551
-13
lines changed

UnitTest1/unittest1.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,55 @@ namespace UnitTest1
20282028
Assert::AreEqual(ret, 0);
20292029
}
20302030

2031+
TEST_METHOD(cc_ns_asym)
2032+
{
2033+
int ret = cc_ns_asym_test();
2034+
2035+
Assert::AreEqual(ret, 0);
2036+
}
2037+
2038+
TEST_METHOD(cc_ns_blackhole)
2039+
{
2040+
int ret = cc_ns_blackhole_test();
2041+
2042+
Assert::AreEqual(ret, 0);
2043+
}
2044+
2045+
TEST_METHOD(cc_ns_drop_and_back)
2046+
{
2047+
int ret = cc_ns_drop_and_back_test();
2048+
2049+
Assert::AreEqual(ret, 0);
2050+
}
2051+
2052+
TEST_METHOD(cc_ns_low_and_up)
2053+
{
2054+
int ret = cc_ns_low_and_up_test();
2055+
2056+
Assert::AreEqual(ret, 0);
2057+
}
2058+
2059+
TEST_METHOD(cc_ns_wifi_fade)
2060+
{
2061+
int ret = cc_ns_wifi_fade_test();
2062+
2063+
Assert::AreEqual(ret, 0);
2064+
}
2065+
2066+
TEST_METHOD(cc_ns_wifi_suspension)
2067+
{
2068+
int ret = cc_ns_wifi_suspension_test();
2069+
2070+
Assert::AreEqual(ret, 0);
2071+
}
2072+
2073+
TEST_METHOD(cc_ns_varylink)
2074+
{
2075+
int ret = cc_ns_varylink_test();
2076+
2077+
Assert::AreEqual(ret, 0);
2078+
}
2079+
20312080
TEST_METHOD(fastcc)
20322081
{
20332082
int ret = fastcc_test();

picohttp_t/picohttp_t.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ static const picoquic_test_def_t test_table[] = {
110110
{ "quicperf_overflow", quicperf_overflow_test },
111111
{ "cc_compete_cubic2", cc_compete_cubic2_test },
112112
{ "cc_compete_prague2", cc_compete_prague2_test },
113-
{ "cc_compete_d_cubic", cc_compete_d_cubic_test }
113+
{ "cc_compete_d_cubic", cc_compete_d_cubic_test },
114+
{ "cc_ns_asym", cc_ns_asym_test },
115+
{ "cc_ns_blackhole", cc_ns_blackhole_test },
116+
{ "cc_ns_drop_and_back", cc_ns_drop_and_back_test },
117+
{ "cc_ns_low_and_up", cc_ns_low_and_up_test },
118+
{ "cc_ns_wifi_fade", cc_ns_wifi_fade_test },
119+
{ "cc_ns_wifi_suspension", cc_ns_wifi_suspension_test },
120+
{ "cc_ns_varylink", cc_ns_varylink_test }
114121
};
115122

116123
static size_t const nb_tests = sizeof(test_table) / sizeof(picoquic_test_def_t);

picoquic/picoquic_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ typedef struct st_picoquictest_sim_link_t {
296296
/* Variable for multipath simulation */
297297
int is_switched_off;
298298
int is_unreachable;
299+
/* variable for simulating suspension */
300+
int is_suspended;
299301
} picoquictest_sim_link_t;
300302

301303
picoquictest_sim_link_t* picoquictest_sim_link_create(double data_rate_in_gps,

picoquic/sim_link.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ void picoquictest_sim_link_submit(picoquictest_sim_link_t* link, picoquictest_si
159159
if (transmit_time <= 0)
160160
transmit_time = 1;
161161

162+
if (link->is_suspended) {
163+
packet->arrival_time = UINT64_MAX;
164+
if (link->last_packet == NULL) {
165+
link->first_packet = packet;
166+
}
167+
else {
168+
link->last_packet->next_packet = packet;
169+
}
170+
link->last_packet = packet;
171+
return;
172+
}
173+
162174
if (link->bucket_increase_per_microsec > 0) {
163175
/* Simulate a rate limiter based on classic leaky bucket algorithm */
164176
uint64_t delta_microsec = current_time - link->bucket_arrival_last;

picoquictest/cc_compete_test.c

Lines changed: 182 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,191 @@ int cc_compete_d_cubic_test()
114114
spec.background_start_time = 0;
115115
spec.background_scenario_text = cc_compete_batch_scenario_10M;
116116
spec.nb_connections = 2;
117-
spec.main_target_time = 10000000;
117+
spec.main_target_time = 8500000;
118118
spec.data_rate_in_gbps = 0.02;
119119
spec.latency = 40000;
120120
spec.icid = icid;
121121
spec.qlog_dir = ".";
122122

123123
return picoquic_ns(&spec);
124-
}
124+
}
125+
126+
/* Check that the picoquic_ns simulations can correctly test asymmetric paths.
127+
*/
128+
int cc_ns_asym_test()
129+
{
130+
picoquic_ns_spec_t spec = { 0 };
131+
picoquic_connection_id_t icid = { { 0xcc, 0xa5, 0xcb, 0, 0, 0, 0, 0}, 8 };
132+
spec.main_cc_algo = picoquic_cubic_algorithm;
133+
spec.main_start_time = 0;
134+
spec.main_scenario_text = cc_compete_batch_scenario_4M;
135+
spec.background_cc_algo = picoquic_cubic_algorithm;
136+
spec.background_start_time = 0;
137+
spec.background_scenario_text = cc_compete_batch_scenario_10M;
138+
spec.nb_connections = 1;
139+
spec.data_rate_in_gbps = 0.01;
140+
spec.data_rate_up_in_gbps = 0.001;
141+
spec.latency = 300000;
142+
spec.main_target_time = 7000000;
143+
spec.queue_delay_max = 600000;
144+
spec.icid = icid;
145+
spec.qlog_dir = ".";
146+
147+
return picoquic_ns(&spec);
148+
}
149+
150+
/* Check that the picoquic_ns simulations can correctly test the black hole scenario.
151+
*/
152+
int cc_ns_blackhole_test()
153+
{
154+
picoquic_ns_spec_t spec = { 0 };
155+
picoquic_connection_id_t icid = { { 0xcc, 0xb1, 0xcb, 0, 0, 0, 0, 0}, 8 };
156+
spec.main_cc_algo = picoquic_cubic_algorithm;
157+
spec.main_start_time = 0;
158+
spec.main_scenario_text = cc_compete_batch_scenario_4M;
159+
spec.background_cc_algo = picoquic_cubic_algorithm;
160+
spec.background_start_time = 0;
161+
spec.background_scenario_text = cc_compete_batch_scenario_10M;
162+
spec.nb_connections = 1;
163+
spec.data_rate_in_gbps = 0.01;
164+
spec.latency = 40000;
165+
spec.main_target_time = 6000000;
166+
spec.queue_delay_max = 80000;
167+
spec.icid = icid;
168+
spec.qlog_dir = ".";
169+
spec.link_scenario = link_scenario_black_hole;
170+
171+
return picoquic_ns(&spec);
172+
}
173+
174+
/* Check that the picoquic_ns simulations can correctly test the drop_and_back scenario.
175+
*/
176+
int cc_ns_drop_and_back_test()
177+
{
178+
picoquic_ns_spec_t spec = { 0 };
179+
picoquic_connection_id_t icid = { { 0xcc, 0xdb, 0xcb, 0, 0, 0, 0, 0}, 8 };
180+
spec.main_cc_algo = picoquic_cubic_algorithm;
181+
spec.main_start_time = 0;
182+
spec.main_scenario_text = cc_compete_batch_scenario_4M;
183+
spec.background_cc_algo = picoquic_cubic_algorithm;
184+
spec.background_start_time = 0;
185+
spec.background_scenario_text = cc_compete_batch_scenario_10M;
186+
spec.nb_connections = 1;
187+
spec.data_rate_in_gbps = 0.01;
188+
spec.latency = 40000;
189+
spec.main_target_time = 5000000;
190+
spec.queue_delay_max = 80000;
191+
spec.icid = icid;
192+
spec.qlog_dir = ".";
193+
spec.link_scenario = link_scenario_drop_and_back;
194+
195+
return picoquic_ns(&spec);
196+
}
197+
198+
/* Check that the picoquic_ns simulations can correctly test the low_and_up scenario.
199+
*/
200+
int cc_ns_low_and_up_test()
201+
{
202+
picoquic_ns_spec_t spec = { 0 };
203+
picoquic_connection_id_t icid = { { 0xcc, 0x1a, 0xcb, 0, 0, 0, 0, 0}, 8 };
204+
spec.main_cc_algo = picoquic_cubic_algorithm;
205+
spec.main_start_time = 0;
206+
spec.main_scenario_text = cc_compete_batch_scenario_4M;
207+
spec.background_cc_algo = picoquic_cubic_algorithm;
208+
spec.background_start_time = 0;
209+
spec.background_scenario_text = cc_compete_batch_scenario_10M;
210+
spec.nb_connections = 1;
211+
spec.data_rate_in_gbps = 0.01;
212+
spec.latency = 40000;
213+
spec.main_target_time = 5500000;
214+
spec.queue_delay_max = 80000;
215+
spec.icid = icid;
216+
spec.qlog_dir = ".";
217+
spec.link_scenario = link_scenario_low_and_up;
218+
219+
return picoquic_ns(&spec);
220+
}
221+
222+
/* Check that the picoquic_ns simulations can correctly test the low_and_up scenario.
223+
*/
224+
int cc_ns_wifi_fade_test()
225+
{
226+
picoquic_ns_spec_t spec = { 0 };
227+
picoquic_connection_id_t icid = { { 0xcc, 0xff, 0xbb, 0, 0, 0, 0, 0}, 8 };
228+
spec.main_cc_algo = picoquic_bbr_algorithm;
229+
spec.main_start_time = 0;
230+
spec.main_scenario_text = cc_compete_batch_scenario_4M;
231+
spec.background_cc_algo = picoquic_bbr_algorithm;
232+
spec.background_start_time = 0;
233+
spec.background_scenario_text = cc_compete_batch_scenario_10M;
234+
spec.nb_connections = 1;
235+
spec.data_rate_in_gbps = 0.01;
236+
spec.latency = 5000;
237+
spec.main_target_time = 7000000;
238+
spec.queue_delay_max = 15000;
239+
spec.icid = icid;
240+
spec.qlog_dir = ".";
241+
spec.link_scenario = link_scenario_wifi_fade;
242+
243+
return picoquic_ns(&spec);
244+
}
245+
246+
247+
/* Check that the picoquic_ns simulations can correctly test the low_and_up scenario.
248+
*/
249+
int cc_ns_wifi_suspension_test()
250+
{
251+
picoquic_ns_spec_t spec = { 0 };
252+
picoquic_connection_id_t icid = { { 0xcc, 0xf5, 0xbb, 0, 0, 0, 0, 0}, 8 };
253+
spec.main_cc_algo = picoquic_bbr_algorithm;
254+
spec.main_start_time = 0;
255+
spec.main_scenario_text = cc_compete_batch_scenario_4M;
256+
spec.background_cc_algo = picoquic_bbr_algorithm;
257+
spec.background_start_time = 0;
258+
spec.background_scenario_text = cc_compete_batch_scenario_10M;
259+
spec.nb_connections = 1;
260+
spec.data_rate_in_gbps = 0.01;
261+
spec.latency = 5000;
262+
spec.main_target_time = 4000000;
263+
spec.queue_delay_max = 15000;
264+
spec.icid = icid;
265+
spec.qlog_dir = ".";
266+
spec.link_scenario = link_scenario_wifi_suspension;
267+
268+
return picoquic_ns(&spec);
269+
}
270+
271+
272+
/* Check that the picoquic_ns simulations can correctly test the low_and_up scenario.
273+
* The simple scenario merely duplicates the "wifi fade" scenario, the only difference
274+
* being that the "varylink" structure is user specified.
275+
*/
276+
picoquic_ns_link_spec_t cc_varylink_test_spec[] = {
277+
{ 1000000, 0.01, 0.01, 5000, 0, 15000, 0 },
278+
{ 2000000, 0.001, 0.001, 5000, 0, 15000, 0 },
279+
{ UINT64_MAX, 0.01, 0.01, 5000, 0, 15000, 0 }
280+
};
281+
282+
int cc_ns_varylink_test()
283+
{
284+
picoquic_ns_spec_t spec = { 0 };
285+
picoquic_connection_id_t icid = { { 0xcc, 0x11, 0xbb, 0, 0, 0, 0, 0}, 8 };
286+
spec.main_cc_algo = picoquic_bbr_algorithm;
287+
spec.main_start_time = 0;
288+
spec.main_scenario_text = cc_compete_batch_scenario_4M;
289+
spec.background_cc_algo = picoquic_bbr_algorithm;
290+
spec.background_start_time = 0;
291+
spec.background_scenario_text = cc_compete_batch_scenario_10M;
292+
spec.nb_connections = 1;
293+
spec.data_rate_in_gbps = 0.01;
294+
spec.latency = 5000;
295+
spec.main_target_time = 7000000;
296+
spec.queue_delay_max = 15000;
297+
spec.icid = icid;
298+
spec.qlog_dir = ".";
299+
spec.link_scenario = link_scenario_none;
300+
spec.vary_link_nb = sizeof(cc_varylink_test_spec) / sizeof(picoquic_ns_link_spec_t);
301+
spec.vary_link_spec = cc_varylink_test_spec;
302+
303+
return picoquic_ns(&spec);
304+
}

0 commit comments

Comments
 (0)