Hi All.

I'm working in Openflow using mininet that is virtual emulation.

I want to modify packet's destination IP address.
For example, If packet's destination is 10.0.0.2, then Switch modify
destination to 10.0.0.3.
So I modify some nox source code such as switch.cc. And add some actions to
switch such as OFPAT_SET_NW_DST.

Below sentence show switch's flows. *Red text* is action.
But It didn't work. Why? Do mininet support this action?

Could you give some advice?

Best Regards

- Hyogi

mininet> dpctl dump-flows
*** s4
------------------------------------------------------------------------
stats_reply (xid=0x52625b89): flags=none type=1(flow)
  cookie=0, duration_sec=33s, duration_nsec=704000000s, table_id=1,
priority=32768, n_packets=71, n_bytes=2718, idle_timeout=60,hard_timeout=0,*
actions=mod_nw_dst:10.0.0.3*
  cookie=8661653833487901345, duration_sec=33s, duration_nsec=719000000s,
table_id=1, priority=65535, n_packets=0, n_bytes=0,
idle_timeout=60,hard_timeout=0,arp,in_port=2,dl_vlan=0xffff,dl_vlan_pcp=0x00,dl_src=6a:e0:e2:84:06:d6,dl_dst=ff:ff:ff:ff:ff:ff,nw_src=0.0.0.0,nw_dst=0.0.0.0,nw_tos=0x00,nw_proto=0,tp_src=0,tp_dst=0,actions=FLOOD
  cookie=6090790159401796605, duration_sec=33s, duration_nsec=753000000s,
table_id=1, priority=65535, n_packets=0, n_bytes=0,
idle_timeout=60,hard_timeout=0,arp,in_port=1,dl_vlan=0xffff,dl_vlan_pcp=0x00,dl_src=aa:7a:42:10:45:dc,dl_dst=ff:ff:ff:ff:ff:ff,nw_src=0.0.0.0,nw_dst=0.0.0.0,nw_tos=0x00,nw_proto=0,tp_src=0,tp_dst=0,actions=FLOOD

*This is my source.*

//////////////////////////////////////////////////////////////////////////////////////

ofp_flow_mod* ofm;
size_t size = sizeof *ofm + sizeof(ofp_action_nw_addr);
boost::shared_array<char> raw_of(new char[size]);
ofm = (ofp_flow_mod*) raw_of.get();

ofm->header.version = OFP_VERSION;
ofm->header.type = OFPT_FLOW_MOD;
ofm->header.length = htons(size);
ofm->match.wildcards =htonl(OFPFW_ALL & (~OFPFW_NW_DST_ALL));


ofm->match.in_port = htons(flow.in_port);
ofm->match.dl_vlan = flow.dl_vlan;
ofm->match.dl_vlan_pcp = flow.dl_vlan_pcp;
memcpy(ofm->match.dl_src, flow.dl_src.octet, sizeof ofm->match.dl_src);
memcpy(ofm->match.dl_dst, flow.dl_dst.octet, sizeof ofm->match.dl_dst);

ofm->match.dl_type = flow.dl_type;

ofm->match.nw_src = flow.nw_src;
ofm->match.nw_dst = 33554442; // IP address : 10.0.0.2

ofm->match.nw_proto = flow.nw_proto;
ofm->match.nw_tos = flow.nw_tos;
ofm->match.tp_src = flow.tp_src;
ofm->match.tp_dst = flow.tp_dst;
ofm->cookie = htonl(0);
ofm->command = htons(OFPFC_ADD);
ofm->buffer_id = htonl(buffer_id);
ofm->idle_timeout = htons(60);
ofm->hard_timeout = htons(OFP_FLOW_PERMANENT);
ofm->priority = htons(OFP_DEFAULT_PRIORITY);
ofm->flags = htons(ofd_flow_mod_flags());

// OFPAT_SET_NW_DST
ofp_action_nw_addr& dlset = *((ofp_action_nw_addr*)ofm->actions);
memset(&dlset, 0, sizeof(ofp_action_nw_addr));
dlset.type = htons(OFPAT_SET_NW_DST);
dlset.len = htons(sizeof(ofp_action_nw_addr));
dlset.nw_addr = 50331658; // 50331658 IP address : 10.0.0.3

send_openflow_command(pi.datapath_id, &ofm->header, true);

//////////////////////////////////////////////////////////////////////////////////////

Not all OpenFlow actions are supported.

The following are not currently supported on any Indigo platform:
OFPAT_SET_NW_SRC (Set L3 IP source address) OFPAT_SET_NW_DST (Set L3 IP
destination address) OFPAT_SET_TP_SRC (Set L4 source port) OFPAT_SET_TP_DST
(Set L4 destination port)

The following are only supported on the Pronto 3290 and the Triumph 2
reference:
OFPAT_SET_DL_SRC (Set L2 MAC source address) OFPAT_SET_DL_DST (Set L2 MAC
destination address)

OFPAT_STRIP_VLAN (Strip VLAN tag) is supported (but with only limited
validation) on the 3290 and 3240 platforms. On other platforms, the
function can be implemented by setting to the system's untagged VLAN
(untested).
_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to