How to use the networkml.parsers.pcap.session_sequence.create_dataset function in networkml

To help you get started, we’ve selected a few networkml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CyberReboot / NetworkML / networkml / algorithms / sos / eval_SoSModel.py View on Github external
def eval_pcap(pcap, labels, time_const, label=None, rnn_size=100, model_path='networkml/trained_models/onelayer/OneLayerModel.pkl', model_type='randomforest'):
    logger = logging.getLogger(__name__)
    try:
        if 'LOG_LEVEL' in os.environ and os.environ['LOG_LEVEL'] != '':
            logger.setLevel(os.environ['LOG_LEVEL'])
    except Exception as e:  # pragma: no cover
        logger.error(
            'Unable to set logging level because: {0} defaulting to INFO.'.format(str(e)))
    data = create_dataset(pcap, time_const, label=label,
                          model_path=model_path, model_type=model_type)
    # Create an iterator
    iterator = BatchIterator(
        data,
        labels,
        perturb_types=['random data']
    )
    logger.debug('Created iterator')
    rnnmodel = SoSModel(rnn_size=rnn_size, label_size=len(labels))
    logger.debug('Created model')
    rnnmodel.load('networkml/trained_models/sos/SoSmodel')
    logger.debug('Loaded model')

    X_list = iterator.X
    L_list = iterator.L
    sessions = iterator.sessions
github CyberReboot / NetworkML / networkml / algorithms / sos / train_SoSModel.py View on Github external
def train(data_dir, sos_model, time_const, rnn_size, labels, save_path):
    logger = logging.getLogger(__name__)
    try:
        if 'LOG_LEVEL' in os.environ and os.environ['LOG_LEVEL'] != '':
            logger.setLevel(os.environ['LOG_LEVEL'])
    except Exception as e:  # pragma: no cover
        logger.error(
            'Unable to set logging level because: {0} defaulting to INFO.'.format(str(e)))

    data = create_dataset(data_dir, time_const)
    # Create the training data
    logger.info('Saving data to %s', save_path)
    with open(save_path, 'wb') as handle:
        pickle.dump(data, handle, protocol=pickle.HIGHEST_PROTOCOL)

    logger.info('Loaded training data')
    # Create an iterator
    iterator = BatchIterator(
        data,
        labels,
        perturb_types=['random data', 'port swap', 'direction_swap']
    )
    logger.info('Created iterator')
    rnnmodel = SoSModel(rnn_size=100, label_size=len(labels))
    logger.info('Created model')
    try: