Re: [nox-dev] Not able to send ARP Reply in C++
Glad you got it working; I had missed yeffri's reply. -- Murphy On Dec 15, 2011, at 8:26 PM, Kimihiko FUKAMI wrote: > I am sorry for replying this thread late. > > And I sent a reply only to yeffri. > > At first, I successed to send an ARP reply in C++. yeffri's code > helps me very much! > > But yeffri's code can send an ARP request, so I wrote the code > to send an ARP reply. The code is below. > > To yeffri and Murphy, thank you very much !! > > Kimihiko FUKAMI > > === code 1 === > > Disposition Switch::handle(const Event& e){ >const Packet_in_event& pi = assert_cast(e); >uint32_t buffer_id = pi.buffer_id; >Flow flow(pi.in_port, *pi.get_buffer()); >stringstream out, out2; >ipaddr ipsrc(ntohl(flow.nw_src)); >ipaddr ipdst(ntohl(flow.nw_dst)); >string tp_src; >string tp_dst; >ipaddr globalgwaddr(LB_IP); >ipaddr privategwaddr(GATEWAY_IP); > >if (flow.dl_type == ethernet::ARP){ > Nonowning_buffer b(*pi.get_buffer()); > const arp_eth_header* arp = NULL; > const eth_header* eth = b.try_pull(); > > if (b.size() >= ARP_ETH_HEADER_LEN) { >arp = reinterpret_cast arp_eth_header*>(b.try_pull(ARP_ETH_HEADER_\ > LEN)); > }else { >return CONTINUE; > } > > if (arp->ar_op == arp::REQUEST){ >if (ipdst.string() == GATEWAY_IP){ > ethernetaddr senderMAC(arptable[GATEWAY_IP]); > ethernetaddr targetMAC(flow.dl_src.string().c_str()); > > sendARPReply(pi.datapath_id, pi.in_port, senderMAC, > privategwaddr.addr\ > , targetMAC, ipsrc.addr); >} > } > > = > > sendARPReply function code is below. > > == > void Switch::sendARPReply(datapathid dpid, int port, ethernetaddr senderMAC, > u\ > int32_t senderIP, ethernetaddr targetMAC, uint32_t targetIP) > { >ethernet ethPacket; >arp arpPacket; > >ethPacket.daddr = targetMAC; >ethPacket.saddr = senderMAC; >ethPacket.type = ethernet::ARP; > >arpPacket.hrd = arp::ETHER; >arpPacket.pro = ethernet::IP; >arpPacket.hln = ethernet::PAYLOAD_MIN; //6 for ethernet >arpPacket.pln = sizeof(targetIP); //4 for IPV4 >arpPacket.sha = senderMAC; >arpPacket.sip = senderIP; >arpPacket.tha = targetMAC; >arpPacket.tip = targetIP; >arpPacket.op = arp::REPLY; > >int size = sizeof(ethernet) + sizeof(arp); >uint8_t *data = new uint8_t[size]; > >memcpy(data, ðPacket, sizeof(ethPacket)); >memcpy(data + sizeof(ethPacket), &arpPacket, sizeof(arpPacket)); >Array_buffer buffer(data,size); // data will be deleted automatically > >send_openflow_packet(dpid, buffer, port, OFPP_LOCAL, true); } > } > > === end === > > Murphy McCauley wrote: > >> First, I'd suggest that you install a flow to send all appropriate ARP >> messages to the controller. >> >> Second, use the packet in event to examine the ARP request. The data that >> you need is all on the event object (specifically, the "buf" field of the >> Ofp_msg_event class contains the raw packet data, which you can parse as an >> ARP request). >> >> Third, build an ARP reply based on the request. Send this data using one of >> the packet sending functions (e.g., send_openflow_packet()). >> >> >> Have you considered writing this as a Python application first? >> >> >> Hope that helps. >> >> -- Murphy >> >> On Nov 30, 2011, at 12:15 AM, Kimihiko FUKAMI wrote: >> >>> Hi,Murphy! >>> >>> Thank you for your reply! >>> >>> I look at arp.hh source code. But, my question is not addressed. >>> >>> I forgot to tell you the code I want to write... >>> >>> The code is NAT program. In the NAT, the condition is that arp >>> reply should be addressed. >>> >>> I examined which api to send arp reply by using of Nox(zaku) in >>> C++, and I get a hint from attached Nox sample code "switch.cc". >>> The hint is Packet_in_event... >>> >>> Then I want to tell you how to get packet data from Packet_in_event >>> instance. Please give me a hint! >>> >>> >>> Murphy McCauley wrote: >>> I don't think I've ever used it, but have you taken a look at include/netinet++/arp.hh? -- Murphy On Nov 25, 2011, at 1:54 AM, Kimihiko FUKAMI wrote: > Hi, > > Currently, I can not send an ARP Reply by using of Nox(zaku) in > C++ code. > > # I can write a code to reply ARP in python. > > So, I want a code sample to send ARP Reply in C++. > > Please teach me! > > --- > E-mail: fukami.kimih...@lab.ntt.co.jp > > ___ > nox-dev mailing list > nox-dev@noxrepo.org > http://noxrepo.org/mailman/listinfo/nox-dev >>> >>> >>> --- >>> 深見 公彦 (Kimihiko FUKAMI) TEL:0422-59-2475 >>> NTT 情報流通プラットホーム研究所 >>> ネットワークセキュリティプロジェクト >>> E-mail: fukami.kimih...@lab.ntt.co.jp >>> > > > > ___ > nox-dev mailing list > nox-dev@noxrepo.org > htt
Re: [nox-dev] Not able to send ARP Reply in C++
I am sorry for replying this thread late. And I sent a reply only to yeffri. At first, I successed to send an ARP reply in C++. yeffri's code helps me very much! But yeffri's code can send an ARP request, so I wrote the code to send an ARP reply. The code is below. To yeffri and Murphy, thank you very much !! Kimihiko FUKAMI === code 1 === Disposition Switch::handle(const Event& e){ const Packet_in_event& pi = assert_cast(e); uint32_t buffer_id = pi.buffer_id; Flow flow(pi.in_port, *pi.get_buffer()); stringstream out, out2; ipaddr ipsrc(ntohl(flow.nw_src)); ipaddr ipdst(ntohl(flow.nw_dst)); string tp_src; string tp_dst; ipaddr globalgwaddr(LB_IP); ipaddr privategwaddr(GATEWAY_IP); if (flow.dl_type == ethernet::ARP){ Nonowning_buffer b(*pi.get_buffer()); const arp_eth_header* arp = NULL; const eth_header* eth = b.try_pull(); if (b.size() >= ARP_ETH_HEADER_LEN) { arp = reinterpret_cast(b.try_pull(ARP_ETH_HEADER_\ LEN)); }else { return CONTINUE; } if (arp->ar_op == arp::REQUEST){ if (ipdst.string() == GATEWAY_IP){ ethernetaddr senderMAC(arptable[GATEWAY_IP]); ethernetaddr targetMAC(flow.dl_src.string().c_str()); sendARPReply(pi.datapath_id, pi.in_port, senderMAC, privategwaddr.addr\ , targetMAC, ipsrc.addr); } } = sendARPReply function code is below. == void Switch::sendARPReply(datapathid dpid, int port, ethernetaddr senderMAC, u\ int32_t senderIP, ethernetaddr targetMAC, uint32_t targetIP) { ethernet ethPacket; arp arpPacket; ethPacket.daddr = targetMAC; ethPacket.saddr = senderMAC; ethPacket.type = ethernet::ARP; arpPacket.hrd = arp::ETHER; arpPacket.pro = ethernet::IP; arpPacket.hln = ethernet::PAYLOAD_MIN; //6 for ethernet arpPacket.pln = sizeof(targetIP); //4 for IPV4 arpPacket.sha = senderMAC; arpPacket.sip = senderIP; arpPacket.tha = targetMAC; arpPacket.tip = targetIP; arpPacket.op = arp::REPLY; int size = sizeof(ethernet) + sizeof(arp); uint8_t *data = new uint8_t[size]; memcpy(data, ðPacket, sizeof(ethPacket)); memcpy(data + sizeof(ethPacket), &arpPacket, sizeof(arpPacket)); Array_buffer buffer(data,size); // data will be deleted automatically send_openflow_packet(dpid, buffer, port, OFPP_LOCAL, true); } } === end === Murphy McCauley wrote: >First, I'd suggest that you install a flow to send all appropriate ARP >messages to the controller. > >Second, use the packet in event to examine the ARP request. The data that you >need is all on the event object (specifically, the "buf" field of the >Ofp_msg_event class contains the raw packet data, which you can parse as an >ARP request). > >Third, build an ARP reply based on the request. Send this data using one of >the packet sending functions (e.g., send_openflow_packet()). > > >Have you considered writing this as a Python application first? > > >Hope that helps. > >-- Murphy > >On Nov 30, 2011, at 12:15 AM, Kimihiko FUKAMI wrote: > >> Hi,Murphy! >> >> Thank you for your reply! >> >> I look at arp.hh source code. But, my question is not addressed. >> >> I forgot to tell you the code I want to write... >> >> The code is NAT program. In the NAT, the condition is that arp >> reply should be addressed. >> >> I examined which api to send arp reply by using of Nox(zaku) in >> C++, and I get a hint from attached Nox sample code "switch.cc". >> The hint is Packet_in_event... >> >> Then I want to tell you how to get packet data from Packet_in_event >> instance. Please give me a hint! >> >> >> Murphy McCauley wrote: >> >>> I don't think I've ever used it, but have you taken a look at >>> include/netinet++/arp.hh? >>> >>> -- Murphy >>> >>> On Nov 25, 2011, at 1:54 AM, Kimihiko FUKAMI wrote: >>> Hi, Currently, I can not send an ARP Reply by using of Nox(zaku) in C++ code. # I can write a code to reply ARP in python. So, I want a code sample to send ARP Reply in C++. Please teach me! --- E-mail: fukami.kimih...@lab.ntt.co.jp ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev >> >> >> --- >> 深見 公彦 (Kimihiko FUKAMI) TEL:0422-59-2475 >> NTT 情報流通プラットホーム研究所 >> ネットワークセキュリティプロジェクト >> E-mail: fukami.kimih...@lab.ntt.co.jp >> ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] Running Error on nox.json
Thanks Murphy. Peng On Thu, Dec 15, 2011 at 8:49 PM, Murphy McCauley wrote: > I suspect you're not running nox_core from the src directory (build/src). > Try that. > > You can also run it by specifying a configuration file (src/nox_core -c > src/etc/nox.json I think), but you'd also need to specify the directories > for components. > > Hope that helps. > > -- Murphy > > On Dec 15, 2011, at 4:39 PM, Peng Sun wrote: > > Hi Murphy, > > I followed the steps in NOX wiki. > > I installed NOX 0.9.0 (zaku) on a VM with Ubuntu 11.04 (Linux 2.6.38). > > I first installed the dependencies with apt-get, then took the steps: > ./boot.sh > mkdir build > cd build > ../configure > make -j 5 > > The compilation finished successfully. But when I launched nox_core, it > exits with error: > > NOX 0.9.0(zaku)~full~beta (nox_core), compiled Dec 16 2011 00:43:32 > Compiled with OpenFlow 0x01 > ERR: Unable to find a configuration file. Checked the following locations: > -> /usr/local/etc/nox/nox.json > -> etc/nox.json > > > > > Peng > > > On Thu, Dec 15, 2011 at 5:50 PM, Murphy McCauley wrote: > >> Hi; maybe you can provide a bit more information. >> >> What OS/version are you running on? What steps did you use to configure, >> build, and run NOX? >> >> -- Murphy >> >> On Dec 15, 2011, at 2:45 PM, Peng Sun wrote: >> >> > Hi, >> > >> > I encountered an error when running NOX. The error is: >> > >> > ERR: Unable to find a configuration file. Checked the following >> locations: >> > -> /usr/local/etc/nox/nox.json >> > -> etc/nox.json >> > >> > The compilation is successful... Does anybody know how to solve the >> problem? >> > >> > Thanks. >> > >> > >> > >> > >> > >> > Peng >> > ___ >> > nox-dev mailing list >> > nox-dev@noxrepo.org >> > http://noxrepo.org/mailman/listinfo/nox-dev >> >> > > ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] Running Error on nox.json
I suspect you're not running nox_core from the src directory (build/src). Try that. You can also run it by specifying a configuration file (src/nox_core -c src/etc/nox.json I think), but you'd also need to specify the directories for components. Hope that helps. -- Murphy On Dec 15, 2011, at 4:39 PM, Peng Sun wrote: > Hi Murphy, > > I followed the steps in NOX wiki. > > I installed NOX 0.9.0 (zaku) on a VM with Ubuntu 11.04 (Linux 2.6.38). > > I first installed the dependencies with apt-get, then took the steps: > ./boot.sh > mkdir build > cd build > ../configure > make -j 5 > > The compilation finished successfully. But when I launched nox_core, it exits > with error: > > NOX 0.9.0(zaku)~full~beta (nox_core), compiled Dec 16 2011 00:43:32 > Compiled with OpenFlow 0x01 > ERR: Unable to find a configuration file. Checked the following locations: > -> /usr/local/etc/nox/nox.json > -> etc/nox.json > > > > > Peng > > > On Thu, Dec 15, 2011 at 5:50 PM, Murphy McCauley wrote: > Hi; maybe you can provide a bit more information. > > What OS/version are you running on? What steps did you use to configure, > build, and run NOX? > > -- Murphy > > On Dec 15, 2011, at 2:45 PM, Peng Sun wrote: > > > Hi, > > > > I encountered an error when running NOX. The error is: > > > > ERR: Unable to find a configuration file. Checked the following locations: > > -> /usr/local/etc/nox/nox.json > > -> etc/nox.json > > > > The compilation is successful... Does anybody know how to solve the problem? > > > > Thanks. > > > > > > > > > > > > Peng > > ___ > > nox-dev mailing list > > nox-dev@noxrepo.org > > http://noxrepo.org/mailman/listinfo/nox-dev > > ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] Running Error on nox.json
Hi Murphy, I followed the steps in NOX wiki. I installed NOX 0.9.0 (zaku) on a VM with Ubuntu 11.04 (Linux 2.6.38). I first installed the dependencies with apt-get, then took the steps: ./boot.sh mkdir build cd build ../configure make -j 5 The compilation finished successfully. But when I launched nox_core, it exits with error: NOX 0.9.0(zaku)~full~beta (nox_core), compiled Dec 16 2011 00:43:32 Compiled with OpenFlow 0x01 ERR: Unable to find a configuration file. Checked the following locations: -> /usr/local/etc/nox/nox.json -> etc/nox.json Peng On Thu, Dec 15, 2011 at 5:50 PM, Murphy McCauley wrote: > Hi; maybe you can provide a bit more information. > > What OS/version are you running on? What steps did you use to configure, > build, and run NOX? > > -- Murphy > > On Dec 15, 2011, at 2:45 PM, Peng Sun wrote: > > > Hi, > > > > I encountered an error when running NOX. The error is: > > > > ERR: Unable to find a configuration file. Checked the following > locations: > > -> /usr/local/etc/nox/nox.json > > -> etc/nox.json > > > > The compilation is successful... Does anybody know how to solve the > problem? > > > > Thanks. > > > > > > > > > > > > Peng > > ___ > > nox-dev mailing list > > nox-dev@noxrepo.org > > http://noxrepo.org/mailman/listinfo/nox-dev > > ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] Not able to send ARP Reply in C++
First, I'd suggest that you install a flow to send all appropriate ARP messages to the controller. Second, use the packet in event to examine the ARP request. The data that you need is all on the event object (specifically, the "buf" field of the Ofp_msg_event class contains the raw packet data, which you can parse as an ARP request). Third, build an ARP reply based on the request. Send this data using one of the packet sending functions (e.g., send_openflow_packet()). Have you considered writing this as a Python application first? Hope that helps. -- Murphy On Nov 30, 2011, at 12:15 AM, Kimihiko FUKAMI wrote: > Hi,Murphy! > > Thank you for your reply! > > I look at arp.hh source code. But, my question is not addressed. > > I forgot to tell you the code I want to write... > > The code is NAT program. In the NAT, the condition is that arp > reply should be addressed. > > I examined which api to send arp reply by using of Nox(zaku) in > C++, and I get a hint from attached Nox sample code "switch.cc". > The hint is Packet_in_event... > > Then I want to tell you how to get packet data from Packet_in_event > instance. Please give me a hint! > > > Murphy McCauley wrote: > >> I don't think I've ever used it, but have you taken a look at >> include/netinet++/arp.hh? >> >> -- Murphy >> >> On Nov 25, 2011, at 1:54 AM, Kimihiko FUKAMI wrote: >> >>> Hi, >>> >>> Currently, I can not send an ARP Reply by using of Nox(zaku) in >>> C++ code. >>> >>> # I can write a code to reply ARP in python. >>> >>> So, I want a code sample to send ARP Reply in C++. >>> >>> Please teach me! >>> >>> --- >>> E-mail: fukami.kimih...@lab.ntt.co.jp >>> >>> ___ >>> nox-dev mailing list >>> nox-dev@noxrepo.org >>> http://noxrepo.org/mailman/listinfo/nox-dev > > > --- > 深見 公彦 (Kimihiko FUKAMI) TEL:0422-59-2475 > NTT 情報流通プラットホーム研究所 > ネットワークセキュリティプロジェクト > E-mail: fukami.kimih...@lab.ntt.co.jp > ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] how to display network topology timely
The fundamental problem here is that there's no always-applicable way to know when a host leaves. The only mechanism used in NOX now is a timeout. You could adjust this timeout -- the best value for it depends on how talkative your hosts are. You might also extend the host tracker to watch the link state, but that only works in some scenarios. I have also suggested that we track hosts by periodically ARP-pinging them, though I don't think anyone has ever actually implemented this. Hope that helps. -- Murphy On Dec 1, 2011, at 11:29 PM, 王健 wrote: > Hi all: > I have a question to consult you. The NOX GUI can display a whole > network topology when run the command: ./nox_core -v -v -i ptcp:6633 > monitoring discovery topology trackhost_pktin. But it cann't update timely > when a host leave from network, in other words, the host is still in the > network topology which you can see in NOX GUI. I think it may be lack of some > component when run the command, am i right? Which one to be used and how to > get it? would you like to tell me, thank you very much~ > Best Wishes > > > > > Wang Jian > >Friday, > December 2,2011 > > > At 2011-11-29 03:01:56,"Murphy McCauley" wrote: > I think the attachment is being scrubbed. Maybe you can send an image? > > Though offhand, I don't know what I can tell you. What do mean by > unreachable? Devices connected to the netfpga switch can't ping devices > connected to the openwrt switch? What NOX components are you running? > > -- Murphy > > On Nov 25, 2011, at 12:09 AM, 王健 wrote: > >> Hi Murphy: >> Thank you for your last reply , your suggest is right. Recently i built >> a openflow network,you can see the topology in the attachment. The >> connection between openflow switch(netfpga) and openwrt(openflow wireless) >> is unreachable, i mark it in blue. What's wrong with it, would you like to >> give me some advice for solving this problem,thank you very much! if there >> is something else you want to know, please tell me. >> Best Wishes >> >> &n bsp;Wang Jian >> >> Friday, November 25, 2011 >> >> >> >> > > > > ___ > nox-dev mailing list > nox-dev@noxrepo.org > http://noxrepo.org/mailman/listinfo/nox-dev ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] Watch inside the IP Option field with Openflow
Well, this depends on what you mean. There is no way in the OpenFlow 1.0 spec to have matches against an IP option. However, if you are installing exact-match flows for TCP or UDP connections and the first packet of the connection will have the option set, then you may be able to do what you want. The first packet of a connection will be sent up to the controller. The controller can then inspect the header to see if your option is set, and can install an exact match flow that modifies the destination address. If *only* the first packets of the connection will have the option set, then you will have to do a little extra work to deal with the case where the flow times out on the switch before the connection is actually dead. (That is, the controller will need to remember the connections it wants rewritten.) Hope that helps. -- Murphy On Dec 2, 2011, at 5:50 AM, Hyogi Jung wrote: > Hi all. > > I am trying to do some experiments with Openflow. > And I would like to know > if it is possible to watch inside the IP Header Option field? > > There is ip header length. So I can find that there is header option. > But How do I watch inside the IP Header Option? > If I read the IP option something like 'x.x.x.x', then I will modify > destination's address. > Can I do this in nox controller? > > Thank you! Hope you could help me > > - Hyogi > ___ > nox-dev mailing list > nox-dev@noxrepo.org > http://noxrepo.org/mailman/listinfo/nox-dev ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] Running Error on nox.json
Hi; maybe you can provide a bit more information. What OS/version are you running on? What steps did you use to configure, build, and run NOX? -- Murphy On Dec 15, 2011, at 2:45 PM, Peng Sun wrote: > Hi, > > I encountered an error when running NOX. The error is: > > ERR: Unable to find a configuration file. Checked the following locations: > -> /usr/local/etc/nox/nox.json > -> etc/nox.json > > The compilation is successful... Does anybody know how to solve the problem? > > Thanks. > > > > > > Peng > ___ > nox-dev mailing list > nox-dev@noxrepo.org > http://noxrepo.org/mailman/listinfo/nox-dev ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
[nox-dev] Running Error on nox.json
Hi, I encountered an error when running NOX. The error is: ERR: Unable to find a configuration file. Checked the following locations: -> /usr/local/etc/nox/nox.json -> etc/nox.json The compilation is successful... Does anybody know how to solve the problem? Thanks. Peng ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev
Re: [nox-dev] what is the difference between pyswitch and routing module?
No. The situation is as I described -- the routing module is really more like a network-wide L2 switch than anything else. It's possible to implement some L3 routing functionality in NOX as Srini mentions in the referenced email. However, there's at least one thing that IP routers do which can't be done reasonably within the OpenFlow 1.0 specification -- decrement the TTL. -- Murphy On Dec 12, 2011, at 11:59 PM, linbo wrote: > Hi,Murphy! > I remember there was an earlier thread: > http://noxrepo.org/pipermail/nox-dev/2011-April/007494.html > > It said that nox couldn't support conventional IP routing before,so does the > routing module making nox as a IP router now? > Thank you! > linbo ___ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev