Wednesday, September 18, 2013

[VMware] NSX Topologies with Traffic Flows

http://packetpushers.net/wp-content/uploads/2013/09/PPP-VMware-NSX-Topologies-Traffic-Flows.pdf

[U-Boot] Use U-Boot command to reload image file and reboot

The following step is about the U-Boot to reboot your machine:

U-Boot>printenv

  • You can find the image address and bootm address.

U-Boot>setenv ipaddr 192.168.4.40
U-Boot>setenv serverip 192.168.4.26
U-Boot>setenv ethaddr 00:01:02:03:04:05
U-Boot>setenv netmask 255.255.255.0
U-Boot>saveenv
U-Boot>tftpboot 0xA800000040000000 <<your image file>>
U-Boot>bootm 0xA800000040000074

Wednesday, August 28, 2013

[BPDU] To understand BPDU Filtering an BPDU Guard


Quote from http://www.cisco.com/en/US/docs/switches/lan/catalyst3560/software/release/12.2_55_se/configuration/guide/swstpopt.html#wp1046220




Understanding BPDU Guard


The BPDU guard feature can be globally enabled on the switch or can be enabled per port, but the feature operates with some differences.

At the global level, you enable BPDU guard on Port Fast-enabled ports by using the spanning-tree portfast bpduguard default global configuration command. Spanning tree shuts down ports that are in a Port Fast-operational state if any BPDU is received on them. In a valid configuration, Port Fast-enabled ports do not receive BPDUs. Receiving a BPDU on a Port Fast-enabled port means an invalid configuration, such as the connection of an unauthorized device, and the BPDU guard feature puts the port in the error-disabled state. When this happens, the switch shuts down the entire port on which the violation occurred.

To prevent the port from shutting down, you can use the errdisable detect cause bpduguard shutdown vlan global configuration command to shut down just the offending VLAN on the port where the violation occurred.

At the interface level, you enable BPDU guard on any port by using the spanning-tree bpduguard enable interface configuration command without also enabling the Port Fast feature. When the port receives a BPDU, it is put in the error-disabled state.

The BPDU guard feature provides a secure response to invalid configurations because you must manually put the interface back in service. Use the BPDU guard feature in a service-provider network to prevent an access port from participating in the spanning tree.

Understanding BPDU Filtering


The BPDU filtering feature can be globally enabled on the switch or can be enabled per interface, but the feature operates with some differences.

At the global level, you can enable BPDU filtering on Port Fast-enabled interfaces by using the spanning-tree portfast bpdufilter default global configuration command. This command prevents interfaces that are in a Port Fast-operational state from sending or receiving BPDUs. The interfaces still send a few BPDUs at link-up before the switch begins to filter outbound BPDUs. You should globally enable BPDU filtering on a switch so that hosts connected to these interfaces do not receive BPDUs. If a BPDU is received on a Port Fast-enabled interface, the interface loses its Port Fast-operational status, and BPDU filtering is disabled.

At the interface level, you can enable BPDU filtering on any interface by using the spanning-tree bpdufilter enable interface configuration command without also enabling the Port Fast feature. This command prevents the interface from sending or receiving BPDUs.




Tuesday, August 20, 2013

[Google Chart] Some examples of using Google Chart API in Python

Here are some example codes of using Google Chart APIs written in Python that I wrote several years ago. And some output image for reference.

  • To generate multi-line chart:
def createMultiLineChart(rows, max_value):
urls = "http://chart.apis.google.com/chart?" + \
"chs=" + str(300+24*rows.__len__()) + "x200" + \
"&chd=t:" + ",".join([str(i[1]) for i in rows]) + "|" + ",".join([str(i[2]) for i in rows]) + \
"&cht=lc" + \
"&chls=2,1,0|2,1,0" + \
"&chco=0000ff,ff0000" + \
"&chtt=SMT%20Scrap%20Rate" + \
"&chxt=x,y" + \
"&chg=20,20" + \
"&chds=0," + str(max_value * 1.4) + \
"&chxl=0:|" + "|".join([str(i[0]) for i in rows]) + "|1:|" + "|".join(
[str(i * max_value * 1.4 / 10.0) + '%' for i in range(0,11)]) + \
"&chdl=Day%20S/R(%)|Night%20S/R(%)" + \
"&chm=s,0000ff,0,-1,8|s,ff0000,1,-1,8|N*f3*%,0000ff,0,-1,10|N*f3*%,ff0000,1,-1,10"
return urls


  • To generate multi-line chart:

def createLineChart(rows, max_value):
urls = "http://chart.apis.google.com/chart?" + \
"chs=" + str(300+24*rows.__len__()) + "x200" + \
"&chd=t:" + ",".join([str(i[1]) for i in rows]) + \
"&cht=lc" + \
"&chls=2,1,0" + \
"&chco=8080ff" + \
"&chtt=SMT%20Scrap%20Rate" + \
"&chxt=x,y" + \
"&chg=20,20" + \
"&chds=0," + str(max_value * 1.4) + \
"&chxl=0:|" + "|".join([str(i[0]) for i in rows]) + "|1:|" + "|".join(
[str(i * max_value * 1.4 / 10.0) + '%' for i in range(0,11)]) +\
"&chdl=S/R(%)" + \
"&chm=s,80C65A,0,-1,10|N*f3*%,8080ff,0,-1,10"
return urls
P.S: It is almost the same as multi-line chart so that I don't provide the image.

  • To generate bar chart:
