amlight / ofp_sniffer

An OpenFlow sniffer to help network troubleshooting in production networks.
Apache License 2.0
13 stars 12 forks source link

Failed to install from requirements #6

Open beraldoleal opened 7 years ago

beraldoleal commented 7 years ago

Hi Guys, Looks like cc1plus is a dependency to run ofp_sniffer.

I'm getting the following error when installing with pip3.6 install docs/requirements.txt:

  creating build
  creating build/temp.linux-x86_64-3.6
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-RxRqwq/python3.6-3.6.1~rc1=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c pcapdumper.cc -o build/temp.linux-x86_64-3.6/pcapdumper.o
  x86_64-linux-gnu-gcc: error trying to exec 'cc1plus': execvp: No such file or directory
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pcapy
  Running setup.py clean for pcapy
Successfully built termcolor
Failed to build pcapy
Installing collected packages: termcolor, netaddr, pcapy
  Running setup.py install for pcapy ... error
    Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s93lfkh3/pcapy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-7mfewe1k-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pcapy' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-RxRqwq/python3.6-3.6.1~rc1=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c pcapdumper.cc -o build/temp.linux-x86_64-3.6/pcapdumper.o
    x86_64-linux-gnu-gcc: error trying to exec 'cc1plus': execvp: No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s93lfkh3/pcapy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-7mfewe1k-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-s93lfkh3/pcapy/
beraldoleal commented 7 years ago

The same for Python.h:

pcapdumper.cc:10:10: fatal error: Python.h: No such file or directory
viniarck commented 7 years ago

@beraldoleal It turns out that pcapy relies on a lower-level library libpcap-dev to be built. Since ofp_sniffer has this OS-level dependency, probably the most convenient way to ship the code is with Docker. I'll talk to AmLight dev guys to start shipping with Docker.

I wrote a prototype with a minimal set of dependencies and ofp_sniffer is working fine inside a container, note on docker-compose that I'm using network_mode: host, in order to have full visibility of the networking stack. You can grab the docker-compose file and Dockerfile from this branch on my repo;

https://github.com/viniciusarcanjo/ofp_sniffer/commit/3e6205b99164f70371176481b6c83bad366df7f2

Inside the container:

root@volos:/opt/ofp_sniffer# python3.6 ofp_sniffer.py -i lo
Sniffing device lo
Packet #1 - 2017-09-16 22:37:47.638290 127.0.0.1:6633 -> 127.0.0.1:50032 Size: 122 Bytes
OpenFlow Version: 1.0(1) Type: OFPT_STATS_REQUEST(16) Length: 56  XID: 3514162067
StatReq Type: Flow(OFPST_FLOW)
Match - wildcards: 0x3fffff
StatReq Table_id: 255 Pad: 0 Out_Port: None(0xFFFF)

Packet #2 - 2017-09-16 22:37:47.641140 127.0.0.1:50032 -> 127.0.0.1:6633 Size: 174 Bytes
OpenFlow Version: 1.0(1) Type: OFPT_STATS_REPLY(17) Length: 108  XID: 3514162067
StatRes Type: Flow(1)
StatRes Length: 96 Table_id: 0 Pad: 0
StatRes Match - wildcards: 0x3820fb dl_src: ee:ee:ee:ee:ee:02
StatRes duration_sec: 3, duration_nsec: 756000000, priority: 50001, idle_timeout: 0, hard_timeout: 0, pad: 0, cookie: 0, packet_count: 0, byte_count: 0
StatRes Action - Type: OUTPUT Length: 8 Port: Controller(0xFFFD) Max Length: 65535