Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

NGAP Protocol #251

boardslayer started this conversation in General
Discussion options

Hello, Is it possible to add NGAP protocol support to the kit? It is mainly used in 5G Networks. How would one go about adding support for it?
TIA

You must be logged in to vote

Replies: 1 comment

Comment options

Yes, it would be pretty much welcomed if you could add the protocol support yourself.

To do this, I would suppose this is an application layer protocol, you need to create a skeleton class that represents the protocol itself, a data class that holds the protocol header fields, and a schema class that defines the structure of the protocol.

Schema Class

from pcapkit.corekit.fields.numbers import UInt32Field
from pcapkit.corekit.fields.strings import BytesField
from pcapkit.protocols.schema.schema import Schema, schema_final
@schema_final # this will automatically generate a constructor for this class
class Schema_NGAP(Schema):
	# now you define the fields in order, for example, we say it has firstly two ports then binary data
	port_one = UInt32Field()
	port_two = UInt32Field()
	data = BytesField(lambda: pkt: pkt['__length__'])

for more information on the pkt lambda used in the field definitions, please see the Schema class's documentation

Data Class

from pcapkit.corekit.infoclass import info_final
from pcapkit.protocols.data.protocol import Protocol
@info_final
class Data_NGAP(Protocol):
	port_one: int
	port_two: int
	data: bytes

Skeleton Class

from pcapkit.protocols.application.application import Application
from pcapkit.utilities.exceptions import ProtocolError, UnsupportedCall
class NGAP(Application[Data_GNAP, Schema_NGAP], data=Data_NGAP, schema=Schema_NGAP):
	@property
	def name(self):
		return 'NG Application Protocol'
	def read(self, length: 'Optional[int]' = None, **kwargs: 'Any') -> 'Data_NGAP':
		if length is None:
			length = len(self)
		schema = self.__header__
		# extra handling of data mapping/processing can be done here before storing to the data class
		return Data_NGAP(port_one=schema.port_one, port_two=schema.port_two, data=schema.data)
	def make(...) -> Schema_NGAP': # constructor for the protocol with given args
 		...
		return Schema_NGAP(port_one=..., port_two=..., data=...)

Protocol Registration

If this protocol is wrapped under TCP (or UDP is the same), then you can register it by calling the register method:

from pcapkit.protocols.transport.tcp import TCP
TCP.register(port_number, NGAP)
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /