<?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 Creating and Inspecting DHCP packets in VAN in Software Defined Networking</title>
    <link>https://community.hpe.com/t5/software-defined-networking/creating-and-inspecting-dhcp-packets-in-van/m-p/6965077#M2103</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;we would like to implement a simple DHCP server module in our controller (v2.7.18). Since DHCP is not part of OpenFlow protocol, we have to inspect the payload to get the relevant data to form DHCP offer/ack&amp;nbsp;messages. Here's the workflow we are following:&lt;/P&gt;&lt;P&gt;1. Create a rule that matches on UDP_SRC/DST 67/68 and send it to the controller (DONE)&lt;/P&gt;&lt;P&gt;2. &amp;nbsp;Use OfmPacketIn.getData() to extract&amp;nbsp;payload and access the byte[] to get relevant data (like XID, Hardware Address, etc). Not my favorite task, but doable. &amp;nbsp;(&lt;EM&gt;DONE -- but it would be nice to be able to create a DHCP object from the raw data, and then use a static class to access the fields&lt;/EM&gt;).&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Create a packetout that contains the DHCP response. VAN's API has a DHCP and DHCP.Builder classes that I assume are target to this case. I am able to create a DHCP instance but I cannot figure out how to add it to the payload of the packetout message I am building.&lt;/P&gt;&lt;P&gt;Do I need to use Java's built-in libraries to serialize objects like::&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="kwd"&gt;public&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;static&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;byte&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[]&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; serialize&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dhcp&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pkt&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;throws&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;IOException&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="typ"&gt;ByteArrayOutputStream&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; out &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;new&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;ByteArrayOutputStream&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;();&lt;/SPAN&gt;
    &lt;SPAN class="typ"&gt;ObjectOutputStream&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; os &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;new&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;ObjectOutputStream&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;out&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;    os&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;writeObject&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(pkt&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;
    &lt;SPAN class="kwd"&gt;return&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; out&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;toByteArray&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;();&lt;/SPAN&gt;
&lt;SPAN class="pun"&gt;}&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;Is there a different way to do it?&lt;/P&gt;&lt;P&gt;Thanks in advance for your suggestions!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2017 19:11:43 GMT</pubDate>
    <dc:creator>checho</dc:creator>
    <dc:date>2017-05-17T19:11:43Z</dc:date>
    <item>
      <title>Creating and Inspecting DHCP packets in VAN</title>
      <link>https://community.hpe.com/t5/software-defined-networking/creating-and-inspecting-dhcp-packets-in-van/m-p/6965077#M2103</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;we would like to implement a simple DHCP server module in our controller (v2.7.18). Since DHCP is not part of OpenFlow protocol, we have to inspect the payload to get the relevant data to form DHCP offer/ack&amp;nbsp;messages. Here's the workflow we are following:&lt;/P&gt;&lt;P&gt;1. Create a rule that matches on UDP_SRC/DST 67/68 and send it to the controller (DONE)&lt;/P&gt;&lt;P&gt;2. &amp;nbsp;Use OfmPacketIn.getData() to extract&amp;nbsp;payload and access the byte[] to get relevant data (like XID, Hardware Address, etc). Not my favorite task, but doable. &amp;nbsp;(&lt;EM&gt;DONE -- but it would be nice to be able to create a DHCP object from the raw data, and then use a static class to access the fields&lt;/EM&gt;).&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Create a packetout that contains the DHCP response. VAN's API has a DHCP and DHCP.Builder classes that I assume are target to this case. I am able to create a DHCP instance but I cannot figure out how to add it to the payload of the packetout message I am building.&lt;/P&gt;&lt;P&gt;Do I need to use Java's built-in libraries to serialize objects like::&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="kwd"&gt;public&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;static&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;byte&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[]&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; serialize&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dhcp&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pkt&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;throws&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;IOException&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="typ"&gt;ByteArrayOutputStream&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; out &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;new&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;ByteArrayOutputStream&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;();&lt;/SPAN&gt;
    &lt;SPAN class="typ"&gt;ObjectOutputStream&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; os &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;new&lt;/SPAN&gt; &lt;SPAN class="typ"&gt;ObjectOutputStream&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;out&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;    os&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;writeObject&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(pkt&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;
    &lt;SPAN class="kwd"&gt;return&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; out&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;toByteArray&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;();&lt;/SPAN&gt;
&lt;SPAN class="pun"&gt;}&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;Is there a different way to do it?&lt;/P&gt;&lt;P&gt;Thanks in advance for your suggestions!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 19:11:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/software-defined-networking/creating-and-inspecting-dhcp-packets-in-van/m-p/6965077#M2103</guid>
      <dc:creator>checho</dc:creator>
      <dc:date>2017-05-17T19:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Inspecting DHCP packets in VAN</title>
      <link>https://community.hpe.com/t5/software-defined-networking/creating-and-inspecting-dhcp-packets-in-van/m-p/6965223#M2105</link>
      <description>&lt;P&gt;Hi checho,&lt;/P&gt;&lt;P&gt;For packet types which VAN is able to recognize and parse (DHCP is one of them), you can use com.hp.util.pkt.Codec.decodeEthernet(byte[]) to decode a byte array into a Packet. The Packet will have accessors to get each header layer, so in this case you'd want to call Packet.get(ProtocolId.DHCP).&lt;/P&gt;&lt;P&gt;To create a packet-out message, you'll start with the Dhcp object that you created using Dhcp.Builder. Then you'd call com.hp.util.pkt.Codec.encode(Dhcp) which returns a byte[]. From there, you'd get the byte[] into the packet-out message by building the packet-out message. It would look something like this:&lt;/P&gt;&lt;PRE&gt;Dhcp.Builder builder = new Dhcp.Builder();&lt;BR /&gt;// .. build DHCP fields ..&lt;BR /&gt;Dhcp dhcp = builder.build();&lt;BR /&gt;&lt;BR /&gt;OfmMutablePacketOut po = (OfmMutablePacketOut) MessageFactory.create(pv, MessageType.PACKET_OUT);
po.bufferId(BufferId.NO_BUFFER);
po.inPort(Port.CONTROLLER); // Required by OF spec
po.addAction(ActionFactory.createAction(pv, ActionType.OUTPUT, bpn, ActOutput.CONTROLLER_NO_BUFFER));
po.data(Codec.encode(dhcp));&lt;/PRE&gt;&lt;P&gt;Could you try this out and let us know if it works for you?&lt;/P&gt;&lt;P&gt;Shaun&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 00:40:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/software-defined-networking/creating-and-inspecting-dhcp-packets-in-van/m-p/6965223#M2105</guid>
      <dc:creator>ShaunWackerly</dc:creator>
      <dc:date>2017-05-19T00:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and Inspecting DHCP packets in VAN</title>
      <link>https://community.hpe.com/t5/software-defined-networking/creating-and-inspecting-dhcp-packets-in-van/m-p/6965320#M2109</link>
      <description>&lt;P&gt;Shaun, thank you for your response. This is great news and does make things more intuitive to code. Once we have a usable version of the module, I will post here if en/decoding worked as it should.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 May 2017 14:07:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/software-defined-networking/creating-and-inspecting-dhcp-packets-in-van/m-p/6965320#M2109</guid>
      <dc:creator>checho</dc:creator>
      <dc:date>2017-05-20T14:07:46Z</dc:date>
    </item>
  </channel>
</rss>

