<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Redirect Package in Software Defined Networking</title>
    <link>https://community.hpe.com/t5/software-defined-networking/redirect-package/m-p/6558868#M362</link>
    <description>&lt;P&gt;Hello Madrid,&lt;BR /&gt;&lt;BR /&gt;Images are not seen.&lt;BR /&gt;Could you please upload the images again?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;HP SDN Team&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jul 2014 16:41:50 GMT</pubDate>
    <dc:creator>sdnindia</dc:creator>
    <dc:date>2014-07-30T16:41:50Z</dc:date>
    <item>
      <title>Redirect Package</title>
      <link>https://community.hpe.com/t5/software-defined-networking/redirect-package/m-p/6556042#M354</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created the rules of Packet-IN and Packet-OUT and the package was sent successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Topology:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;IMG src="https://lh4.googleusercontent.com/K9fpk6xyzSpRpqnSgTTVdj0_hPbImz7lEC4Ocdf3ytOD84sBdoxdDjw-Vq1U4VcHAfdDxw=w1511-h649" border="0" height="649" width="1061" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Flows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;IMG border="0" src="https://lh5.googleusercontent.com/vkJRK1tvaHLDR050xSWrZWzmnmVa_L1u0D5RMxnQAKXjDT1tVCwFvQAuayPXC08z9KhZmA=w1511-h649" height="424" width="1197" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when i send a package &amp;nbsp;to the node(10.0.0.2) for another node(10.0.0.4), when i try to redirect it to the &amp;nbsp;node(10.0.0.1),&amp;nbsp; the message reply is denied.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've created these flows and initiated the wireshark to monitor the network traffic.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Command:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;IMG border="0" src="https://lh5.googleusercontent.com/gQd7GZeJdBYvCMS7eacCPIJpVJ85aRn_OrGfmiNcrD3draO0vlToqN31dMZOUMmAKSj66w=w1511-h649" height="649" width="903" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Flows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;IMG border="0" src="https://lh5.googleusercontent.com/NPJuhXR02Dp7F-C9yDcWkaxkWzLedALz-Eyjb00BtUrw7DthDTUgm53P3cpsfsLI62xLuQ=w1511-h649" height="300" width="1216" /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results of Wireshark- Node(10.0.0.2):&lt;/SPAN&gt;&lt;BR /&gt;&lt;IMG border="0" src="https://lh3.googleusercontent.com/utAL3uTAlMaTHraIF1QxA2kphFp4e2147VBTQQVYSrzzunHR6Yos3p3fjaM0bVs5rXxgwg=w1511-h649" height="649" width="789" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Results of Wireshark- Node&lt;/SPAN&gt;(10.0.0.4):&lt;/SPAN&gt;&lt;BR /&gt;&lt;IMG border="0" src="https://lh6.googleusercontent.com/1aIIu_6KKHLgu9VXBAdgbrHe2qkLTrwRg0LdMGMOa-FMr17c0-N-s3j6Nd3EQJUHgtc3Bw=w1511-h649" height="649" width="686" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Results of Wireshark- Node&lt;/SPAN&gt;(10.0.0.1):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;IMG border="0" src="https://lh5.googleusercontent.com/D60i3QjIZRyjEzMx1LkTPyjn0b39T8Wh-VmNExxsOWlrEiryg83JzVFSOsBGe6zMZEs4nw=w1511-h649" height="649" width="805" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I believe that the message reply for the package is not being created, because the MAC_DST and IP_DST of the package doesn't match with the node that receive the package.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public class PacketListener implements SequencedPacketListener {&lt;BR /&gt;private ProtocolVersion pv = ProtocolVersion.V_1_0;&lt;BR /&gt;private short flowTimeout = 800;&lt;BR /&gt;private short flowPriority = 3001;&lt;BR /&gt;private Set&amp;lt;FlowModFlag&amp;gt; flags = EnumSet.of(FlowModFlag.SEND_FLOW_REM);&lt;BR /&gt;&lt;BR /&gt;@Override&lt;BR /&gt;public void errorEvent(ErrorEvent arg0) {&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt;public boolean event(MessageContext context) {&lt;/P&gt;&lt;P&gt;if (context.isHandled())&lt;BR /&gt;return false;&lt;BR /&gt;&lt;BR /&gt;MatchFields match = new MatchFields();&lt;BR /&gt;ActionFields action = new ActionFields();&lt;BR /&gt;&lt;BR /&gt;Packet decodedPacket = context.decodedPacket();&lt;BR /&gt;Ethernet ethernet = decodedPacket.get(ProtocolId.ETHERNET);&lt;BR /&gt;Ip ip = decodedPacket.get(ProtocolId.IP);&lt;BR /&gt;&lt;BR /&gt;match.srcIp = ip.srcAddr();&lt;BR /&gt;match.srcMac = ethernet.srcAddr();&lt;BR /&gt;&lt;BR /&gt;match.dstIp = ip.dstAddr();&lt;BR /&gt;match.dstMac = ethernet.dstAddr();&lt;BR /&gt;&lt;BR /&gt;match.inputPort = context.getPacketIn().getInPort();&lt;BR /&gt;action.dataPathId = context.srcEvent().dpid();&lt;BR /&gt;&lt;BR /&gt;if (decodedPacket.has(ProtocolId.TCP)) {&lt;BR /&gt;Tcp tcp = decodedPacket.get(ProtocolId.TCP);&lt;BR /&gt;match.srcPort = tcp.srcPort();&lt;BR /&gt;match.dstPort = tcp.dstPort();&lt;/P&gt;&lt;P&gt;} else if (decodedPacket.has(ProtocolId.UDP)) {&lt;BR /&gt;Udp udp = decodedPacket.get(ProtocolId.UDP);&lt;BR /&gt;match.srcPort = udp.srcPort();&lt;BR /&gt;match.dstPort = udp.dstPort();&lt;BR /&gt;} else if (decodedPacket.has(ProtocolId.ICMP)) {&lt;BR /&gt;Udp udp = decodedPacket.get(ProtocolId.ICMP);&lt;BR /&gt;match.srcPort = udp.srcPort();&lt;BR /&gt;match.dstPort = udp.dstPort();&lt;BR /&gt;} else {&lt;BR /&gt;throw new IllegalArgumentException("packet: Invalid protocol");&lt;BR /&gt;}&lt;BR /&gt;Action output = ActionFactory.createAction(ProtocolVersion.V_1_0, ActionType.OUTPUT, Port.TABLE);&lt;BR /&gt;context.packetOut().addAction(output);&lt;/P&gt;&lt;P&gt;NetworkNode server = doLoadBalancing();//this method returns a Node in the topology&lt;BR /&gt;action.dstIp = server.ip();&lt;BR /&gt;action.dstMac = server.mac();&lt;BR /&gt;action.outputPort = server.connectedPort();&lt;BR /&gt;&lt;BR /&gt;pushFlowMod(match,action,PacketType.PACKET_IN);&lt;BR /&gt;&lt;BR /&gt;TcpUdpPort srcPort = match.srcPort;&lt;BR /&gt;match.srcPort = match.dstPort;&lt;BR /&gt;match.dstPort = srcPort;&lt;BR /&gt;&lt;BR /&gt;action.outputPort = match.inputPort;&lt;BR /&gt;match.dstIp = match.srcIp;&lt;BR /&gt;match.srcIp = server.ip();&lt;BR /&gt;&lt;BR /&gt;action.srcIp = server.ip();&lt;BR /&gt;action.srcMac = server.mac();&lt;BR /&gt;&lt;BR /&gt;return pushFlowMod(match,action,PacketType.PACKET_OUT);&lt;BR /&gt;}&lt;BR /&gt;private boolean pushFlowMod(MatchFields match, ActionFields action, PacketType packet) {&lt;BR /&gt;OfmMutableFlowMod flowMod;&lt;BR /&gt;&lt;BR /&gt;flowMod = (OfmMutableFlowMod) MessageFactory.create(pv, MessageType.FLOW_MOD);&lt;BR /&gt;flowMod.match((Match) createMatch(match).toImmutable());&lt;BR /&gt;flowMod.hardTimeout(0);&lt;BR /&gt;flowMod.idleTimeout(flowTimeout);&lt;BR /&gt;flowMod.priority(flowPriority);&lt;BR /&gt;flowMod.command(FlowModCommand.ADD);&lt;BR /&gt;flowMod.bufferId(BufferId.NO_BUFFER);&lt;BR /&gt;flowMod.outPort(Port.NONE);&lt;BR /&gt;flowMod.cookie(0x1234);&lt;BR /&gt;flowMod.flowModFlags(flags);&lt;BR /&gt;&lt;BR /&gt;flowMod.addAction(ActionFactory&lt;BR /&gt;.createAction(pv, ActionType.OUTPUT, action.outputPort, ActOutput.CONTROLLER_NO_BUFFER));&lt;BR /&gt;if(packet == PacketType.PACKET_OUT){&lt;BR /&gt;flowMod.addAction(createActionSetField(pv,OxmBasicFieldType.ETH_SRC, action.srcMac))&lt;BR /&gt;.addAction(createActionSetField(pv,OxmBasicFieldType.IPV4_SRC, action.srcIp));&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;flowMod.addAction(createActionSetField(pv,OxmBasicFieldType.ETH_DST, action.dstMac))&lt;BR /&gt;.addAction(createActionSetField(pv,OxmBasicFieldType.IPV4_DST, action.dstIp));&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;try {&lt;BR /&gt;return controllerService.sendFlowMod((OfmFlowMod) flowMod.toImmutable(),action.dataPathId).setSuccess();&lt;BR /&gt;} catch (OpenflowException e) {&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;}&lt;BR /&gt;return false;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;private MutableMatch createMatch(MatchFields matchField){&lt;BR /&gt;MutableMatch match = MatchFactory.createMatch(pv).&lt;BR /&gt;addField(createBasicField(pv, OxmBasicFieldType.ETH_TYPE,EthernetType.IPv4))&lt;BR /&gt;.addField(createBasicField(pv, OxmBasicFieldType.IP_PROTO,IpProtocol.TCP))&lt;BR /&gt;//.addField(createBasicField(pv, OxmBasicFieldType.IN_PORT,matchField.inputPort))&lt;BR /&gt;.addField(createBasicField(pv, OxmBasicFieldType.IPV4_SRC,matchField.srcIp))&lt;BR /&gt;.addField(createBasicField(pv, OxmBasicFieldType.IPV4_DST,matchField.dstIp))&lt;BR /&gt;.addField(createBasicField(pv, IpProtocol.TCP.equals(IpProtocol.TCP)&lt;BR /&gt;? OxmBasicFieldType.TCP_SRC : (OxmBasicFieldType.UDP_SRC),PortNumber.valueOf(matchField.srcPort.getNumber())))&lt;BR /&gt;.addField(createBasicField(pv, IpProtocol.TCP.equals(IpProtocol.TCP)&lt;BR /&gt;? OxmBasicFieldType.TCP_DST : OxmBasicFieldType.UDP_DST,PortNumber.valueOf(matchField.dstPort.getNumber())));&lt;BR /&gt;return match;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;private class MatchFields {&lt;BR /&gt;public BigPortNumber outputPort;&lt;BR /&gt;public BigPortNumber inputPort;&lt;BR /&gt;public IpAddress srcIp;&lt;BR /&gt;public IpAddress dstIp;&lt;BR /&gt;public MacAddress srcMac;&lt;BR /&gt;public MacAddress dstMac;&lt;BR /&gt;public TcpUdpPort srcPort;&lt;BR /&gt;public TcpUdpPort dstPort;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;private class ActionFields {&lt;BR /&gt;public BigPortNumber outputPort;&lt;BR /&gt;public DataPathId dataPathId;&lt;BR /&gt;public IpAddress srcIp;&lt;BR /&gt;public IpAddress dstIp;&lt;BR /&gt;public MacAddress srcMac;&lt;BR /&gt;public MacAddress dstMac;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2014 14:30:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/software-defined-networking/redirect-package/m-p/6556042#M354</guid>
      <dc:creator>Madrid</dc:creator>
      <dc:date>2014-07-28T14:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Redirect Package</title>
      <link>https://community.hpe.com/t5/software-defined-networking/redirect-package/m-p/6558868#M362</link>
      <description>&lt;P&gt;Hello Madrid,&lt;BR /&gt;&lt;BR /&gt;Images are not seen.&lt;BR /&gt;Could you please upload the images again?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;HP SDN Team&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2014 16:41:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/software-defined-networking/redirect-package/m-p/6558868#M362</guid>
      <dc:creator>sdnindia</dc:creator>
      <dc:date>2014-07-30T16:41:50Z</dc:date>
    </item>
  </channel>
</rss>

