-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from network-analytics/feature/update-yang-module
Feature/update yang module
- Loading branch information
Showing
36 changed files
with
5,693 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,4 +141,4 @@ cython_debug/ | |
*.pcap | ||
pids | ||
.DS_Store | ||
yangs | ||
yangs/yang-push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
# Scapy generator for UDP-notif | ||
|
||
This repository implements a mock generator for UDP-notif messages as defined in [draft-ietf-netconf-udp-notif-08](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-08). This mock generator supports IPv4. | ||
This repository implements a mock generator for YANG-push notifications using UDP-notif transport as defined in [draft-ietf-netconf-udp-notif-09](https://datatracker.ietf.org/doc/draft-ietf-netconf-udp-notif/09/). This mock generator supports IPv4. | ||
|
||
|
||
### Supported IETF RFCs/drafts | ||
|
||
The mock YANG-push notifications uses the following IETF RFCs and drafts. The supported variant is Configured Subscriptions defined in [RFC8641](https://datatracker.ietf.org/doc/rfc8641/). | ||
|
||
- [RFC5277](https://datatracker.ietf.org/doc/rfc5277): Netconf Event Notifications | ||
- [RFC8639](https://datatracker.ietf.org/doc/rfc8639): Subscription to YANG Notifications | ||
- [RFC8641](https://datatracker.ietf.org/doc/rfc8641/): Subscription to YANG Notifications for Datastore Updates (Configured Subscriptions only) | ||
- [draft-ietf-netconf-udp-notif-09](https://datatracker.ietf.org/doc/draft-ietf-netconf-udp-notif/09/): UDP-based Transport for Configured Subscriptions | ||
- [draft-ietf-netconf-distributed-notif-06](https://datatracker.ietf.org/doc/draft-ietf-netconf-distributed-notif/06/): Subscription to Distributed Notifications | ||
- [draft-ahuang-netconf-notif-yang-01](https://datatracker.ietf.org/doc/draft-ahuang-netconf-notif-yang/01/): YANG model for NETCONF Event Notifications | ||
- [draft-tgraf-netconf-notif-sequencing-00](https://datatracker.ietf.org/doc/draft-tgraf-netconf-notif-sequencing/00/): Support of Hostname and Sequencing in YANG Notifications | ||
- [draft-tgraf-yang-push-observation-time-00](https://datatracker.ietf.org/doc/draft-tgraf-yang-push-observation-time/00/): Support of Network Observation Timestamping in YANG Notifications | ||
- [draft-tgraf-netconf-yang-notifications-versioning-03](https://datatracker.ietf.org/doc/draft-tgraf-netconf-yang-notifications-versioning/03/): Support of Versioning in YANG Notifications Subscription | ||
|
||
|
||
## Dependencies (Tested in Python 3.6.8) | ||
Required libraries are specified in `src/requirements.txt` | ||
|
@@ -22,46 +38,130 @@ $ sudo python3 src/main.py <src_ipv4> <dst_ipv4> <port_src> <port_dst> | |
|
||
### Optional arguments | ||
|
||
- `--initial-domain x` or `-i x` : (Integer) initial observation domain id, x >= 0, Default: `0` | ||
- `--initial-domain <domain>` or `-i <domain>` : (Integer) initial observation domain id, `<domain>` >= 0, Default: `0` | ||
|
||
- `--additional-domains x` or `-a x` : (Integer) amount of additional observation domains, x >= 0, Default: `0` | ||
- `--additional-domains <obs_nb>` or `-a <obs_nb>` : (Integer) amount of additional observation domains, `<obs_nb>` >= 0, Default: `0` | ||
|
||
- `--message-amount x` or `-n x` : (Integer) amount of messages to send, x >= 1, Default: `1` | ||
- `--message-amount <msgs>` or `-n <msgs>` : (Integer) amount of notification messages to send, `<msgs>` >= 1, Default: `1` | ||
|
||
- `--encoding <encoding>` or `-e <encoding>`: (String) encoding of the UDP-notif payload. Options: [`json`, `xml`]. Default: `json`. | ||
|
||
- `--mtu x` or `-m x` : (Integer) maximum transmission unit, 16 < x < 65535, Default: `1500` | ||
- `--mtu <value>` or `-m <value>` : (Integer) maximum transmission unit, 16 < `<value>` < 65535, Default: `1500` | ||
|
||
- `--waiting-time f` or `-w f` : (Float) waiting time (in seconds) between two messages, x > 0, Default: `0` | ||
- `--waiting-time <time>` or `-w <time>` : (Float) waiting time (in seconds) between two messages, `<time>` > 0, Default: `0` | ||
|
||
- `--probability-of-loss f` or `-p f` : (Float) segment loss probability, 0 <= x < 1, Default: `0` | ||
- `--probability-of-loss <loss>` or `-p <loss>` : (Float) segment loss probability, 0 <= `<loss>` < 1, Default: `0` | ||
|
||
- `--logging-level s` or `-l s` : (String) logging level, s = none or s = warning or s = info or s = debug, Default: `info` | ||
- `--logging-level <level>` or `-l <level>` : (String) logging level, `<level>` = none or `<level>` = warning or `<level>` = info or `<level>` = debug, Default: `info` | ||
|
||
- `--capture <path>` or `-c <path>` : (String) Save a wireshark capture of the forwarded packets in the `<path>`. Default: `None` (disabled). | ||
|
||
- `--legacy` or `-leg` : Generate legacy headers as defined in [draft-ietf-netconf-udp-pub-channel-05](https://datatracker.ietf.org/doc/draft-ietf-netconf-udp-pub-channel/), /!\ No segmentation is possible. Default: Disabled | ||
- `--legacy` or `-leg` : Generate legacy headers as defined in [draft-ietf-netconf-udp-pub-channel-05](https://datatracker.ietf.org/doc/draft-ietf-netconf-udp-pub-channel/), /!\ No segmentation is possible. Default: Disabled. | ||
|
||
- `--update-yang` or `-upd`: Simulate a YANG module update to a backward compatible YANG module. Default: Disabled. | ||
|
||
## Examples | ||
|
||
One YANG-push message [RFC8641](https://www.rfc-editor.org/rfc/rfc8641) using UDP-notif as transport. | ||
One YANG-push message [RFC8641](https://datatracker.ietf.org/doc/rfc8641) using UDP-notif as transport. | ||
```shell | ||
$ sudo python3 src/main.py 192.0.2.65 192.0.2.66 10001 10010 | ||
``` | ||
|
||
Continuous stream of YANG-push messages [RFC8641](https://www.rfc-editor.org/rfc/rfc8641) using UDP-notif as transport. | ||
Continuous stream of YANG-push messages [RFC8641](https://datatracker.ietf.org/doc/rfc8641) using UDP-notif as transport. | ||
```shell | ||
$ sudo python3 src/main.py 192.0.2.66 192.0.2.66 10001 10010 -n 0 | ||
``` | ||
|
||
### Simulating a YANG subscription update | ||
|
||
This generator can also simulate a YANG module update in YANG-push. | ||
|
||
```shell | ||
$ sudo python3 src/main.py 192.0.2.65 192.0.2.66 10001 10010 -upd | ||
``` | ||
|
||
#### Used YANG modules | ||
|
||
The YANG modules used in [yang/interfaces](./yangs/interfaces/). | ||
|
||
The mock generator emulates a subscription to the Xpath `/if:interfaces` of [[email protected]](./yangs/interfaces/ietf-interfaces%402018-02-20.yang) | ||
|
||
```yang | ||
module: ietf-interfaces | ||
+--rw interfaces | ||
+--rw interface* [name] | ||
+--rw name string | ||
+--rw description? string | ||
+--rw type identityref | ||
+--rw enabled? boolean | ||
+--rw link-up-down-trap-enable? enumeration {if-mib}? | ||
+--ro admin-status enumeration {if-mib}? | ||
+--ro oper-status enumeration | ||
+--ro last-change? yang:date-and-time | ||
+--ro if-index int32 {if-mib}? | ||
+--ro phys-address? yang:phys-address | ||
+--ro higher-layer-if* interface-ref | ||
+--ro lower-layer-if* interface-ref | ||
+--ro speed? yang:gauge64 | ||
+--ro statistics | ||
+--ro discontinuity-time yang:date-and-time | ||
+--ro in-octets? yang:counter64 | ||
+--ro in-unicast-pkts? yang:counter64 | ||
+--ro in-broadcast-pkts? yang:counter64 | ||
+--ro in-multicast-pkts? yang:counter64 | ||
+--ro in-discards? yang:counter32 | ||
+--ro in-errors? yang:counter32 | ||
+--ro in-unknown-protos? yang:counter32 | ||
+--ro out-octets? yang:counter64 | ||
+--ro out-unicast-pkts? yang:counter64 | ||
+--ro out-broadcast-pkts? yang:counter64 | ||
+--ro out-multicast-pkts? yang:counter64 | ||
+--ro out-discards? yang:counter32 | ||
+--ro out-errors? yang:counter32 | ||
``` | ||
|
||
After the update of the subscription, the generator emulates pushing a new versioned of the same YANG module with a new leaf `mtu`. This new YANG module is defined in [[email protected]](./yangs/interfaces/ietf-interfaces%402023-04-30.yang). Note that this new YANG module is defined for test purposes and is not part of any IETF standard RFC. | ||
|
||
```yang | ||
module: ietf-interfaces | ||
+--rw interfaces | ||
+--rw interface* [name] | ||
+--rw name string | ||
+--rw description? string | ||
+--rw mtu uint32 | ||
+--rw type identityref | ||
+--rw enabled? boolean | ||
+--rw link-up-down-trap-enable? enumeration {if-mib}? | ||
+--ro admin-status enumeration {if-mib}? | ||
+--ro oper-status enumeration | ||
+--ro last-change? yang:date-and-time | ||
+--ro if-index int32 {if-mib}? | ||
+--ro phys-address? yang:phys-address | ||
+--ro higher-layer-if* interface-ref | ||
+--ro lower-layer-if* interface-ref | ||
+--ro speed? yang:gauge64 | ||
+--ro statistics | ||
+--ro discontinuity-time yang:date-and-time | ||
+--ro in-octets? yang:counter64 | ||
+--ro in-unicast-pkts? yang:counter64 | ||
+--ro in-broadcast-pkts? yang:counter64 | ||
+--ro in-multicast-pkts? yang:counter64 | ||
+--ro in-discards? yang:counter32 | ||
+--ro in-errors? yang:counter32 | ||
+--ro in-unknown-protos? yang:counter32 | ||
+--ro out-octets? yang:counter64 | ||
+--ro out-unicast-pkts? yang:counter64 | ||
+--ro out-broadcast-pkts? yang:counter64 | ||
+--ro out-multicast-pkts? yang:counter64 | ||
+--ro out-discards? yang:counter32 | ||
+--ro out-errors? yang:counter32 | ||
``` | ||
|
||
## NETCONF configuration XML examples | ||
|
||
As defined in [RFC8641](https://www.rfc-editor.org/rfc/rfc8641), configured subscriptions are configured via Netconf RPC `<edit-config>`. | ||
As defined in [RFC8641](https://datatracker.ietf.org/doc/rfc8641), configured subscriptions are configured via Netconf RPC `<edit-config>`. | ||
|
||
Examples of configuration files can be found in [configurations](./src/resources/xml/subscription/). | ||
|
||
## Docker container | ||
See [Docker docs](docker) | ||
|
||
## Launch multiple simulations | ||
- `./launch_multiple.sh <number_messages>` : launches multiple instances of the generator simuling multiple source ips and ports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/resources/json/notifications/push-change-update-subscription.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...urces/json/notifications/push-update.json → ...ces/json/notifications/push-update-1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"ietf-notification:notification": { | ||
"eventTime": "2023-03-25T08:30:11.22Z", | ||
"ietf-notification-sequencing:sysName": "example-router", | ||
"ietf-notification-sequencing:sequenceNumber": 1, | ||
"ietf-yang-push:push-update": { | ||
"id": 6666, | ||
"ietf-yang-push-netobs-timestamping:observation-time": "2023-03-25T08:30:11.22Z", | ||
"datastore-contents": { | ||
"ietf-interfaces:interfaces": [ | ||
{ | ||
"interface": { | ||
"name": "eth0", | ||
"type": "iana-if-type:ethernetCsmacd", | ||
"oper-status": "up", | ||
"mtu": 1500 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
{ | ||
"ietf-notification:notification": { | ||
"eventTime": "2023-03-25T08:30:11.22Z", | ||
"ietf-notification-sequencing:sysName": "example-router", | ||
"ietf-notification-sequencing:sequenceNumber": 1, | ||
"ietf-subscribed-notification:subscription-modified": { | ||
"id": 6666, | ||
"ietf-yang-push:datastore": "ietf-datastores:operational", | ||
"ietf-yang-push:datastore-xpath-filter": "/if:interfaces", | ||
"ietf-yang-push-revision:revision": "2014-05-08", | ||
"ietf-distributed-notif:message-observation-domain-id": [1,2], | ||
"transport": "ietf-udp-notif-transport:udp-notif", | ||
"encoding": "encode-json", | ||
"ietf-yang-push:periodic": { | ||
"ietf-yang-push:period": 100 | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/resources/json/notifications/subscription-started_with_anchor-time.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/resources/json/notifications/subscription-terminated.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.