def createBarChart(rows, max_value):
urls = "http://chart.apis.google.com/chart?" + \
"chs=" + str(300+24*rows.__len__()) + "x200" + \
"&chd=t:" + ",".join([str(i[1]) for i in rows]) + \
"&cht=bvg" + \
"&chco=1d89f9,c6d9fd" + \
"&chtt=SMT%20Scrap%20Rate" + \
"&chxt=x,y" + \
"&chg=20,20" + \
"&chds=0," + str(max_value * 1.4) + \
"&chxl=0:|" + "|".join([str(i[0]) for i in rows]) + "|1:|" + "|".join(
[str(i * max_value * 1.4 / 10.0) + '%' for i in range(0,11)]) +\
"&chdl=S/R(%)" + \
"&chbh=14,9,15"
#"&chf=bg,s,ffffef"
return urls

  • To generate pie chart:
def createPieChart(rows, legend):
urls = "|".join([i[0] for i in rows])
urls = urls.replace(' ','_')
urls=urls.encode('utf8')
urls=urllib.quote(urls,'&=')
return "http://chart.apis.google.com/chart?" + \
"chs=600x150" + \
"&chd=t:" + ",".join([str(i[1]) for i in rows]) + \
"&cht=p3" + \
"&chtt=" + legend + \
"&chl=" + urls

[Linux Command] Redirect stderr to stdout and output to terminal and log into file at the same time

If you want to redirect stderr to stdout, append this at your command: 2>&1 , and also for outputting to terminal and logging into file you should use tee.
Both together would look like this:
$ yourcommand 2>&1 | tee yourlogfile.log

Monday, August 19, 2013

[Floodlight] A simle note from Floodlight dev discussion

For some kind of the reasons, I stopped tracking what's going on Floodlight for a while. I post my previous notes about Floodlight and OpenFlow from Floodlight dev discussion, and hope it is beneficial for those who are still working on it.
  • Floodlight by default gets full packets from switch
    • OFPT_SET_CONFIG

  • GreenMST module for Floodlight
    • GreenMST is a module used to build the Minimum Spanning Tree of an OpenFlow network, thus avoiding brodcast storm, using looped topologies with the LearningSwitch module and switches not supporting the Spanning Tree Protocol.
    • http://github.com/LucaPrete/GreenMST

  • Wildcard Matching on network address
    • OFMatch mTo = new OFMatch();
      mTo.fromString("dl_type=0x800,nw_dst=224.128.0.0/9");
      System.out.println(mTo.toString()); // This prints nw_dst as 224.128.0.0/9
      System.out.println(mTo.getNetworkDestinationMaskLen()); //This prints destination mask length as 9
      But when I do dump-flows in the switch, it doesn't show any mask. It simply gives nw_dst as 224.128.0.0.
       
  • Push static flows based on ingress ports
    • your forwarding would not work any more.  Reason is any packet coming to that port is forced out the same port, making LLDP no longer workable.  LLDP is needed for floodlight to learn topology and route/forward packets.

  • BDDP Topology Discovery
    • In BSN BDDP and BSNPROBE types were defined.  BDDP is used in TopologyDiscovery to detect non-OpenFlow broadcast domains.  BSNPROBE is not used in Floodlight now.

  • Disabling Flooding for a Switch Port
    • OFPortMod p = (OFPortMod) floodlightprovider.
      getOFMessageFactory().getMessage(OFType.PORT_MOD);
      p.setPortNumber((short) 4); // or your port number
      p.setConfig(config); // you have to enter the proper Integer to disable the port (see OpenFlow doc)
    • The setting is related with OFPPC_NO_FLOOD

  • No NAT in Floodlight now
  • Creating static flows in Floodlight
  • Northbound API
    • Right now all the decisions are made logically (load balancer, firewall) so they will never have to travel to other computers. As far as the ordering in which these are executed you can enforce some special ordering by returning something in the isCallbackOrderingPostreq methods supplied by the IFloodlightmodule interface. For instance in the firewall module we have...

      @Override
      public boolean isCallbackOrderingPostreq(OFType type, String name) {
          return (type.equals(OFType.PACKET_IN) && name.equals("forwarding"));
      }

      This says that the module has a post requirement and forces Packet_IN messages to be passed on to the forwarding module. This is an example of how you would enforce an ordering. You can probably find something similar in the loadbalancing module.
  • Virtual Network
    • multiple links between two controller islands (which is the case for fat tree topologies) are not supported by Floodlight, at least for now. See Supported Topologies for details.