test: add stats and config tests to integrated test suite

Run this in the following way:

$ ryu-manager ryu/ryu/tests/integrated/test_request_reply_v12.py

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
controller: print backtrace when exception in addition to stacktrace

This is useful when debugging. it's difficult to debug without
backtrace.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
add packet library

As discussed on the mailing list, there is no good packet library
(parses and builds various protocol packets). dpkt isn't flexible
enough (can't nicely handle stacked protocols such as vlan, mpls,
gre). NOX's one is nice but released under GPL3.

So we need our own packet library.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
test: use the latest version of pep8

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
fix pep8 1.3.3 warnings

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
test: fix pep8 1.3.3 warnings

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.2: fix ofp_port_stats pack format

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.2: fix OFPFlowRemoved parser

Fix the following:

ryu/ofproto/ofproto_v1_2_parser.py", line 1701, in parser
    type_, length = struct.unpack_from('!HH', buf, offset)
TypeError: unpack_from() argument 1 must be string or read-only buffer, not bytearray

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: serialize in reverse order

- we need to serialize in reverse order since some need to know
  payload.
- TCP and UDP need the previous protocol info (IP) to calculate the
  checksum.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: calculate the ip total length

If the total length is not given, calculate it.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: calculate the udp length

If the length is not given, calculate it.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: add data serialize support to Packet class

This enables you to send data with Packet class.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: add packet_utils.py

Add a helper function to calculate the checksum.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: add udp data transmit and checksum support

- UDP supports sending data.
- UDP calculates the checksum if not given.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: convert ip to use the checksum helper function

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: add tcp support

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: set _MIN_LEN class variable

All protocols need to check if the data length is long enough so let's
set the minimum length in the same way.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: fix ipv4 option field handling

- fix the parser to set option data.
- add option argument to __init__.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
remove unnecessary OFPEchoReply handler in dispatchers

We don't send OFPEchoRequest so there is no point to have OFPEchoReply
handler.

I think that sending OFPEchoRequest is useful for some cases
(e.g. finding problems on the switch quickly). But that should be
another helper dispatcher since not all applications need such.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
remove unnecessary OFPFlowRemoved and OFPBarrierReply handlers in CONFIG_DISPATCHER

We don't send OFPC_DELETE OFPFlowMod or OFPBarrier during
CONFIG_DISPATCHER so we don't need OFPFlowRemoved and OFPBarrierReply.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>