- Community Home
- >
- Networking
- >
- Software Defined Networking
- >
- create ARP reply (OpenFlow version 1.3 )
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
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
03-30-2014 10:41 PM
03-30-2014 10:41 PM
create ARP reply (OpenFlow version 1.3 )
Hi
I'm trying to create an ARP reply for OpenFlow 1.3 based on
http://h30499.www3.hp.com/t5/SDN-Development/replying-ARP-message/m-p/6404080#M199
but does not work
my code is
//------------------------------
cs.addPacketListener(pl2, DIRECTOR, ALTITUDE2, EnumSet.of(ARP));
//----------------------------------------------
privateclass PacketListener2 extends SequencedPacketAdapter {
@Override
publicboolean event(MessageContext context) {
Arp arpPkt = context.decodedPacket().get(ARP);
if (arpPkt.opCode().equals(OpCode.REQ)) {
if (is_a_rule(arpPkt.senderIpAddr(), arpPkt.senderMacAddr(), arpPkt.targetIpAddr(), context.getPacketIn()
.getInPort(), context.srcEvent().dpid())) {
return
true;
}
}
returnfalse;
}
privateboolean is_a_rule(IpAddress senderIpAddr,
MacAddress senderMacAddr, IpAddress targetIpAddr,
BigPortNumber inPort, DataPathId dpid) {
.
.
.
.
Arp arpgen = build_arp(key);
OfmMutablePacketOut packetout = (OfmMutablePacketOut) MessageFactory.create(ProtocolVersion.V_1_3, MessageType.PACKET_OUT);
packetout.inPort(inPort);
packetout.bufferId(BufferId.NO_BUFFER);
packetout.data(arpgen.toString().getBytes());
//packetout.addAction(act) no ofv1.3
try {
cs.send(packetout.toImmutable(), dpid);
log.info("arp packet was sent"
+ dpid.toString() + "de "
+ arpgen.targetIpAddr().toString());
} catch (OpenflowException e) {
// TODO Auto-generated catch block
e.printStackTrace();
returntrue;
}
the code does not generate any errors and on the log info appears "" arp packet was sent "" ,
thanks for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2014 02:50 PM
03-31-2014 02:50 PM
Re: create ARP reply (OpenFlow version 1.3 )
@armandom wrote:packetout.data(arpgen.toString().getBytes());
The above line is calling the getBytes() method from the String class[1], which doesn't structure the packet in the format
specified by the protocol[2], so I guess the packet goes out but since the contents are not understood by other devices they discard them.
[1] http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes%28%29
[2] http://en.wikipedia.org/wiki/Address_Resolution_Protocol#Packet_structure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2014 05:54 PM
04-05-2014 05:54 PM
Re: create ARP reply (OpenFlow version 1.3 )
sepbot thank you for your help
I made the changes you recommended me but did not work
another idea?
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2014 01:02 PM
04-14-2014 01:02 PM
Re: create ARP reply (OpenFlow version 1.3 )
Hi guys,
Here is an ArpPacket class which I've created an ARP packet and how to create a PACKET_OUT message:
***** ARPPacket ******
package example;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class ArpPacket {
private static final int ARP_RESPONSE = 2;
private static final int HW_TYPE = 1;// ethernet
private static final int PROTOCOL_TYPE = 0x0800;
private static final int HW_ADDRESS_LENGHT = 6; // mac
private static final int PROTOCOL_ADDRESS_LENGTH = 4; // ipv4
public static byte[] createArpPacket(String srcIp, String srcMac,
String dstIp, String dstMac) {
byte[] sIp = new byte[4];
byte[] sMac = new byte[6];
byte[] dIp = new byte[4];
byte[] dMac = new byte[6];
System.out.println("ArpMessage: srcIp" + srcIp);
for (int i = 0; i < 4; i++) {
sIp[i] = (byte) Integer.parseInt(srcIp.split("\\.")[i]);
}
System.out.println("ArpMessage: srcMac" + srcMac);
for (int i = 0; i < 6; i++) {
sMac[i] = (byte) Integer.parseInt(srcMac.split(":")[i], 16);
}
System.out.println("ArpMessage: dstIp" + dstIp);
for (int i = 0; i < 4; i++) {
dIp[i] = (byte) Integer.parseInt(dstIp.split("\\.")[i]);
}
System.out.println("ArpMessage: dstMac" + dstMac);
for (int i = 0; i < 6; i++) {
dMac[i] = (byte) Integer.parseInt(dstMac.split(":")[i], 16);
}
//TODO: calculate exact packet length
ByteBuffer buf = ByteBuffer.allocate(28+14);
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
buf.put(dMac);
buf.put(sMac);
buf.putShort((short) 0x0806);
buf.putShort((short) HW_TYPE);
buf.putShort((short) PROTOCOL_TYPE);
buf.put((byte) HW_ADDRESS_LENGHT);
buf.put((byte) PROTOCOL_ADDRESS_LENGTH);
buf.putShort((short) ARP_RESPONSE);
buf.put(sMac);
buf.put(sIp);
buf.put(dMac);
buf.put(dIp);
return buf.array();
}
}
******** PACKET_OUT***********
OfmMutablePacketOut pOut = (OfmMutablePacketOut) MessageFactory.create(PV, MessageType.PACKET_OUT);
byte[] arpResponse = ArpPacket.createArpPacket(IP_SERVER_VIRTUAL, MAC_SERVER_VIRTUAL,senderIp.toString(), senderMac.toString());
System.out.println("SENDING TO SWITCH PORT: ["
+ senderIp.toString() + ":"
+ s.getPortToHost(senderIp.toString()) + "]");
System.out.println("#################################");
pOut.bufferId(BUFFER_ID)
.inPort(Port.CONTROLLER)
.data(arpResponse)
.addAction(
ActionFactory.createAction(PV,
ActionType.OUTPUT, messageContext
.getPacketIn().getInPort()));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2014 08:37 AM
04-18-2014 08:37 AM
Re: create ARP reply (OpenFlow version 1.3 )
HI RichieKotzen
I tested your code in my application but it did not work
Can you use this code for OpenFlow version 1.3?
because according to the api. addAction is not used since 1.1
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2014 12:03 AM
05-08-2014 12:03 AM
Re: create ARP reply (OpenFlow version 1.3 )
Hello armandom,
We are looking into the issue and we will come back.
Thanks,
HP SDN Team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2014 12:38 AM
06-20-2014 12:38 AM
Re: create ARP reply (OpenFlow version 1.3 )
Hello armandom,
Please find the attached file DeviceHealthManager.java for sample ARP-Proxy App to send Arp-Reply.
Currently ‘PROXY_MAC_ADDRESS’ and ‘ALTITUDE’ of the App are hardcoded.
SDN Controller used : 2.2.5.0016
SDN SDK used : 2.2.5
Hybrid mode of the controller : false
Please let us know if you still face the problem.
Thanks,
HP SDN Team