mirror of
https://github.com/rclone/rclone
synced 2025-01-17 22:27:30 +01:00
Add --bwlimit for upload and download #1873
This commit is contained in:
parent
8856e0e559
commit
0a932dc1f2
@ -359,59 +359,81 @@ it will give an error.
|
|||||||
|
|
||||||
### --bwlimit=BANDWIDTH_SPEC ###
|
### --bwlimit=BANDWIDTH_SPEC ###
|
||||||
|
|
||||||
This option controls the bandwidth limit. Limits can be specified
|
This option controls the bandwidth limit. For example
|
||||||
in two ways: As a single limit, or as a timetable.
|
|
||||||
|
|
||||||
Single limits last for the duration of the session. To use a single limit,
|
--bwlimit 10M
|
||||||
specify the desired bandwidth in kBytes/s, or use a suffix b|k|M|G. The
|
|
||||||
default is `0` which means to not limit bandwidth.
|
would mean limit the upload and download bandwidth to 10 Mbyte/s.
|
||||||
|
**NB** this is **bytes** per second not **bits** per second. To use a
|
||||||
|
single limit, specify the desired bandwidth in kBytes/s, or use a
|
||||||
|
suffix b|k|M|G. The default is `0` which means to not limit bandwidth.
|
||||||
|
|
||||||
For example, to limit bandwidth usage to 10 MBytes/s use `--bwlimit 10M`
|
The upload and download bandwidth can be specified seperately, as
|
||||||
|
`--bwlimit UP:DOWN`, so
|
||||||
|
|
||||||
It is also possible to specify a "timetable" of limits, which will cause
|
--bwlimit 10M:100k
|
||||||
certain limits to be applied at certain times. To specify a timetable, format your
|
|
||||||
entries as `WEEKDAY-HH:MM,BANDWIDTH WEEKDAY-HH:MM,BANDWIDTH...` where:
|
would mean limit the upload bandwidth to 10 Mbyte/s and the download
|
||||||
`WEEKDAY` is optional element.
|
bandwidth to 100 kByte/s. Either limit can be "off" meaning no limit, so
|
||||||
It could be written as whole world or only using 3 first characters.
|
to just limit the upload bandwidth you would use
|
||||||
`HH:MM` is an hour from 00:00 to 23:59.
|
|
||||||
|
--bwlimit 10M:off
|
||||||
|
|
||||||
|
this would limit the upload bandwidth to 10MByte/s but the download
|
||||||
|
bandwidth would be unlimited.
|
||||||
|
|
||||||
|
When specified as above the bandwidth limits last for the duration of
|
||||||
|
run of the rclone binary.
|
||||||
|
|
||||||
|
It is also possible to specify a "timetable" of limits, which will
|
||||||
|
cause certain limits to be applied at certain times. To specify a
|
||||||
|
timetable, format your entries as `WEEKDAY-HH:MM,BANDWIDTH
|
||||||
|
WEEKDAY-HH:MM,BANDWIDTH...` where: `WEEKDAY` is optional element.
|
||||||
|
|
||||||
|
- `BANDWIDTH` can be a single number, e.g.`100k` or a pair of numbers
|
||||||
|
for upload:download, e.g.`10M:1M`.
|
||||||
|
- `WEEKDAY` can be written as the whole word or only using the first 3
|
||||||
|
characters. It is optional.
|
||||||
|
- `HH:MM` is an hour from 00:00 to 23:59.
|
||||||
|
|
||||||
An example of a typical timetable to avoid link saturation during daytime
|
An example of a typical timetable to avoid link saturation during daytime
|
||||||
working hours could be:
|
working hours could be:
|
||||||
|
|
||||||
`--bwlimit "08:00,512 12:00,10M 13:00,512 18:00,30M 23:00,off"`
|
`--bwlimit "08:00,512k 12:00,10M 13:00,512k 18:00,30M 23:00,off"`
|
||||||
|
|
||||||
In this example, the transfer bandwidth will be every day set to 512kBytes/sec at 8am.
|
In this example, the transfer bandwidth will be set to 512kBytes/sec
|
||||||
At noon, it will raise to 10Mbytes/s, and drop back to 512kBytes/sec at 1pm.
|
at 8am every day. At noon, it will rise to 10Mbytes/s, and drop back
|
||||||
At 6pm, the bandwidth limit will be set to 30MBytes/s, and at 11pm it will be
|
to 512kBytes/sec at 1pm. At 6pm, the bandwidth limit will be set to
|
||||||
completely disabled (full speed). Anything between 11pm and 8am will remain
|
30MBytes/s, and at 11pm it will be completely disabled (full speed).
|
||||||
unlimited.
|
Anything between 11pm and 8am will remain unlimited.
|
||||||
|
|
||||||
An example of timetable with `WEEKDAY` could be:
|
An example of timetable with `WEEKDAY` could be:
|
||||||
|
|
||||||
`--bwlimit "Mon-00:00,512 Fri-23:59,10M Sat-10:00,1M Sun-20:00,off"`
|
`--bwlimit "Mon-00:00,512 Fri-23:59,10M Sat-10:00,1M Sun-20:00,off"`
|
||||||
|
|
||||||
It mean that, the transfer bandwidth will be set to 512kBytes/sec on Monday.
|
It means that, the transfer bandwidth will be set to 512kBytes/sec on
|
||||||
It will raise to 10Mbytes/s before the end of Friday.
|
Monday. It will rise to 10Mbytes/s before the end of Friday. At 10:00
|
||||||
At 10:00 on Sunday it will be set to 1Mbyte/s.
|
on Saturday it will be set to 1Mbyte/s. From 20:00 on Sunday it will
|
||||||
From 20:00 at Sunday will be unlimited.
|
be unlimited.
|
||||||
|
|
||||||
Timeslots without weekday are extended to whole week.
|
Timeslots without `WEEKDAY` are extended to the whole week. So this
|
||||||
So this one example:
|
example:
|
||||||
|
|
||||||
`--bwlimit "Mon-00:00,512 12:00,1M Sun-20:00,off"`
|
`--bwlimit "Mon-00:00,512 12:00,1M Sun-20:00,off"`
|
||||||
|
|
||||||
Is equal to this:
|
Is equivalent to this:
|
||||||
|
|
||||||
`--bwlimit "Mon-00:00,512Mon-12:00,1M Tue-12:00,1M Wed-12:00,1M Thu-12:00,1M Fri-12:00,1M Sat-12:00,1M Sun-12:00,1M Sun-20:00,off"`
|
`--bwlimit "Mon-00:00,512Mon-12:00,1M Tue-12:00,1M Wed-12:00,1M Thu-12:00,1M Fri-12:00,1M Sat-12:00,1M Sun-12:00,1M Sun-20:00,off"`
|
||||||
|
|
||||||
Bandwidth limits only apply to the data transfer. They don't apply to the
|
Bandwidth limit apply to the data transfer for all backends. For most
|
||||||
bandwidth of the directory listings etc.
|
backends the directory listing bandwidth is also included (exceptions
|
||||||
|
being the non HTTP backends, `ftp`, `sftp` and `tardigrade`).
|
||||||
|
|
||||||
Note that the units are Bytes/s, not Bits/s. Typically connections are
|
Note that the units are **Bytes/s**, not **Bits/s**. Typically
|
||||||
measured in Bits/s - to convert divide by 8. For example, let's say
|
connections are measured in Bits/s - to convert divide by 8. For
|
||||||
you have a 10 Mbit/s connection and you wish rclone to use half of it
|
example, let's say you have a 10 Mbit/s connection and you wish rclone
|
||||||
- 5 Mbit/s. This is 5/8 = 0.625MByte/s so you would use a `--bwlimit
|
to use half of it - 5 Mbit/s. This is 5/8 = 0.625MByte/s so you would
|
||||||
0.625M` parameter for rclone.
|
use a `--bwlimit 0.625M` parameter for rclone.
|
||||||
|
|
||||||
On Unix systems (Linux, macOS, …) the bandwidth limiter can be toggled by
|
On Unix systems (Linux, macOS, …) the bandwidth limiter can be toggled by
|
||||||
sending a `SIGUSR2` signal to rclone. This allows to remove the limitations
|
sending a `SIGUSR2` signal to rclone. This allows to remove the limitations
|
||||||
|
@ -90,7 +90,7 @@ func newAccountSizeName(ctx context.Context, stats *StatsInfo, in io.ReadCloser,
|
|||||||
acc.values.max = int64((acc.ci.MaxTransfer))
|
acc.values.max = int64((acc.ci.MaxTransfer))
|
||||||
}
|
}
|
||||||
currLimit := acc.ci.BwLimitFile.LimitAt(time.Now())
|
currLimit := acc.ci.BwLimitFile.LimitAt(time.Now())
|
||||||
if currLimit.Bandwidth > 0 {
|
if currLimit.Bandwidth.IsSet() {
|
||||||
fs.Debugf(acc.name, "Limiting file transfer to %v", currLimit.Bandwidth)
|
fs.Debugf(acc.name, "Limiting file transfer to %v", currLimit.Bandwidth)
|
||||||
acc.tokenBucket = newTokenBucket(currLimit.Bandwidth)
|
acc.tokenBucket = newTokenBucket(currLimit.Bandwidth)
|
||||||
}
|
}
|
||||||
|
@ -55,17 +55,32 @@ func (bs *buckets) _setOff() {
|
|||||||
|
|
||||||
const maxBurstSize = 4 * 1024 * 1024 // must be bigger than the biggest request
|
const maxBurstSize = 4 * 1024 * 1024 // must be bigger than the biggest request
|
||||||
|
|
||||||
// make a new empty token bucket with the bandwidth given
|
// make a new empty token bucket with the bandwidth(s) given
|
||||||
func newTokenBucket(bandwidth fs.SizeSuffix) (newTokenBucket buckets) {
|
func newTokenBucket(bandwidth fs.BwPair) (tbs buckets) {
|
||||||
for i := range newTokenBucket {
|
bandwidthAccounting := fs.SizeSuffix(-1)
|
||||||
newTokenBucket[i] = rate.NewLimiter(rate.Limit(bandwidth), maxBurstSize)
|
if bandwidth.Tx > 0 {
|
||||||
// empty the bucket
|
tbs[TokenBucketSlotTransportTx] = rate.NewLimiter(rate.Limit(bandwidth.Tx), maxBurstSize)
|
||||||
err := newTokenBucket[i].WaitN(context.Background(), maxBurstSize)
|
bandwidthAccounting = bandwidth.Tx
|
||||||
if err != nil {
|
}
|
||||||
fs.Errorf(nil, "Failed to empty token bucket: %v", err)
|
if bandwidth.Rx > 0 {
|
||||||
|
tbs[TokenBucketSlotTransportRx] = rate.NewLimiter(rate.Limit(bandwidth.Rx), maxBurstSize)
|
||||||
|
if bandwidth.Rx > bandwidthAccounting {
|
||||||
|
bandwidthAccounting = bandwidth.Rx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newTokenBucket
|
if bandwidthAccounting > 0 {
|
||||||
|
tbs[TokenBucketSlotAccounting] = rate.NewLimiter(rate.Limit(bandwidthAccounting), maxBurstSize)
|
||||||
|
}
|
||||||
|
for _, tb := range tbs {
|
||||||
|
if tb != nil {
|
||||||
|
// empty the bucket
|
||||||
|
err := tb.WaitN(context.Background(), maxBurstSize)
|
||||||
|
if err != nil {
|
||||||
|
fs.Errorf(nil, "Failed to empty token bucket: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tbs
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartTokenBucket starts the token bucket if necessary
|
// StartTokenBucket starts the token bucket if necessary
|
||||||
@ -74,7 +89,7 @@ func (tb *tokenBucket) StartTokenBucket(ctx context.Context) {
|
|||||||
defer tb.mu.Unlock()
|
defer tb.mu.Unlock()
|
||||||
ci := fs.GetConfig(ctx)
|
ci := fs.GetConfig(ctx)
|
||||||
tb.currLimit = ci.BwLimit.LimitAt(time.Now())
|
tb.currLimit = ci.BwLimit.LimitAt(time.Now())
|
||||||
if tb.currLimit.Bandwidth > 0 {
|
if tb.currLimit.Bandwidth.IsSet() {
|
||||||
tb.curr = newTokenBucket(tb.currLimit.Bandwidth)
|
tb.curr = newTokenBucket(tb.currLimit.Bandwidth)
|
||||||
fs.Infof(nil, "Starting bandwidth limiter at %vBytes/s", &tb.currLimit.Bandwidth)
|
fs.Infof(nil, "Starting bandwidth limiter at %vBytes/s", &tb.currLimit.Bandwidth)
|
||||||
|
|
||||||
@ -113,7 +128,7 @@ func (tb *tokenBucket) StartTokenTicker(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set new bandwidth. If unlimited, set tokenbucket to nil.
|
// Set new bandwidth. If unlimited, set tokenbucket to nil.
|
||||||
if limitNow.Bandwidth > 0 {
|
if limitNow.Bandwidth.IsSet() {
|
||||||
*targetBucket = newTokenBucket(limitNow.Bandwidth)
|
*targetBucket = newTokenBucket(limitNow.Bandwidth)
|
||||||
if tb.toggledOff {
|
if tb.toggledOff {
|
||||||
fs.Logf(nil, "Scheduled bandwidth change. "+
|
fs.Logf(nil, "Scheduled bandwidth change. "+
|
||||||
@ -140,7 +155,7 @@ func (tb *tokenBucket) LimitBandwidth(i TokenBucketSlot, n int) {
|
|||||||
tb.mu.RLock()
|
tb.mu.RLock()
|
||||||
|
|
||||||
// Limit the transfer speed if required
|
// Limit the transfer speed if required
|
||||||
if !tb.curr._isOff() {
|
if tb.curr[i] != nil {
|
||||||
err := tb.curr[i].WaitN(context.Background(), n)
|
err := tb.curr[i].WaitN(context.Background(), n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Errorf(nil, "Token bucket error: %v", err)
|
fs.Errorf(nil, "Token bucket error: %v", err)
|
||||||
@ -151,10 +166,10 @@ func (tb *tokenBucket) LimitBandwidth(i TokenBucketSlot, n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetBwLimit sets the current bandwidth limit
|
// SetBwLimit sets the current bandwidth limit
|
||||||
func (tb *tokenBucket) SetBwLimit(bandwidth fs.SizeSuffix) {
|
func (tb *tokenBucket) SetBwLimit(bandwidth fs.BwPair) {
|
||||||
tb.mu.Lock()
|
tb.mu.Lock()
|
||||||
defer tb.mu.Unlock()
|
defer tb.mu.Unlock()
|
||||||
if bandwidth > 0 {
|
if bandwidth.IsSet() {
|
||||||
tb.curr = newTokenBucket(bandwidth)
|
tb.curr = newTokenBucket(bandwidth)
|
||||||
fs.Logf(nil, "Bandwidth limit set to %v", bandwidth)
|
fs.Logf(nil, "Bandwidth limit set to %v", bandwidth)
|
||||||
} else {
|
} else {
|
||||||
@ -183,13 +198,22 @@ func (tb *tokenBucket) rcBwlimit(ctx context.Context, in rc.Params) (out rc.Para
|
|||||||
}
|
}
|
||||||
tb.mu.RLock()
|
tb.mu.RLock()
|
||||||
bytesPerSecond := int64(-1)
|
bytesPerSecond := int64(-1)
|
||||||
if !tb.curr._isOff() {
|
if tb.curr[TokenBucketSlotAccounting] != nil {
|
||||||
bytesPerSecond = int64(tb.curr[0].Limit())
|
bytesPerSecond = int64(tb.curr[TokenBucketSlotAccounting].Limit())
|
||||||
|
}
|
||||||
|
var bp = fs.BwPair{Tx: -1, Rx: -1}
|
||||||
|
if tb.curr[TokenBucketSlotTransportTx] != nil {
|
||||||
|
bp.Tx = fs.SizeSuffix(tb.curr[TokenBucketSlotTransportTx].Limit())
|
||||||
|
}
|
||||||
|
if tb.curr[TokenBucketSlotTransportRx] != nil {
|
||||||
|
bp.Rx = fs.SizeSuffix(tb.curr[TokenBucketSlotTransportRx].Limit())
|
||||||
}
|
}
|
||||||
tb.mu.RUnlock()
|
tb.mu.RUnlock()
|
||||||
out = rc.Params{
|
out = rc.Params{
|
||||||
"rate": fs.SizeSuffix(bytesPerSecond).String(),
|
"rate": bp.String(),
|
||||||
"bytesPerSecond": bytesPerSecond,
|
"bytesPerSecond": bytesPerSecond,
|
||||||
|
"bytesPerSecondTx": int64(bp.Tx),
|
||||||
|
"bytesPerSecondRx": int64(bp.Rx),
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
@ -203,18 +227,30 @@ func init() {
|
|||||||
},
|
},
|
||||||
Title: "Set the bandwidth limit.",
|
Title: "Set the bandwidth limit.",
|
||||||
Help: `
|
Help: `
|
||||||
This sets the bandwidth limit to that passed in.
|
This sets the bandwidth limit to the string passed in. This should be
|
||||||
|
a single bandwidth limit entry or a pair of upload:download bandwidth.
|
||||||
|
|
||||||
Eg
|
Eg
|
||||||
|
|
||||||
rclone rc core/bwlimit rate=off
|
rclone rc core/bwlimit rate=off
|
||||||
{
|
{
|
||||||
"bytesPerSecond": -1,
|
"bytesPerSecond": -1,
|
||||||
|
"bytesPerSecondTx": -1,
|
||||||
|
"bytesPerSecondRx": -1,
|
||||||
"rate": "off"
|
"rate": "off"
|
||||||
}
|
}
|
||||||
rclone rc core/bwlimit rate=1M
|
rclone rc core/bwlimit rate=1M
|
||||||
{
|
{
|
||||||
"bytesPerSecond": 1048576,
|
"bytesPerSecond": 1048576,
|
||||||
|
"bytesPerSecondTx": 1048576,
|
||||||
|
"bytesPerSecondRx": 1048576,
|
||||||
|
"rate": "1M"
|
||||||
|
}
|
||||||
|
rclone rc core/bwlimit rate=1M:100k
|
||||||
|
{
|
||||||
|
"bytesPerSecond": 1048576,
|
||||||
|
"bytesPerSecondTx": 1048576,
|
||||||
|
"bytesPerSecondRx": 131072,
|
||||||
"rate": "1M"
|
"rate": "1M"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +260,8 @@ If the rate parameter is not supplied then the bandwidth is queried
|
|||||||
rclone rc core/bwlimit
|
rclone rc core/bwlimit
|
||||||
{
|
{
|
||||||
"bytesPerSecond": 1048576,
|
"bytesPerSecond": 1048576,
|
||||||
|
"bytesPerSecondTx": 1048576,
|
||||||
|
"bytesPerSecondRx": 1048576,
|
||||||
"rate": "1M"
|
"rate": "1M"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,10 @@ func TestRcBwLimit(t *testing.T) {
|
|||||||
out, err := call.Fn(context.Background(), in)
|
out, err := call.Fn(context.Background(), in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, rc.Params{
|
assert.Equal(t, rc.Params{
|
||||||
"bytesPerSecond": int64(1048576),
|
"bytesPerSecond": int64(1048576),
|
||||||
"rate": "1M",
|
"bytesPerSecondTx": int64(1048576),
|
||||||
|
"bytesPerSecondRx": int64(1048576),
|
||||||
|
"rate": "1M",
|
||||||
}, out)
|
}, out)
|
||||||
assert.Equal(t, rate.Limit(1048576), TokenBucket.curr[0].Limit())
|
assert.Equal(t, rate.Limit(1048576), TokenBucket.curr[0].Limit())
|
||||||
|
|
||||||
@ -31,8 +33,35 @@ func TestRcBwLimit(t *testing.T) {
|
|||||||
out, err = call.Fn(context.Background(), in)
|
out, err = call.Fn(context.Background(), in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, rc.Params{
|
assert.Equal(t, rc.Params{
|
||||||
"bytesPerSecond": int64(1048576),
|
"bytesPerSecond": int64(1048576),
|
||||||
"rate": "1M",
|
"bytesPerSecondTx": int64(1048576),
|
||||||
|
"bytesPerSecondRx": int64(1048576),
|
||||||
|
"rate": "1M",
|
||||||
|
}, out)
|
||||||
|
|
||||||
|
// Set
|
||||||
|
in = rc.Params{
|
||||||
|
"rate": "10M:1M",
|
||||||
|
}
|
||||||
|
out, err = call.Fn(context.Background(), in)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, rc.Params{
|
||||||
|
"bytesPerSecond": int64(10485760),
|
||||||
|
"bytesPerSecondTx": int64(10485760),
|
||||||
|
"bytesPerSecondRx": int64(1048576),
|
||||||
|
"rate": "10M:1M",
|
||||||
|
}, out)
|
||||||
|
assert.Equal(t, rate.Limit(10485760), TokenBucket.curr[0].Limit())
|
||||||
|
|
||||||
|
// Query
|
||||||
|
in = rc.Params{}
|
||||||
|
out, err = call.Fn(context.Background(), in)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, rc.Params{
|
||||||
|
"bytesPerSecond": int64(10485760),
|
||||||
|
"bytesPerSecondTx": int64(10485760),
|
||||||
|
"bytesPerSecondRx": int64(1048576),
|
||||||
|
"rate": "10M:1M",
|
||||||
}, out)
|
}, out)
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
@ -42,8 +71,10 @@ func TestRcBwLimit(t *testing.T) {
|
|||||||
out, err = call.Fn(context.Background(), in)
|
out, err = call.Fn(context.Background(), in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, rc.Params{
|
assert.Equal(t, rc.Params{
|
||||||
"bytesPerSecond": int64(-1),
|
"bytesPerSecond": int64(-1),
|
||||||
"rate": "off",
|
"bytesPerSecondTx": int64(-1),
|
||||||
|
"bytesPerSecondRx": int64(-1),
|
||||||
|
"rate": "off",
|
||||||
}, out)
|
}, out)
|
||||||
assert.Nil(t, TokenBucket.curr[0])
|
assert.Nil(t, TokenBucket.curr[0])
|
||||||
|
|
||||||
@ -52,8 +83,10 @@ func TestRcBwLimit(t *testing.T) {
|
|||||||
out, err = call.Fn(context.Background(), in)
|
out, err = call.Fn(context.Background(), in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, rc.Params{
|
assert.Equal(t, rc.Params{
|
||||||
"bytesPerSecond": int64(-1),
|
"bytesPerSecond": int64(-1),
|
||||||
"rate": "off",
|
"bytesPerSecondTx": int64(-1),
|
||||||
|
"bytesPerSecondRx": int64(-1),
|
||||||
|
"rate": "off",
|
||||||
}, out)
|
}, out)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,56 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BwPair represents an upload and a download bandwidth
|
||||||
|
type BwPair struct {
|
||||||
|
Tx SizeSuffix // upload bandwidth
|
||||||
|
Rx SizeSuffix // download bandwidth
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns a printable representation of a BwPair
|
||||||
|
func (bp *BwPair) String() string {
|
||||||
|
var out strings.Builder
|
||||||
|
out.WriteString(bp.Tx.String())
|
||||||
|
if bp.Rx != bp.Tx {
|
||||||
|
out.WriteRune(':')
|
||||||
|
out.WriteString(bp.Rx.String())
|
||||||
|
}
|
||||||
|
return out.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the bandwidth from a string which is either
|
||||||
|
// SizeSuffix or SizeSuffix:SizeSuffix (for tx:rx bandwidth)
|
||||||
|
func (bp *BwPair) Set(s string) (err error) {
|
||||||
|
colon := strings.Index(s, ":")
|
||||||
|
stx, srx := s, ""
|
||||||
|
if colon >= 0 {
|
||||||
|
stx, srx = s[:colon], s[colon+1:]
|
||||||
|
}
|
||||||
|
err = bp.Tx.Set(stx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if colon < 0 {
|
||||||
|
bp.Rx = bp.Tx
|
||||||
|
} else {
|
||||||
|
err = bp.Rx.Set(srx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns true if either of the bandwidth limits are set
|
||||||
|
func (bp *BwPair) IsSet() bool {
|
||||||
|
return bp.Tx > 0 || bp.Rx > 0
|
||||||
|
}
|
||||||
|
|
||||||
// BwTimeSlot represents a bandwidth configuration at a point in time.
|
// BwTimeSlot represents a bandwidth configuration at a point in time.
|
||||||
type BwTimeSlot struct {
|
type BwTimeSlot struct {
|
||||||
DayOfTheWeek int
|
DayOfTheWeek int
|
||||||
HHMM int
|
HHMM int
|
||||||
Bandwidth SizeSuffix
|
Bandwidth BwPair
|
||||||
}
|
}
|
||||||
|
|
||||||
// BwTimetable contains all configured time slots.
|
// BwTimetable contains all configured time slots.
|
||||||
@ -21,11 +66,18 @@ type BwTimetable []BwTimeSlot
|
|||||||
|
|
||||||
// String returns a printable representation of BwTimetable.
|
// String returns a printable representation of BwTimetable.
|
||||||
func (x BwTimetable) String() string {
|
func (x BwTimetable) String() string {
|
||||||
ret := []string{}
|
var out strings.Builder
|
||||||
|
bwOnly := len(x) == 1 && x[0].DayOfTheWeek == 0 && x[0].HHMM == 0
|
||||||
for _, ts := range x {
|
for _, ts := range x {
|
||||||
ret = append(ret, fmt.Sprintf("%s-%04.4d,%s", time.Weekday(ts.DayOfTheWeek), ts.HHMM, ts.Bandwidth.String()))
|
if out.Len() != 0 {
|
||||||
|
out.WriteRune(' ')
|
||||||
|
}
|
||||||
|
if !bwOnly {
|
||||||
|
_, _ = fmt.Fprintf(&out, "%s-%02d:%02d,", time.Weekday(ts.DayOfTheWeek).String()[:3], ts.HHMM/100, ts.HHMM%100)
|
||||||
|
}
|
||||||
|
out.WriteString(ts.Bandwidth.String())
|
||||||
}
|
}
|
||||||
return strings.Join(ret, " ")
|
return out.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic hour format checking
|
// Basic hour format checking
|
||||||
@ -174,7 +226,7 @@ func timeDiff(lateDayOfWeekHHMM int, earlyDayOfWeekHHMM int) int {
|
|||||||
func (x BwTimetable) LimitAt(tt time.Time) BwTimeSlot {
|
func (x BwTimetable) LimitAt(tt time.Time) BwTimeSlot {
|
||||||
// If the timetable is empty, we return an unlimited BwTimeSlot starting at Sunday midnight.
|
// If the timetable is empty, we return an unlimited BwTimeSlot starting at Sunday midnight.
|
||||||
if len(x) == 0 {
|
if len(x) == 0 {
|
||||||
return BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: -1}
|
return BwTimeSlot{Bandwidth: BwPair{-1, -1}}
|
||||||
}
|
}
|
||||||
|
|
||||||
dayOfWeekHHMM := int(tt.Weekday())*10000 + tt.Hour()*100 + tt.Minute()
|
dayOfWeekHHMM := int(tt.Weekday())*10000 + tt.Hour()*100 + tt.Minute()
|
||||||
|
@ -17,105 +17,241 @@ func TestBwTimetableSet(t *testing.T) {
|
|||||||
in string
|
in string
|
||||||
want BwTimetable
|
want BwTimetable
|
||||||
err bool
|
err bool
|
||||||
|
out string
|
||||||
}{
|
}{
|
||||||
{"", BwTimetable{}, true},
|
{"", BwTimetable{}, true, ""},
|
||||||
{"bad,bad", BwTimetable{}, true},
|
{"bad,bad", BwTimetable{}, true, ""},
|
||||||
{"bad bad", BwTimetable{}, true},
|
{"bad bad", BwTimetable{}, true, ""},
|
||||||
{"bad", BwTimetable{}, true},
|
{"bad", BwTimetable{}, true, ""},
|
||||||
{"1000X", BwTimetable{}, true},
|
{"1000X", BwTimetable{}, true, ""},
|
||||||
{"2401,666", BwTimetable{}, true},
|
{"2401,666", BwTimetable{}, true, ""},
|
||||||
{"1061,666", BwTimetable{}, true},
|
{"1061,666", BwTimetable{}, true, ""},
|
||||||
{"bad-10:20,666", BwTimetable{}, true},
|
{"bad-10:20,666", BwTimetable{}, true, ""},
|
||||||
{"Mon-bad,666", BwTimetable{}, true},
|
{"Mon-bad,666", BwTimetable{}, true, ""},
|
||||||
{"Mon-10:20,bad", BwTimetable{}, true},
|
{"Mon-10:20,bad", BwTimetable{}, true, ""},
|
||||||
{
|
{
|
||||||
"0",
|
"0",
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: 0},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: BwPair{Tx: 0, Rx: 0}},
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
"0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"666",
|
"666",
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
"666k",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"666:333",
|
||||||
|
BwTimetable{
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
"666k:333k",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"10:20,666",
|
"10:20,666",
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1020, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1020, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1020, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1020, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1020, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1020, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1020, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
"Sun-10:20,666k Mon-10:20,666k Tue-10:20,666k Wed-10:20,666k Thu-10:20,666k Fri-10:20,666k Sat-10:20,666k",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"10:20,666:333",
|
||||||
|
BwTimetable{
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1020, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
"Sun-10:20,666k:333k Mon-10:20,666k:333k Tue-10:20,666k:333k Wed-10:20,666k:333k Thu-10:20,666k:333k Fri-10:20,666k:333k Sat-10:20,666k:333k",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"11:00,333 13:40,666 23:50,10M 23:59,off",
|
"11:00,333 13:40,666 23:50,10M 23:59,off",
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2359, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2359, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2359, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2359, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2359, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2359, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2359, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
"Sun-11:00,333k Mon-11:00,333k Tue-11:00,333k Wed-11:00,333k Thu-11:00,333k Fri-11:00,333k Sat-11:00,333k Sun-13:40,666k Mon-13:40,666k Tue-13:40,666k Wed-13:40,666k Thu-13:40,666k Fri-13:40,666k Sat-13:40,666k Sun-23:50,10M Mon-23:50,10M Tue-23:50,10M Wed-23:50,10M Thu-23:50,10M Fri-23:50,10M Sat-23:50,10M Sun-23:59,off Mon-23:59,off Tue-23:59,off Wed-23:59,off Thu-23:59,off Fri-23:59,off Sat-23:59,off",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Mon-11:00,333 Tue-13:40,666 Fri-00:00,10M Sat-10:00,off Sun-23:00,666",
|
"11:00,333:666 13:40,666:off 23:50,10M:1M 23:59,off:10M",
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: 10 * 1024 * 1024}},
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
"Sun-11:00,333k:666k Mon-11:00,333k:666k Tue-11:00,333k:666k Wed-11:00,333k:666k Thu-11:00,333k:666k Fri-11:00,333k:666k Sat-11:00,333k:666k Sun-13:40,666k:off Mon-13:40,666k:off Tue-13:40,666k:off Wed-13:40,666k:off Thu-13:40,666k:off Fri-13:40,666k:off Sat-13:40,666k:off Sun-23:50,10M:1M Mon-23:50,10M:1M Tue-23:50,10M:1M Wed-23:50,10M:1M Thu-23:50,10M:1M Fri-23:50,10M:1M Sat-23:50,10M:1M Sun-23:59,off:10M Mon-23:59,off:10M Tue-23:59,off:10M Wed-23:59,off:10M Thu-23:59,off:10M Fri-23:59,off:10M Sat-23:59,off:10M",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Mon-11:00,333 Tue-13:40,666 Fri-00:00,10M 00:01,off Sun-23:00,666",
|
"Mon-11:00,333 Tue-13:40,666:333 Fri-00:00,10M Sat-10:00,off Sun-23:00,666",
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1, Bandwidth: -1},
|
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1, Bandwidth: -1},
|
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1, Bandwidth: -1},
|
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1, Bandwidth: -1},
|
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1, Bandwidth: -1},
|
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: 666 * 1024},
|
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
"Mon-11:00,333k Tue-13:40,666k:333k Fri-00:00,10M Sat-10:00,off Sun-23:00,666k",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Mon-11:00,333 Tue-13:40,666 Fri-00:00,10M 00:01,off Sun-23:00,666:off",
|
||||||
|
BwTimetable{
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: -1}},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
"Mon-11:00,333k Tue-13:40,666k Fri-00:00,10M Sun-00:01,off Mon-00:01,off Tue-00:01,off Wed-00:01,off Thu-00:01,off Fri-00:01,off Sat-00:01,off Sun-23:00,666k:off",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// from the docs
|
||||||
|
"08:00,512 12:00,10M 13:00,512 18:00,30M 23:00,off",
|
||||||
|
BwTimetable{
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 800, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 800, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 800, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 800, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 800, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 800, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 800, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1200, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1200, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1200, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1200, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1200, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1200, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1200, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1800, Bandwidth: BwPair{Tx: 30 * 1024 * 1024, Rx: 30 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1800, Bandwidth: BwPair{Tx: 30 * 1024 * 1024, Rx: 30 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1800, Bandwidth: BwPair{Tx: 30 * 1024 * 1024, Rx: 30 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1800, Bandwidth: BwPair{Tx: 30 * 1024 * 1024, Rx: 30 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1800, Bandwidth: BwPair{Tx: 30 * 1024 * 1024, Rx: 30 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1800, Bandwidth: BwPair{Tx: 30 * 1024 * 1024, Rx: 30 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1800, Bandwidth: BwPair{Tx: 30 * 1024 * 1024, Rx: 30 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2300, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2300, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2300, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2300, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2300, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2300, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
"Sun-08:00,512k Mon-08:00,512k Tue-08:00,512k Wed-08:00,512k Thu-08:00,512k Fri-08:00,512k Sat-08:00,512k Sun-12:00,10M Mon-12:00,10M Tue-12:00,10M Wed-12:00,10M Thu-12:00,10M Fri-12:00,10M Sat-12:00,10M Sun-13:00,512k Mon-13:00,512k Tue-13:00,512k Wed-13:00,512k Thu-13:00,512k Fri-13:00,512k Sat-13:00,512k Sun-18:00,30M Mon-18:00,30M Tue-18:00,30M Wed-18:00,30M Thu-18:00,30M Fri-18:00,30M Sat-18:00,30M Sun-23:00,off Mon-23:00,off Tue-23:00,off Wed-23:00,off Thu-23:00,off Fri-23:00,off Sat-23:00,off",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// from the docs
|
||||||
|
"Mon-00:00,512 Fri-23:59,10M Sat-10:00,1M Sun-20:00,off",
|
||||||
|
BwTimetable{
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 0, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2359, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2000, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
"Mon-00:00,512k Fri-23:59,10M Sat-10:00,1M Sun-20:00,off",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// from the docs
|
||||||
|
"Mon-00:00,512 12:00,1M Sun-20:00,off",
|
||||||
|
BwTimetable{
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 0, Bandwidth: BwPair{Tx: 512 * 1024, Rx: 512 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1200, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1200, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1200, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1200, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1200, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1200, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1200, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 1024 * 1024}},
|
||||||
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2000, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
"Mon-00:00,512k Sun-12:00,1M Mon-12:00,1M Tue-12:00,1M Wed-12:00,1M Thu-12:00,1M Fri-12:00,1M Sat-12:00,1M Sun-20:00,off",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
tt := BwTimetable{}
|
tt := BwTimetable{}
|
||||||
@ -126,6 +262,7 @@ func TestBwTimetableSet(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
assert.Equal(t, test.want, tt)
|
assert.Equal(t, test.want, tt)
|
||||||
|
assert.Equal(t, test.out, tt.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,189 +275,189 @@ func TestBwTimetableLimitAt(t *testing.T) {
|
|||||||
{
|
{
|
||||||
BwTimetable{},
|
BwTimetable{},
|
||||||
time.Date(2017, time.April, 20, 15, 0, 0, 0, time.UTC),
|
time.Date(2017, time.April, 20, 15, 0, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 0, Bandwidth: BwPair{Tx: -1, Rx: -1}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 20, 15, 0, 0, 0, time.UTC),
|
time.Date(2017, time.April, 20, 15, 0, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 666 * 1024}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 20, 10, 15, 0, 0, time.UTC),
|
time.Date(2017, time.April, 20, 10, 15, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 20, 11, 0, 0, 0, time.UTC),
|
time.Date(2017, time.April, 20, 11, 0, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 20, 13, 1, 0, 0, time.UTC),
|
time.Date(2017, time.April, 20, 13, 1, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2301, Bandwidth: BwPair{Tx: 1024 * 1024, Rx: 102 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 20, 23, 59, 0, 0, time.UTC),
|
time.Date(2017, time.April, 20, 23, 59, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: -1, Rx: 1024 * 1024}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: BwPair{Tx: -1, Rx: 100 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 20, 23, 59, 0, 0, time.UTC),
|
time.Date(2017, time.April, 20, 23, 59, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: BwPair{Tx: -1, Rx: 100 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 21, 23, 59, 0, 0, time.UTC),
|
time.Date(2017, time.April, 21, 23, 59, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
BwTimetable{
|
BwTimetable{
|
||||||
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: 333 * 1024},
|
BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 33 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: 10 * 1024 * 1024},
|
BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 1 * 1024 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: -1},
|
BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: BwPair{Tx: -1, Rx: 100 * 1024}},
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
},
|
},
|
||||||
time.Date(2017, time.April, 17, 10, 59, 0, 0, time.UTC),
|
time.Date(2017, time.April, 17, 10, 59, 0, 0, time.UTC),
|
||||||
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: 666 * 1024},
|
BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 66 * 1024}},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
slot := test.tt.LimitAt(test.now)
|
slot := test.tt.LimitAt(test.now)
|
||||||
|
@ -1079,13 +1079,13 @@ func TestSyncWithMaxDuration(t *testing.T) {
|
|||||||
maxDuration := 250 * time.Millisecond
|
maxDuration := 250 * time.Millisecond
|
||||||
ci.MaxDuration = maxDuration
|
ci.MaxDuration = maxDuration
|
||||||
bytesPerSecond := 300
|
bytesPerSecond := 300
|
||||||
accounting.TokenBucket.SetBwLimit(fs.SizeSuffix(bytesPerSecond))
|
accounting.TokenBucket.SetBwLimit(fs.BwPair{Tx: fs.SizeSuffix(bytesPerSecond), Rx: fs.SizeSuffix(bytesPerSecond)})
|
||||||
oldTransfers := ci.Transfers
|
oldTransfers := ci.Transfers
|
||||||
ci.Transfers = 1
|
ci.Transfers = 1
|
||||||
defer func() {
|
defer func() {
|
||||||
ci.MaxDuration = 0 // reset back to default
|
ci.MaxDuration = 0 // reset back to default
|
||||||
ci.Transfers = oldTransfers
|
ci.Transfers = oldTransfers
|
||||||
accounting.TokenBucket.SetBwLimit(fs.SizeSuffix(0))
|
accounting.TokenBucket.SetBwLimit(fs.BwPair{Tx: -1, Rx: -1})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// 5 files of 60 bytes at 60 bytes/s 5 seconds
|
// 5 files of 60 bytes at 60 bytes/s 5 seconds
|
||||||
|
Loading…
Reference in New Issue
Block a user