How to use AS_PATH attribute in scapy for BGP?

Question:

I try to set the AS_PATH attribute:

setAS=BGPPathAttr(type_flags="Transitive", type_code="AS_PATH",attr_len=None,attribute=None)

But Wireshark is saying that it is a malformed AS_PATH attribute.

I already have the other mandatory attributes in my Update message packet and they’re doing well.

How to send a BGP Update message crafted packet with correct attributes?

Asked By: Luiz Buzza

||

Answers:

I did like this and works.

setAS = BGPPathAttr(
    type_flags="Transitive",
    type_code="AS_PATH",
    attr_len=None,
    attribute=BGPPAAS4BytesPath(
        segments=BGPPAAS4BytesPath().ASPathSegment(
                                                    segment_type=2(AS_SEQUENCE), segment_length=None, segment_value=[1234]
                                                )
                                )
    )

When we have variables asking the "length", please use "None".

Answered By: Luiz Buzza
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.