blob: c1d3eaf3d149cf99fc816857a892299a6976b5f7 [file] [log] [blame]
kjellander@webrtc.org595749f2012-05-31 20:19:05 +00001#!/usr/bin/env python
2# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3#
4# Use of this source code is governed by a BSD-style license
5# that can be found in the LICENSE file in the root of the source
6# tree. An additional intellectual property rights grant can be found
7# in the file PATENTS. All contributing project authors may
8# be found in the AUTHORS file in the root of the source tree.
kjellander@webrtc.org29c5a232012-06-01 08:42:17 +00009"""Configuration class for network emulation."""
kjellander@webrtc.org595749f2012-05-31 20:19:05 +000010
11
12class ConnectionConfig(object):
Mirko Bonadei8cc66952020-10-30 10:13:45 +010013 """Configuration containing the characteristics of a network connection."""
kjellander@webrtc.org595749f2012-05-31 20:19:05 +000014
Mirko Bonadei8cc66952020-10-30 10:13:45 +010015 def __init__(self, num, name, receive_bw_kbps, send_bw_kbps, delay_ms,
16 packet_loss_percent, queue_slots):
17 self.num = num
18 self.name = name
19 self.receive_bw_kbps = receive_bw_kbps
20 self.send_bw_kbps = send_bw_kbps
21 self.delay_ms = delay_ms
22 self.packet_loss_percent = packet_loss_percent
23 self.queue_slots = queue_slots
kjellander@webrtc.org595749f2012-05-31 20:19:05 +000024
Mirko Bonadei8cc66952020-10-30 10:13:45 +010025 def __str__(self):
26 """String representing the configuration.
kjellander@webrtc.org595749f2012-05-31 20:19:05 +000027
28 Returns:
29 A string formatted and padded like this example:
30 12 Name 375 kbps 375 kbps 10 145 ms 0.1 %
31 """
Mirko Bonadei8cc66952020-10-30 10:13:45 +010032 left_aligned_name = self.name.ljust(24, ' ')
33 return '%2s %24s %5s kbps %5s kbps %4s %5s ms %3s %%' % (
34 self.num, left_aligned_name, self.receive_bw_kbps,
35 self.send_bw_kbps, self.queue_slots, self.delay_ms,
36 self.packet_loss_percent)