<commit_before>#!/usr/bin/env python
#
# Copyright 2015,2016,2018 <NAME>
# Copyright 2018 Viveris Technologies
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#

"""
Introduction
------------

The program takes a flow of IP packets as input (in the PCAP format) and
tests the ROHC compression/decompression library with them. The program
also tests the feedback mechanism.

Details
-------

The program defines two compressor/decompressor pairs and sends the flow
of IP packet through Compressor 1 and Decompressor 1 (flow A) and through
Compressor 2 and Decompressor 2 (flow B). See the figure below.

The feedback for flow A is sent by Decompressor 1 to Compressor 1 via
Compressor 2 and Decompressor 2. The feedback for flow  B is sent by
Decompressor 2 to Compressor 2 via Compressor 1 and Decompressor 1.

         +-- IP packets                             IP packets <--+
         |   flow A (input)                    flow A (output)    |
         |                                                        |
         |    +----------------+    ROHC    +----------------+    |
         +--> |                |            |                | ---+
              |  Compressor 1  | ---------> | Decompressor 1 |
         +--> |                |            |                | ---+
         |    +----------------+            +----------------+    |
feedback |                                                        | feedback
flow B   |                                                        | flow A
         |    +----------------+     ROHC   +----------------+    |
         +--- |                |            |                | <--+
              | Decompressor 2 | <--------- |  Compressor 2  |
         +--- |                |            |                | <--+
         |    +----------------+            +----------------+    |
         |                                                        |
         +--> IP packets                             IP packets --+
              flow B (output)                    flow B (input)

Checks
------

The program checks for the status of the compression and decompression
processes. The program also compares input IP packets from flow A (resp.
flow B) with output IP packets from flow A (resp. flow B).

The program optionally compares the ROHC packets generated with the ones
given as input to the program.

Output
------

The program outputs the compression/decompression/comparison status of every
packets of flow A and flow B on stdout. It also outputs the log of the
different processes (startup, compression, decompression, comparison and
shutdown).
"""

from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from builtins import range
from builtins import int
from future import standard_library
standard_library.install_aliases()

import sys
import pcap

from rohc import *
from RohcCompressor import *
from RohcDecompressor import *

ETHER_HDR_LEN       = 14 # bytes
ETHER_FRAME_MIN_LEN = 60 # bytes

ALL_PROFILES_V1 = [ROHC_PROFILE_UNCOMPRESSED, \
                   ROHC_PROFILE_RTP, \
                   ROHC_PROFILE_UDP, \
                   ROHC_PROFILE_ESP, \
                   ROHC_PROFILE_IP, \
                   ROHC_PROFILE_TCP, \
                   ROHC_PROFILE_UDPLITE, \
                  ]

ALL_PROFILES_V2 = [ROHC_PROFILE_UNCOMPRESSED, \
                   ROHCv2_PROFILE_IP, \
                   ROHCv2_PROFILE_IP_UDP, \
                   ROHCv2_PROFILE_IP_ESP, \
                   ROHC_PROFILE_TCP, \
                  ]


def usage():
    print("ROHC non-regression tool: test the Python binding of the ROHC")
    print("                          library with a flow of network packets")<commit_msg>ROHCv2: python: enable the ROHCv2 IP/UDP/RTP profile<commit_after>#!/usr/bin/env python
#
# Copyright 2015,2016,2018 <NAME>
# Copyright 2018 Viveris Technologies
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#

"""
Introduction
------------

The program takes a flow of IP packets as input (in the PCAP format) and
tests the ROHC compression/decompression library with them. The program
also tests the feedback mechanism.

Details
-------

The program defines two compressor/decompressor pairs and sends the flow
of IP packet through Compressor 1 and Decompressor 1 (flow A) and through
Compressor 2 and Decompressor 2 (flow B). See the figure below.

The feedback for flow A is sent by Decompressor 1 to Compressor 1 via
Compressor 2 and Decompressor 2. The feedback for flow  B is sent by
Decompressor 2 to Compressor 2 via Compressor 1 and Decompressor 1.

         +-- IP packets                             IP packets <--+
         |   flow A (input)                    flow A (output)    |
         |                                                        |
         |    +----------------+    ROHC    +----------------+    |
         +--> |                |            |                | ---+
              |  Compressor 1  | ---------> | Decompressor 1 |
         +--> |                |            |                | ---+
         |    +----------------+            +----------------+    |
feedback |                                                        | feedback
flow B   |                                                        | flow A
         |    +----------------+     ROHC   +----------------+    |
         +--- |                |            |                | <--+
              | Decompressor 2 | <--------- |  Compressor 2  |
         +--- |                |            |                | <--+
         |    +----------------+            +----------------+    |
         |                                                        |
         +--> IP packets                             IP packets --+
              flow B (output)                    flow B (input)

Checks
------

The program checks for the status of the compression and decompression
processes. The program also compares input IP packets from flow A (resp.
flow B) with output IP packets from flow A (resp. flow B).

The program optionally compares the ROHC packets generated with the ones
given as input to the program.

Output
------

The program outputs the compression/decompression/comparison status of every
packets of flow A and flow B on stdout. It also outputs the log of the
different processes (startup, compression, decompression, comparison and
shutdown).
"""

from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from builtins import range
from builtins import int
from future import standard_library
standard_library.install_aliases()

import sys
import pcap

from rohc import *
from RohcCompressor import *
from RohcDecompressor import *

ETHER_HDR_LEN       = 14 # bytes
ETHER_FRAME_MIN_LEN = 60 # bytes

ALL_PROFILES_V1 = [ROHC_PROFILE_UNCOMPRESSED, \
                   ROHC_PROFILE_RTP, \
                   ROHC_PROFILE_UDP, \
                   ROHC_PROFILE_ESP, \
                   ROHC_PROFILE_IP, \
                   ROHC_PROFILE_TCP, \
                   ROHC_PROFILE_UDPLITE, \
                  ]

ALL_PROFILES_V2 = [ROHC_PROFILE_UNCOMPRESSED, \
                   ROHCv2_PROFILE_IP, \
                   ROHCv2_PROFILE_IP_UDP, \
                   ROHCv2_PROFILE_IP_UDP_RTP, \
                   ROHCv2_PROFILE_IP_ESP, \
                   ROHC_PROFILE_TCP, \
                  ]


def usage():
    print("ROHC non-regression tool: test the Python binding of the ROHC")
    print("                          library with a flow of network packets")
{'fraction_non_alphanumeric': 0.09681358943044299, 'fraction_numerical': 0.012323748195847674, 'mean_word_length': 1.505702364394993, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4424315', 'n_tokens_mistral': 2375, 'n_tokens_neox': 2220, 'n_words': 870}