@@ -78,12 +78,6 @@ long double rttSeconds(std::size_t latency_us) {
7878 return std::chrono::microseconds (2 * latency_us) / 1 .0s;
7979}
8080
81- // Utility function that does the reverse of the above.
82- Time::Duration convert (long double v) {
83- const auto t0 = std::chrono::duration<long double >(v);
84- return std::chrono::duration_cast<Time::Duration>(t0);
85- }
86-
8781// calculate the throughput of a channel.
8882long double throughput (NetworkDescription::ChannelParameters params) {
8983 const auto rtt_secs = rttSeconds (params.latency );
@@ -107,17 +101,23 @@ long double throughput(NetworkDescription::ChannelParameters params) {
107101 return std::min (tp, (long double )params.bandwidth );
108102}
109103
104+ // Utility function that does the reverse of the above.
105+ Time::Duration convert (long double v) {
106+ const auto t0 = std::chrono::duration<long double >(v);
107+ return std::chrono::duration_cast<Time::Duration>(t0);
108+ }
109+
110110// compute the time it takes to send n bytes on a channel.
111111Time::Duration recvTimeOffset (std::size_t n,
112112 NetworkDescription::ChannelParameters params) {
113113 const long double total_size = completeDataSize (n);
114114 const long double tp = throughput (params);
115115
116- // the min here is needed in case we're sending very small amounts of
116+ // the max here is needed in case we're sending very small amounts of
117117 // data. I.e., regardless of how good the channel is, we cannot send data
118118 // faster than the latency.
119119 const long double delay =
120- std::min (total_size / tp, rttSeconds (params.latency ));
120+ std::max (total_size / tp, rttSeconds (params.latency ));
121121
122122 return convert (delay);
123123}
@@ -129,7 +129,9 @@ Time::Duration computeDelay(Time::Duration rt,
129129 Time::Duration st,
130130 std::size_t n,
131131 NetworkDescription::ChannelParameters params) {
132- return std::max (st + recvTimeOffset (n, params) - rt, Time::Duration::zero ());
132+ const auto x = st + recvTimeOffset (n, params) - rt;
133+ std::cout << recvTimeOffset (n, params) << " \n " ;
134+ return std::max (x, Time::Duration::zero ());
133135}
134136
135137} // namespace
0 commit comments