A tcpdump of the control traffic will be useful and easier. Regards KK
On 21 July 2011 16:04, Ricardo Bennesby <ricardo.benne...@gmail.com> wrote: > Hi KK. I tested as you suggested. > ofm->match.nw_dst = htons(36677824); // I tested also ofm->match.nw_dst = > flow.nw_dst; > and in the action I did: > nwaction->nw_addr = htons(new_ip); > But it continue trying to send to IP 192.168.47.2... > The Wireshark continues showing these: > Ethernet II, Src: 5a:8c:01:8b:e0:fb (5a:8c:01:8b:e0:fb), Dst: > 62:4c:de:97:90:e4 (62:4c:de:97:90:e4) > Internet Protocol, Src: 192.168.47.1 (192.168.47.1), Dst: 192.168.47.2 > (192.168.47.2) > > The MAC adress is of host with IP 10.0.0.2. So the dataframes arrive in this > host. But the destination IP continues without midifications. > Any suggestion? > Thank you very much. > Best Regards. > 2011/7/21 kk yap <yap...@stanford.edu> >> >> Hi Ricardo, >> >> Try matching on the old IP, then rewrite to the new IP. >> >> Regards >> KK >> >> On 20 July 2011 14:50, Ricardo Bennesby <ricardo.benne...@gmail.com> >> wrote: >> > Hi all. I would like to forward packets from one host to another. >> > I have the following topology: >> > c0 c0 >> > | | >> > s3------------- s3 >> > / \ / \ >> > h1 h2 h1 h2 >> > Each host can ping each other. The two networks are connected by their >> > switches (s3). >> > In net1 h1 and h2 have IP 10.0.0.1 and 10.0.0.2. >> > In net2 h1 and h2 have IP 192.168.47.1 and 192.168.47.2 >> > I want that everytime I ping from some host in 192.168.47.2 the packets >> > be >> > forward to 10.0.0.2. >> > I am using the switch.cc component and making some modifications on it. >> > I set some actions to achieve this, using flow_mod and changing the >> > out_port, destination mac_address and destination IP. >> > Using wireshark, listening to the port where h2 (10.0.0.2) is, I saw >> > that it >> > got an ARP request from h1. So, looks like the packets arrive in the >> > correct >> > ethernet address, but it continue asking for 192.168.47.2. The >> > destination >> > IP was not modified. The code follows: >> > if (flow.nw_dst == 36677824){//if destination ip=192.168.47.2 >> > uint8_t no_of_actions_len = 56; >> > uint8_t action_length = no_of_actions_len/(sizeof(struct >> > ofp_action_header)); >> > unsigned char *action_type = (unsigned >> > char*)malloc(action_length*sizeof(struct ofp_action_header)); >> > ofp_flow_mod* ofm; >> > size_t size = sizeof *ofm + >> > 7*sizeof(ofp_action_output); >> > 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(0); >> > ofm->match.wildcards = htonl(1<<20 | 1<<1); >> > 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, new_mac.octet, sizeof >> > ofm->match.dl_dst); >> > ofm->match.dl_type = flow.dl_type; >> > ofm->match.nw_src = flow.nw_src; >> > ofm->match.nw_dst = new_ip; >> > ofm->match.tp_src = flow.tp_src; >> > ofm->match.tp_dst = flow.tp_dst; >> > ofm->match.nw_proto = flow.nw_proto; >> > ofm->match.nw_tos = flow.nw_tos; >> > ofm->match.tp_src = flow.tp_src; >> > ofm->cookie = htonl(0); >> > ofm->command = htons(OFPFC_ADD); >> > ofm->buffer_id = htonl(buffer_id); >> > ofm->idle_timeout = htons(5); >> > ofm->hard_timeout = htons(OFP_FLOW_PERMANENT); >> > ofm->priority = htons(OFP_DEFAULT_PRIORITY); >> > ofm->flags = htons(ofd_flow_mod_flags()); >> > ofp_action_dl_addr *dlaction = (ofp_action_dl_addr >> > *)malloc(sizeof(ofp_action_dl_addr)); >> > dlaction->type = htons(OFPAT_SET_DL_DST); >> > dlaction->len = htons(sizeof(ofp_action_dl_addr)); >> > memcpy(dlaction->dl_addr, ofm->match.dl_dst, >> > sizeof(ofm->match.dl_dst)); >> > ofp_action_nw_tos *nw_tos = (ofp_action_nw_tos >> > *)malloc(sizeof(ofp_action_nw_tos)); >> > nw_tos->type = htons(OFPAT_SET_NW_TOS); >> > nw_tos->len = htons(sizeof(ofp_action_nw_tos)); >> > nw_tos->nw_tos = 0; >> > ofp_action_tp_port *tp_src = (ofp_action_tp_port >> > *)malloc(sizeof(ofp_action_tp_port)); >> > tp_src->type = htons(OFPAT_SET_TP_SRC); >> > tp_src->len = htons(sizeof(ofp_action_tp_port)); >> > tp_src->tp_port = htons(0); >> > ofp_action_tp_port *tp_dst = (ofp_action_tp_port >> > *)malloc(sizeof(ofp_action_tp_port)); >> > tp_dst->type = htons(OFPAT_SET_TP_DST); >> > tp_dst->len = htons(sizeof(ofp_action_tp_port)); >> > tp_dst->tp_port = htons(0); >> > ofp_action_output *action = (ofp_action_output >> > *)malloc(sizeof(ofp_action_output)); >> > action->type = htons(OFPAT_OUTPUT); >> > action->len = htons(sizeof(ofp_action_output)); >> > action->port = htons(port); >> > action->max_len = htons(0); >> > ofp_action_nw_addr *nwaction = (ofp_action_nw_addr >> > *)malloc(sizeof(ofp_action_nw_addr)); >> > nwaction->type = htons(OFPAT_SET_NW_DST); >> > nwaction->len = htons(sizeof(ofp_action_nw_addr)); >> > nwaction->nw_addr = new_ip; >> > memcpy(action_type, (unsigned char *)dlaction, >> > sizeof(ofp_action_dl_addr)); >> > memcpy(action_type + sizeof(ofp_action_dl_addr), >> > (unsigned >> > char *)nw_tos, sizeof(ofp_action_nw_tos)); >> > memcpy(action_type + sizeof(ofp_action_dl_addr)+ >> > sizeof(ofp_action_nw_tos), (unsigned char *)tp_src, >> > sizeof(ofp_action_tp_port)); >> > memcpy(action_type + sizeof(ofp_action_dl_addr) + >> > sizeof(ofp_action_nw_tos) + sizeof(ofp_action_tp_port), (unsigned char >> > *)tp_dst, sizeof(ofp_action_tp_port)); >> > memcpy(action_type + sizeof(ofp_action_dl_addr) + >> > sizeof(ofp_action_nw_tos) + sizeof(ofp_action_tp_port)+ >> > sizeof(ofp_action_tp_port), (unsigned char *)action, >> > sizeof(ofp_action_output)); >> > memcpy(action_type + sizeof(ofp_action_dl_addr) + >> > sizeof(ofp_action_nw_tos) + sizeof(ofp_action_tp_port)+ >> > sizeof(ofp_action_tp_port)+sizeof(ofp_action_output), (unsigned char >> > *)nwaction, sizeof(ofp_action_nw_addr)); >> > \ >> > // Copy action_type to ofm->actions >> > memcpy(ofm->actions, action_type, no_of_actions_len); >> > send_openflow_command(pi.datapath_id, &ofm->header, >> > true); >> > } >> > Sorry if I wasn't clear. >> > Best regards. >> > -- >> > Ricardo Bennesby da Silva >> > Ciência da Computação - UFAM >> > LabCIA - Laboratório de Computação Inteligente e Autonoma >> > >> > >> > _______________________________________________ >> > nox-dev mailing list >> > nox-dev@noxrepo.org >> > http://noxrepo.org/mailman/listinfo/nox-dev >> > >> > > > > > -- > Ricardo Bennesby da Silva > Ciência da Computação - UFAM > LabCIA - Laboratório de Computação Inteligente e Autonômica > > _______________________________________________ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev