- Community Home
- >
- Networking
- >
- Software Defined Networking
- >
- Creating and Inspecting DHCP packets in VAN
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 12:09 PM - edited 05-17-2017 12:11 PM
05-17-2017 12:09 PM - edited 05-17-2017 12:11 PM
Creating and Inspecting DHCP packets in VAN
Hi there,
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 messages. Here's the workflow we are following:
1. Create a rule that matches on UDP_SRC/DST 67/68 and send it to the controller (DONE)
2. Use OfmPacketIn.getData() to extract payload and access the byte[] to get relevant data (like XID, Hardware Address, etc). Not my favorite task, but doable. (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).
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.
Do I need to use Java's built-in libraries to serialize objects like::
public static byte[] serialize(Dhcp pkt) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(out); os.writeObject(pkt); return out.toByteArray(); }
Is there a different way to do it?
Thanks in advance for your suggestions!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 05:40 PM
05-18-2017 05:40 PM
Re: Creating and Inspecting DHCP packets in VAN
Hi checho,
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).
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:
Dhcp.Builder builder = new Dhcp.Builder();
// .. build DHCP fields ..
Dhcp dhcp = builder.build();
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));
Could you try this out and let us know if it works for you?
Shaun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2017 07:07 AM
05-20-2017 07:07 AM
Re: Creating and Inspecting DHCP packets in VAN
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.