Skip to content

Commit

Permalink
add configuration options documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lwlee2608 committed Nov 27, 2023
1 parent c9f596b commit b6e9c93
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 10 deletions.
63 changes: 54 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import diam from 'k6/x/diameter'
import avp from 'k6/x/diameter/avp'
import dict from 'k6/x/diameter/dict'
import { cmd, app, code, flag, vendor } from './diam/const.js'

import { check } from 'k6'

let data = diam.DataType()

let client = diam.Client({
authApplicationId: [app.ChargingControl],
})
Expand Down Expand Up @@ -55,6 +55,15 @@ Use your custom k6 binary to run an example k6 script.
./bin/k6 run example/example.js
```

## Docker
Alternatively, you may run xk6-diameter packaged in Docker using the following command:
```bash
docker run \
--net=host \
-v $(pwd)/example:/mnt/example \
ghcr.io/matrixxsoftware/xk6-diameter run --logformat=raw /mnt/example/example.js
```

## Generator

There are thousands of AVPs, each with a unique avp-code and vendor-id. To aid readability and enhance the developer experience, we recommend defining them as constants in a separate file, for example, using `diam/const.js`.
Expand All @@ -69,11 +78,47 @@ The CLI also supports generating additional AVPs that are not defined in the def
./bin/dict_generator -output example/diam/const.js -dictionary dict/extra.xml
```

## Docker
Run xk6-diameter docker using the following command:
```bash
docker run \
--net=host \
-v $(pwd)/example:/mnt/example \
ghcr.io/matrixxsoftware/xk6-diameter run --logformat=raw /mnt/example/example.js
```
Configurations

## Configuration Options

### Diameter Config

| Field Name | JavaScript Type | Description |
| ------------------------------ | ----------------------------- | ----------------------------------------------------- |
| RequestTimeout | duration | Timeout for each request |
| MaxRetransmits | number | Maximum number of message retransmissions |
| RetransmitInterval | duration | Interval between message retransmissions |
| EnableWatchdog | boolean | Flag to enable automatic DWR (Diameter Watchdog Request) |
| WatchdogInterval | duration | Interval between sending DWRs |
| WatchdogStream | number | Stream ID for sending DWRs (for multistreaming protocols) |
| SupportedVendorID | number array | List of supported vendor IDs |
| AcctApplicationID | number array | List of accounting application IDs |
| AuthApplicationID | number array | List of authentication application IDs |
| VendorSpecificApplicationID | number array | List of vendor-specific application IDs |
| CapabilityExchange | object | Configuration for capability exchange |

### Capability Exchange Config

| Field Name | JavaScript Type | Description |
| ------------------------------ | ----------------------------- | ----------------------------------------------------- |
| VendorID | number | Vendor ID |
| ProductName | string | Name of the product |
| OriginHost | string | Host name of the origin |
| OriginRealm | string | Realm of the origin |
| FirmwareRevision | number | Firmware revision number |
| HostIPAddresses | string array | List of host IP addresses |

### Example
The following example demonstrates how to create a Diameter client in k6 with various configuration options.

```go
let client = diam.Client({
requestTimeout: "50ms",
enableWatchdog: false,
authApplicationId: [app.ChargingControl],
capabilityExchange: {
vendorId: 35838,
},
})
```
5 changes: 4 additions & 1 deletion example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import diam from 'k6/x/diameter'
import avp from 'k6/x/diameter/avp'
import dict from 'k6/x/diameter/dict'
import { cmd, app, code, flag, vendor } from './diam/const.js'

import { check } from 'k6'

export let options = {
Expand All @@ -14,10 +13,14 @@ export let options = {
// dict.load("dict/extra.xml")

let data = diam.DataType()

let client = diam.Client({
requestTimeout: "50ms",
enableWatchdog: false,
authApplicationId: [app.ChargingControl],
capabilityExchange: {
vendorId: 35838,
},
})

export default function () {
Expand Down

0 comments on commit b6e9c93

Please sign in to comment.