- Community Home
- >
- Networking
- >
- Software Defined Networking
- >
- Re: How do I assemble and send a packet from a SDN...
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
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
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
07-01-2014 08:26 AM
07-01-2014 08:26 AM
How do I assemble and send a packet from a SDN App for the HP VAN controller
I've been on the HP SDN App course, I'm now trying to write a very basic packet in / packet out app, where I can ping the controller on the SDN network side.
I can handle a ICMP ech request packet, decode it to ethernet, IP and ICMP and then modify the fields, e.g.
public boolean action (MessageContext messageContext, Packet packetInData)
{
// Extract the Ethernet packet info.
Ethernet ethData = packetInData.get( ProtocolId.ETHERNET );
MacAddress srcMacAddr = ethData.srcAddr();
MacAddress dstMacAddr = ethData.dstAddr();
ProtocolId ethProtocol = ethData.id();
int ethLength = ethData.len();
EthernetType ethType = ethData.type();
Ethernet.SnapId ethSnap = ethData.snapId();
Ethernet.Control ethCtl = ethData.control();
Ethernet.Ssap ethSsap = ethData.ssap();
Ethernet.Dsap ethDsap = ethData.dsap();
// Extract IP packet info
Ip ipData = packetInData.get( ProtocolId.IP );
IpAddress srcIpAddress = ipData.srcAddr();
IpAddress dstIpAddress = ipData.dstAddr();
ProtocolId ipProtocol = ipData.id();
int ipTTL = ipData.ttl();
// Extract ICMP info
Icmp icmpData = packetInData.get( ProtocolId.ICMP);
int icmpIdent = icmpData.ident();
int icmpSeqNumber = icmpData.seqNum();
IcmpTypeCode icmpType = icmpData.typeCode();
//String packetString = icmpData.toString();
byte[] icmpPayload = icmpData.bytes();
// Build response packet
// Build ICMP response based on original ICMP packet
Icmp.Builder icmpOutData = new Icmp.Builder(icmpData);
icmpOutData.ident(icmpIdent);
icmpOutData.typeCode(IcmpTypeCode.valueOf("ECHO_REPLY"));
icmpOutData.seqNum(icmpSeqNumber);
// IP response packet based on original IP packet
Ip.Builder ipOutData = new Ip.Builder(ipData);
ipOutData.dstAddr(srcIpAddress);
ipOutData.srcAddr(dstIpAddress);
ipOutData.ident(icmpIdent);
ipOutData.ttl(255);
// Ethernet response frame based on original Ethernet frame
Ethernet.Builder ethOutData = new Ethernet.Builder(ethData);
ethOutData.control(ethCtl);
ethOutData.snapId(ethSnap);
ethOutData.type(ethType);
ethOutData.ssap(ethSsap);
ethOutData.dsap(ethDsap);
ethOutData.dstAddr(srcMacAddr);
ethOutData.srcAddr(dstMacAddr);
// Assemble packet
Packet packetOutData = new Packet();
return true;
}
How do combine the ethernet, IP and ICMP parts into a new packet and send the packet back to the switch?
Which classes do I use?
Any help appreciated.
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2014 12:04 PM
08-04-2014 12:04 PM
Re: How do I assemble and send a packet from a SDN App for the HP VAN controller
Hello Dave,
Apologies for the delay.
Did you try to use Packet Class (from the package com.hp.util.pkt.Packet)?
This class has constructors as below
Packet(List<Protocol> layers)
Constructor creates a packet of protocol layers.
Packet(Protocol... layers)
Constructor creates a packet of protocol layers.
Here Protocols are Ethernet,Icmp,Ip,…
So different protocols can be combined in the List to create the packet.
Please let us know if you are still facing the issue or your problem is solved.
Thanks,
HP SDN Team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2014 05:58 AM
08-05-2014 05:58 AM
Re: How do I assemble and send a packet from a SDN App for the HP VAN controller
Thanks for the reply,
I am using the Packet Class (from the package com.hp.util.pkt.Packet)
import com.hp.util.pkt.Packet;
When I try to create a packet I get the error message:
"The constructor Packet(Ethernet.Builder, Ip.Builder, Tcp.Builder, Icmp.Builder) is undefined."
I am modified the Eth, IP , TCP and ICMP info using:
// Build ICMP response based on original ICMP packet
Icmp.Builder icmpOutData = new Icmp.Builder(icmpData);
icmpOutData.ident(icmpIdent);
icmpOutData.typeCode(IcmpTypeCode.valueOf("ECHO_REPLY"));
icmpOutData.seqNum(icmpSeqNumber);
// IP response packet based on original IP packet
Ip.Builder ipOutData = new Ip.Builder(ipData);
ipOutData.dstAddr(srcIpAddress);
ipOutData.srcAddr(dstIpAddress);
ipOutData.ident(icmpIdent);
ipOutData.ttl(255);
// TCP response
Tcp.Builder tcpOutData = new Tcp.Builder(tcpData);
tcpOutData.dstPort(srcTCPport);
tcpOutData.dstPort(dstTCPport);
// Ethernet response frame based on original Ethernet frame
Ethernet.Builder ethOutData = new Ethernet.Builder(ethData);
ethOutData.control(ethCtl);
ethOutData.snapId(ethSnap);
ethOutData.type(ethType);
ethOutData.ssap(ethSsap);
ethOutData.dsap(ethDsap);
ethOutData.dstAddr(srcMacAddr);
ethOutData.srcAddr(dstMacAddr);
// Assemble packet
Packet packetOutData = new Packet(ethOutData, ipOutData, tcpOutData, icmpOutData);
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2014 04:34 AM
08-06-2014 04:34 AM
Re: How do I assemble and send a packet from a SDN App for the HP VAN controller
A more specifc question would be how to convert back from mutable Ethernet.Builder / Ip.Builder / Icmp.builder classes to the immutable Ethernet / Ip / Icmp classes.
To create a packet I can use;
Packet MyPacket = new Packet(eth, ip, icmp);
# There is no tcp layer for ICMP packets.
However to modify or create eth, ip and icmp inner layers I have to create mutable versions , e.g.
Icmp.Builder icmpOutData = new Icmp.Builder(icmpData);
But I cannot use icmpOutData when I create a new packet or cast to Icmp.
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2014 11:50 PM
10-27-2014 11:50 PM
Re: How do I assemble and send a packet from a SDN App for the HP VAN controller
Hello Dave,
Apologies for the delay.
Please let us know if your problem is solved or you still facing some issue.
If you have more questions on the same topic please do reply on the same thread or open a new post if new topic.
Thanks,
HP SDN Team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2014 02:47 AM
10-29-2014 02:47 AM
Re: How do I assemble and send a packet from a SDN App for the HP VAN controller
SDN Team,
I still haven't been able to create and output packets in HP VAN 2.0.
I have started setting up a HP VAN 2.3 developement system, but not finished this yet.
I also do not know if either HP VAN 2.0 or 2.3 are capable of creating and sending a packet to a switch.
It would aslo be useful if there were IGMP packet functions in the SDK. Multicast is very important for my industry.
Dave.