@@ -315,7 +315,7 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
315315 int * reinject ,
316316 struct sock * * subsk ,
317317 unsigned int * limit )
318- {/*Start scheduling next segments*/
318+ {
319319 const struct mptcp_cb * mpcb = tcp_sk (meta_sk )-> mpcb ;
320320 struct sock * choose_sk = NULL ;
321321 struct mptcp_tcp_sock * mptcp ;
@@ -346,8 +346,8 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
346346 mptcp_sched_probe_init (& sprobe );
347347
348348#endif
349+ /*Intial parameter setup for meta_tp*/
349350 if (meta_tp -> run_started == 0 ) {
350- /*Intial parameter setup*/
351351 meta_tp -> run_started = 1 ;
352352 num_segments_flow_one = meta_tp -> num_segments_flow_one = sysctl_num_segments_flow_one ;
353353 meta_tp -> ratio_search_step = sysctl_mptcp_ratio_search_step ;
@@ -374,9 +374,8 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
374374 return skb ;
375375 }
376376
377-
377+ /*Schedule the next segment*/
378378retry :
379- /* First, we look for a subflow who is currently being used */
380379 mptcp_for_each_sub (mpcb , mptcp ) {
381380 struct sock * sk_it = mptcp_to_sock (mptcp );
382381 struct tcp_sock * tp_it = tcp_sk (sk_it );
@@ -388,30 +387,33 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
388387 struct sockaddr_in6 v6 ;
389388 } dst ;
390389
391- counter ++ ;//This is for what??
390+ /*Counter to distinguish the subflows*/
391+ counter ++ ;
392392
393393 tcp_probe_copy_fl_to_si4 (inet , dst .v4 , d );
394394 if (!mptcp_ratio_is_available (sk_it , skb , false, cwnd_limited )){
395395 //printk("flow rejected");
396396 continue ;
397397 }
398398
399+ /*Counter to compare with full_subs for round restart*/
399400 iter ++ ;
400401
402+ /* Considering the first subflow */
401403 if (counter % 2 ) {
402404 if (meta_tp -> num_segments_flow_one == 0 ) {
403405 full_subs ++ ;
404406 continue ;
405407 }
406408
407- /* Is this subflow currently being used? */
409+ /*This subflow is being used but not yet reached the quota */
408410 if (rsp -> quota > 0 && rsp -> quota < meta_tp -> num_segments_flow_one ) {
409411 split = meta_tp -> num_segments_flow_one - rsp -> quota ;
410412 choose_sk = sk_it ;
411413 goto found ;
412414 }
413415
414- /* Or, it's totally unused */
416+ /*Nothing scheduled on this subflow yet */
415417 if (!rsp -> quota ) {
416418 split = meta_tp -> num_segments_flow_one ;
417419 choose_sk = sk_it ;
@@ -421,20 +423,21 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
421423 if (rsp -> quota >= meta_tp -> num_segments_flow_one )
422424 full_subs ++ ;
423425 }
426+ /* Considering the second subflow */
424427 else {
425428 if (num_segments - meta_tp -> num_segments_flow_one == 0 ) {
426429 full_subs ++ ;
427430 continue ;
428431 }
429432
430- /* Is this subflow currently being used? */
433+ /*This subflow is being used but not yet reached the quota */
431434 if (rsp -> quota > 0 && rsp -> quota < (num_segments - meta_tp -> num_segments_flow_one )) {
432435 split = (num_segments - meta_tp -> num_segments_flow_one ) - rsp -> quota ;
433436 choose_sk = sk_it ;
434437 goto found ;
435438 }
436439
437- /* Or, it's totally unused */
440+ /*Nothing scheduled on this subflow yet */
438441 if (!rsp -> quota ) {
439442 split = num_segments - meta_tp -> num_segments_flow_one ;
440443 choose_sk = sk_it ;
@@ -446,10 +449,10 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
446449 }
447450 }
448451
452+ /* All subflows reach quota, we restart this round by setting quota to 0 and retry
453+ * to find a subflow.
454+ */
449455 if (iter && iter == full_subs ) {
450- /* So, all sub flows reach quota, we restart this round by setting quota to 0 and retry
451- * to find a subflow.
452- */
453456 mptcp_for_each_sub (mpcb , mptcp ) {
454457 struct sock * sk_it = mptcp_to_sock (mptcp );
455458 struct tcp_sock * tp_it = tcp_sk (sk_it );
@@ -465,7 +468,6 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
465468
466469found :
467470 if (choose_sk ) {
468- /*Schedule the chosen socket*/
469471 unsigned int mss_now ;
470472 struct tcp_sock * choose_tp = tcp_sk (choose_sk );
471473 struct ratio_sched_priv * rsp = ratio_sched_get_priv (choose_tp );
@@ -492,6 +494,8 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
492494
493495#ifdef MPTCP_SCHED_PROBE
494496 iter = total_rate = rate_ad = rate_ac = 0 ;
497+
498+ /*Start probe logic for every segment*/
495499 mptcp_for_each_sub (mpcb , mptcp ) {
496500 struct sock * sk_it = mptcp_to_sock (mptcp );
497501 struct tcp_sock * tp_it = tcp_sk (sk_it );
@@ -501,7 +505,7 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
501505 mptcp_sched_probe_init (& sprobe );
502506 iter ++ ;
503507
504- /*These two are read for every function call, e.g, every segments
508+ /*These two are read for every function call, e.g, every segment
505509 * we log every 100ms or longer*/
506510 subflow_rate = READ_ONCE (tp_it -> rate_delivered );
507511 subflow_intv = READ_ONCE (tp_it -> rate_interval_us );
@@ -510,7 +514,7 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
510514 do_div (subflow_rate64 , subflow_intv );
511515 subflow_rate64 *= 8 ;
512516
513- if (subflow_rate64 != tp_it -> last_ac_rate ) { // Using last_ac_rate as last ac or ad rate
517+ if (subflow_rate64 != tp_it -> last_ac_rate ) {
514518 if (iter == 1 ) {
515519 rate_ad += subflow_rate64 ;
516520 } else {
@@ -533,14 +537,13 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
533537 mptcp_sched_probe_log_hook (& sprobe , true, sched_probe_id , sk_it );
534538 }
535539 else mptcp_sched_probe_log_hook (& sprobe , false, sched_probe_id , sk_it );
536- }
540+ }/*End probe logic for every segment*/
537541
538542 /* AUTO-RATE search */
539543 do_div (total_rate , 1000000 );
540544 meta_tp -> rate_delivered += total_rate ;//no use
541545 meta_tp -> delivered ++ ;
542546
543-
544547 mptcp_for_each_sub (mpcb , mptcp ) {
545548 struct sock * sk_it = mptcp_to_sock (mptcp );
546549 struct tcp_sock * tp_it_temp = tcp_sk (sk_it );
@@ -550,8 +553,8 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
550553 }
551554
552555 time_diff = jiffies_to_msecs (jiffies - meta_tp -> rate_interval_us );
556+ /*Ratio search logic, triggered by collecting samples every ratio_rate_sample (ms)*/
553557 if (time_diff >= meta_tp -> ratio_rate_sample ) {
554- /*Collecting samples over an fixed sampling interval (i.e 100ms)*/
555558 last_rate = meta_tp -> prr_out ;
556559 trigger_threshold = meta_tp -> prr_delivered ;
557560 in_search = meta_tp -> lost ;
@@ -565,8 +568,9 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
565568
566569 iter = 0 ;
567570 meta_tp -> rate_delivered = 0 ;
571+
572+ /*Value estimation per sampling interval*/
568573 mptcp_for_each_sub (mpcb , mptcp ) {
569- //Throughput estimation on each interface
570574 struct sock * sk_it = mptcp_to_sock (mptcp );
571575 struct tcp_sock * tp_it_temp = tcp_sk (sk_it );
572576 struct ratio_sched_priv * rsp_temp = ratio_sched_get_priv (tp_it_temp );
@@ -588,7 +592,7 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
588592 meta_tp -> rate_delivered += tput [iter ];
589593 rsp_temp -> snd_una_saved = tp_it_temp -> snd_una ;
590594 iter ++ ;
591- }
595+ }/*End value estimation per sampling interval*/
592596
593597 for (iter = 0 ; iter < 3 ; iter ++ ) {
594598 if (iter == 2 )
@@ -751,8 +755,8 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
751755 }
752756
753757
758+ /*Start ratio searching*/
754759 if (in_search ) {
755- /*Start searching*/
756760 switch (meta_tp -> search_state ) {
757761 case RIGHT_RATIO_SET :
758762 printk ("RIGHT_RATIO_SET" );
@@ -853,9 +857,10 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
853857 goto reset ;
854858 break ;
855859 }
856- }// End searching
860+ }/* End ratio searching*/
857861
858862 last_rate = meta_tp -> rate_delivered ;
863+ //Save estimation value at this interval for later use
859864reset :
860865 meta_tp -> prr_out = last_rate ;
861866 meta_tp -> prr_delivered = trigger_threshold ;
@@ -900,14 +905,16 @@ static struct sk_buff *mptcp_ratio_next_segment(struct sock *meta_sk,
900905 iter = 0 ;
901906 mptcp_for_each_sub (mpcb , mptcp ) {
902907 struct sock * sk_it = mptcp_to_sock (mptcp );
903- mptcp_sched_probe_init (& sprobe );
908+ mptcp_sched_probe_init (& sprobe );//initialize sprobe
904909 iter ++ ;
905910
906911 if (!mptcp_ratio_is_available (sk_it , skb , false, cwnd_limited )) sprobe .temp_unavailable = true;
907912
913+ //Probe the chosen subflow
908914 if (choose_sk == sk_it ) {
909915 mptcp_sched_probe_log_hook (& sprobe , true, sched_probe_id , sk_it );
910916 }
917+ //Don't probe the current subflow
911918 else mptcp_sched_probe_log_hook (& sprobe , false, sched_probe_id , sk_it );
912919 }
913920#endif
0 commit comments