Answer the question
In order to leave comments, you need to log in
How to generate an Ethernet OAM PDU in Scapy?
Hello! I just can’t catch up with how to form Ethernet OAM packets / PDUs there, specifying their values in the type, subtype, flags, code fields. Is this even possible in Scapy? If not, are there tools that allow you to generate and send such PDUs?
Answer the question
In order to leave comments, you need to log in
Is this even possible in Scapy?You can create a frame using the constructor e=Ether(src='AA:AA:AA:AA:AA:AA',dst='01:80:c2:00:00:02',type=0x8809), and so on set the value of the data field yourself (e.payload=data, where data is of the Packet or str type)
e=Ether(src='AA:AA:AA:AA:AA:AA',dst='01:80:c2:00:00:02',type=0x8809)
class EthernetOAM(Packet):
name='Ethernet OAM'
fields_desc=[
ByteField('Subtype',3),
ByteField('Flags',0),
ByteField('Code',0),
]
OAM=EtherOAM()
OAM.payload="data+padding"
e.payload=OAM
OAM
>>> <EthernetOAM |<Raw load='data+padding' |>>
e
>>> <Ether dst=01:80:c2:00:00:02 src=AA:AA:AA:AA:AA:AA type=0x8809 |<EthernetOAM |<Raw load='data+padding' |>>>
If not, are there tools that allow you to generate and send such PDUs?There are many tools (for example, trafgen or mausezahn as part of the netsniff-ng package), but you will most likely have to form the data field yourself.
Thank you throughtheether! Your answer helped me. I figured out which direction to go)) I'll add it a little more from myself) Maybe someone will need it))
I created a test_packet.py file with something like this
#! /usr/bin/env python
#! /usr/bin/env python
# Set log level to benefit from Scapy warnings
import logging
logging.getLogger("scapy").setLevel(1)
from scapy.all import *
class EthernetOAM(Packet):
name = "Ethernet OAM"
fields_desc = [
XByteField("Subtype", 0x03),
XByteField("Flags1", 0x00),
XByteField("Flags2", 0x02),
XByteField("Code", 0x00)
]
if __name__ == "__main__":
interact(mydict=globals(), mybanner="I am Batman")
#End of file
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question