[pox-dev] Create TCP packet
Murphy McCauley
murphy.mccauley at gmail.com
Tue Nov 26 17:39:12 PST 2013
On Nov 26, 2013, at 6:53 AM, Silvia Fichera <fichera.sil at gmail.com> wrote:
> You are right! I want to pretend that a connection is open.
> I've done this:
>
> def send_tcp(seqNum, srcMAC, dstMAC,srcIP,dstIP,srcPort,dstPort,inport):
> tcp_packet = tcp()
> tcp_packet.srcport = dstPort
> tcp_packet.dstport = srcPort
> tcp_packet.len = tcp.MIN_LEN+20
> tcp_packet.win=1
> tcp_packet._setflag(tcp_packet.SYN_flag,1)
> tcp_packet._setflag(tcp_packet.ACK_flag,1)
> tcp_packet.seq=0
> tcp_packet.ack=1
> ipv4_packet = ipv4()
> ipv4_packet.iplen = ipv4.MIN_LEN + tcp_packet.len
> ipv4_packet.protocol = ipv4.TCP_PROTOCOL
> ipv4_packet.dstip = IPAddr(dstIP)
> ipv4_packet.srcip = IPAddr(srcIP)
> ipv4_packet.set_payload(tcp_packet)
> eth_packet = ethernet()
> eth_packet.set_payload(ipv4_packet)
> eth_packet.src = srcMAC #MAC Controller
> eth_packet.dst = dstMAC
> eth_packet.type = ethernet.IP_TYPE
> msg = of.ofp_packet_out(data = eth_packet)
> msg.actions.append(of.ofp_action_output(port = inport))
> for connection in core.openflow.connections:
> connection.send(msg)
>
> Here the controller aswers to a SYN packet with a SYN/ACK packet via packet_out. But I still have a problem...
> I've done a wireshark capture and in the information about this packet it tells me:
>
> Packet Out (CSM) (78B) => 45506 > 5001 [SYN, ACK] Seq=0 Ack=0 Win=1, bogus TCP header length (0, must be at least 20)
>
> wich fields I'm forgetting to set?
The TCP data (payload) offset field, which is in the .off attribute. 5 is the minimum value, which should be correct if you aren't including any TCP options. We should probably compute this value automatically or at least maybe default it to 5, but currently don't.
> And why, if I setted ack=1 it is 0?
The issue with the ACK may be because Wireshark has a setting where it shows "relative" sequence numbers instead of absolute ones. This can be disabled in the preferences. But if you select this packet and highlight the "Acknowledgement number" field in the packet details (center) pane, it should highlight the relevant bytes in the hex dump (bottom) pane. You should be able to see if it's 1 or 0 there.
-- Murphy
> 2013/11/25 Murphy McCauley <murphy.mccauley at gmail.com>
> The .win attribute of the TCP class should be an integer, and it's just put into the 16-bit window field verbatim. IIRC, in the absence of window scaling, this is just the number of bytes (beyond whatever is being ACKed) that you're willing to receive. (If you're just trying to get a client to think a connection is open, I think you can probably just set it to 1 -- 0 may not be a good idea.)
>
> I'd check the RFC or a good TCP reference for additional information. Or just try it. :)
>
> -- Murphy
>
> On Nov 25, 2013, at 12:38 AM, Silvia Fichera <fichera.sil at gmail.com> wrote:
>
> > Hi all,
> > I would like send a TCP - SYN/ACK packet from the controller to one host.
> > I already know how to buid UDP packet and send it in flooding, so I think I can follow the same way with TCP fields.
> > I need to set a minimal congestion window as I can receive only the ACK. Is it measured in bit? How much should be the right dimension?
> >
> > Thanks
> >
> > --
> > Silvia Fichera
>
>
>
>
> --
> Silvia Fichera
More information about the pox-dev
mailing list