Creating TCP packet with POX

Daniel

I'm trying to create a TCP packet with POX controller and sending it to one of the switches.

This is how the packet is created:

        payload = "MESSAGE"
        tcp_packet = tcp()
        tcp_packet.srcport = 10000
        tcp_packet.dstport = 10001
        tcp_packet.payload = payload
        tcp_packet.seq = 100

        ipv4_packet = ipv4()
        ipv4_packet.iplen = ipv4.MIN_LEN + len(tcp_packet)
        ipv4_packet.protocol = ipv4.TCP_PROTOCOL
        ipv4_packet.dstip = IPAddr('10.0.0.5')
        ipv4_packet.srcip = IPAddr('10.0.0.1')
        ipv4_packet.set_payload(tcp_packet)

        eth_packet = ethernet()
        eth_packet.set_payload(ipv4_packet)
        eth_packet.dst = EthAddr('00:00:00:00:00:05')
        eth_packet.src = EthAddr('00:00:00:00:00:01')
        eth_packet.type = ethernet.IP_TYPE

Afterwards, it's sent through one of the ports of a switch. When I try to capture the packet in PacketIn handler:

event.parsed.find('tcp')

returns None, as though there's no TCP packet. Capturing the traffic with Wireshark, I see the packet (wrapped in OF packet) but Wireshark warns that TCP header is zero.

Is this indeed the problem, with the header, and if it's how can I fix this ?

Thank you

Daniel

The problem was that data offset field had not been set. Since, the minimal header length for TCP packet is 5 32bit words (20 bytes) and I've no options set in the header. So in order to fix this, I should had to add:

tcp_packet.off = 5

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

POX - Installing a rule which says to send a dummy packet whenever a certain packet matches an ofp_match

From Dev

POX - Installing a rule which says to send a dummy packet whenever a certain packet matches an ofp_match

From Dev

Parsing a TCP Packet data

From Dev

Print TCP Packet Data

From Dev

reassembly of tcp packet

From Dev

Send TCP packet in PHP

From Dev

TCP FIN in separate packet

From Dev

Creating Custom UDP Packet

From Dev

How to understand a packet is TCP CLOSE packet with sharPcap

From Dev

detecting TCP/IP packet loss

From Dev

Send TCP SYN packet with payload

From Dev

TCP RST on TELNET - Packet builder

From Dev

TCP Client / Server packet loss

From Dev

Socket TCP Communication packet splitted

From Dev

What are different between these?(TCP packet)

From Dev

Controlling TCP connection at packet level

From Dev

Creating an effective packet sniffer in .NET

From Dev

Compile error when creating packet

From Dev

creating a buffer/packet in c++

From Dev

Creating DNS packet with dnslib python

From Dev

Does TCP verify data all at once or as a packet by packet verification?

From Dev

Why TCPDUMP shows Ethernet packet when querying TCP packet?

From Java

TCP Duplicate Ack without Packet Loss

From Dev

how to add the option scaling to the tcp packet with scapy

From Dev

Is TCP packet filtering possible on mobile platforms?

From Dev

TCP packet sizing at application level for max throughput

From Dev

How to extract Raw of TCP packet using Scapy

From Dev

Java / JSP Send TCP packet and wait for response

From Dev

C TCP Socket - Get packet destination name