Create a Session with duration
This helps the application to create a QoD session with the required profile for a certain duration.
A QoD session would then be terminated as soon as this time has elapsed.
The application can however terminate the QOD session earlier than the specified duration by using the session.delete()
operation.
Creating a session for a specified duration
You can create a QoD session with duration to instruct how the network should behave during a specified amount of time.
import network_as_code as nac
from network_as_code.models.device import DeviceIpv4Addr
client = nac.NetworkAsCodeClient(...)
# Identify the device with its ID, IP address(es) and optionally, a phone number
device = client.devices.get("device@testcsp.net",
ipv4_address = DeviceIpv4Addr(public_address="233.252.0.2",
private_address="192.0.2.25",
public_port=80),
# The phone number accepts the "+" sign, but not spaces or "()" marks
phone_number = "36721601234567"
)
# Here you can create a QoD session, identify the service IP address(es) and the network profile
session = device.create_qod_session(
service_ipv4="233.252.0.2",
service_ipv6="2001:db8:1234:5678:9abc:def0:fedc:ba98",
profile="DOWNLINK_L_UPLINK_L",
duration=60
)
Device object parameters
The snippet above identified a mobile network device in multiple ways (IP addresses, port, etc). Learn how to create a device object and understand how the DeviceIPv4Addr
model works using NAT technology.
Session duration parameters
What we've just done here is create a QoD session with a determined duration of 60 seconds. Here are the parameters used:
Parameters | Description |
---|---|
service_ipv4 | The service identified by the application IPv4 address and Port (optionally). |
service_ipv6 | The service identified by the application IPv6 address and Port (optionally). |
profile | The QoS profile that will ensure a maximum bandwidth between these two points. |
duration | This will tell when the QoD session should end. |
Keywords:
If you want to create the QoD session object without passing its parameters by name (keywords), then remember that their ordering will be important for your code to work properly. In which case, you will need to inform the QoS profile first, before the IP address(es). For example:
session = device.create_qod_session("DOWNLINK_L_UPLINK_L", "192.0.2.25", "2001:db8:1234:5678:9abc:def0:fedc:ba98", 60)
Keep in mind: The duration is given in seconds with a default value and upper limit at 24 hours. For example, if the duration desired is for one hour, then the parameter in seconds should be
duration=3600
.