Giter Site home page Giter Site logo

udp-notif-scapy's Introduction

Scapy generator for UDP-notif

This repository implements a mock generator for YANG-push notifications using UDP-notif transport as defined in draft-ietf-netconf-udp-notif-11. 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.

Dependencies (Tested in Python 3.9.16)

Required libraries are specified in src/requirements.txt

$ pip install -r src/requirements.txt

Usage

4 required arguments:

$ sudo python3 src/main.py <src_ipv4> <dst_ipv4> <port_src> <port_dst>
  • <src_ipv4>: valid source IPv4 address
  • <dst_ipv4>: valid destination IPv4 address
  • <port_src>: source port to be used
  • <port_dst>: destination port to be used

Optional arguments

  • --initial-domain <domain> or -i <domain> : (Integer) initial observation domain id, <domain> >= 0, Default: 0

  • --additional-domains <obs_nb> or -a <obs_nb> : (Integer) amount of additional observation domains, <obs_nb> >= 0, Default: 0

  • --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, cbor]. Default: json.

  • --mtu <value> or -m <value> : (Integer) maximum transmission unit, 16 < <value> < 65535, Default: 1500

  • --waiting-time <time> or -w <time> : (Float) waiting time (in seconds) between two messages, <time> > 0, Default: 0

  • --probability-of-loss <loss> or -p <loss> : (Float) segment loss probability, 0 <= <loss> < 1, Default: 0

  • --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, โš ๏ธ 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 using UDP-notif as transport.

$ sudo python3 src/main.py 192.0.2.65 192.0.2.66 10001 10010

Continuous stream of YANG-push messages RFC8641 using UDP-notif as transport.

$ 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.

$ 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.

The mock generator emulates a subscription to the Xpath /if:interfaces of [email protected]

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]. Note that this new YANG module is defined for test purposes and is not part of any IETF standard RFC.

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, configured subscriptions are configured via Netconf RPC <edit-config>.

Examples of configuration files can be found in configurations.

YANG push notifications workflow

Please find more information about YANG push here.

Docker container

See Docker docs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.