Christoffer Jansson | 4e8a773 | 2022-02-08 08:01:12 | [diff] [blame] | 1 | #!/usr/bin/env vpython3 |
| 2 | |
kjellander@webrtc.org | 595749f | 2012-05-31 20:19:05 | [diff] [blame] | 3 | # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license |
| 6 | # that can be found in the LICENSE file in the root of the source |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
kjellander@webrtc.org | 29c5a23 | 2012-06-01 08:42:17 | [diff] [blame] | 10 | """Configuration class for network emulation.""" |
kjellander@webrtc.org | 595749f | 2012-05-31 20:19:05 | [diff] [blame] | 11 | |
| 12 | |
Christoffer Jansson | 4e8a773 | 2022-02-08 08:01:12 | [diff] [blame] | 13 | class ConnectionConfig: |
| 14 | """Configuration containing the characteristics of a network connection.""" |
kjellander@webrtc.org | 595749f | 2012-05-31 20:19:05 | [diff] [blame] | 15 | |
Christoffer Jansson | 4e8a773 | 2022-02-08 08:01:12 | [diff] [blame] | 16 | def __init__(self, num, name, receive_bw_kbps, send_bw_kbps, delay_ms, |
| 17 | packet_loss_percent, queue_slots): |
| 18 | self.num = num |
| 19 | self.name = name |
| 20 | self.receive_bw_kbps = receive_bw_kbps |
| 21 | self.send_bw_kbps = send_bw_kbps |
| 22 | self.delay_ms = delay_ms |
| 23 | self.packet_loss_percent = packet_loss_percent |
| 24 | self.queue_slots = queue_slots |
kjellander@webrtc.org | 595749f | 2012-05-31 20:19:05 | [diff] [blame] | 25 | |
Christoffer Jansson | 4e8a773 | 2022-02-08 08:01:12 | [diff] [blame] | 26 | def __str__(self): |
| 27 | """String representing the configuration. |
kjellander@webrtc.org | 595749f | 2012-05-31 20:19:05 | [diff] [blame] | 28 | |
| 29 | Returns: |
| 30 | A string formatted and padded like this example: |
| 31 | 12 Name 375 kbps 375 kbps 10 145 ms 0.1 % |
| 32 | """ |
Christoffer Jansson | 4e8a773 | 2022-02-08 08:01:12 | [diff] [blame] | 33 | left_aligned_name = self.name.ljust(24, ' ') |
| 34 | return '%2s %24s %5s kbps %5s kbps %4s %5s ms %3s %%' % ( |
| 35 | self.num, left_aligned_name, self.receive_bw_kbps, self.send_bw_kbps, |
| 36 | self.queue_slots, self.delay_ms, self.packet_loss_percent) |