Building an IOx Application for the IR1101
This section provides an example of building an IOX application for an IR1101 in an IOx software development environment (SDE).
In the following steps, you will see how the Cisco IOx SDE uses a virtualization layer on an x86_64-bit build machine that enables an ARM 64-bit environment to run on that machine. By emulating an ARM 64-bit CPU in this way, you can cross compile code for an ARM 64-bit IR1101 target device without explicitly using a cross compiler.
If you have not already loaded the IOx SDE, go to https://developer.cisco.com/docs/iox/#!iox-resource-downloads/downloads and scroll down to IOx SDE.
Testing and Developing an Application in the IOx SDE
In the IOx SDE, use the following commands to run the base image for the IR1101 and install all build dependencies for the application that you are building. In the fourth command, the base image is an ARM binary.
$ mkdir tcpdump-app
$ cd tcpdump-app
$ mkdir tcpdump-bin
$ docker run -vpwd/tcpdump-bin:/opt/build -it devhub-docker.cisco.com/iox-docker/ir1101/base-rootfsRun the IR1101 Docker base image and map the host directory
pwd/tcpdump-bin to the "/opt/build" directory inside the container file system.
Now you are in the running Docker container, and the prompt changes to /#.Enter the following command to install the build dependencies. In this command, install iox-toolchain installs the toolchain that builds the ARM binaries that the application requires. The iox-toolchain component is used only in the development environment and is not packaged into the final application.
/ # opkg update && opkg install iox-toolchain bison flexEnter the following commands to download and untar the tcpdump and libpcap sources from the tcpdump official archive, https://www.tcpdump.org/index.html#latest-releases. The versions of the tcpdump and libpcab used here are compatible with the Docker base image for the IR1101.
/ # mkdir tcpdump
/ # cd tcpdump/
/tcpdump # wget https://www.tcpdump.org/index.html#latest-releases/tcpdump-4.99.1.tar.gzConnecting to www.tcpdump.org/ (198.199.88.104:80)tcpdump-4.99.1.tar.gz 100%|**************************************************************************************************************** 1126k 0:00:00 ETA
/tcpdump # lstcpdump-4.99.1.tar.gz
/tcpdump # wget https://www.tcpdump.org/index.html#latest-releases/libpcap-1.10.1.tar.gzConnecting to www.tcpdump.org (198.199.88.104:80)libpcap-1.10.1.tar.gz 100%|****************************************************************************************************************| 635k 0:00:00 ETA
/tcpdump # tar -xf tcpdump-4.99.1.tar.gz
/tcpdump # tar -xf libpcap-1.10.1.tar.gzEnter the following commands to configure and build libpcap and tcpdump, and to install the binaries under /opt/build:
/tcpdump # cd libpcap-1.10.1/
/tcpdump/libpcap-1.10.1 # ./configure --prefix=/opt/build/
/tcpdump/libpcap-1.10.1 # make
/tcpdump/libpcap-1.10.1 # make install
/tcpdump/libpcap-1.10.1 # cd ../tcpdump-4.99.1/
/tcpdump/tcpdump-4.99.1 # ./configure --prefix=/opt/build/
/tcpdump/tcpdump-4.99.1 # make
/tcpdump/tcpdump-4.99.1 # make installTo confirm that lib and bin are installed under /opt/build, enter the following commands:
/tcpdump/tcpdump-4.99.1 # ls /opt/buildbin include lib sbin share
/tcpdump/tcpdump-4.99.1 # exitTo verify that the binaries have copied out from the container, enter the following commands.
Note: The /opt/build directory in the container was mapped to the directory ~/tcpdump-app/tcpdump-bin in the host system.
$ cd ~/tcpdump-app
$ ls -l tcpdump-bindrwxr-xr-x 2 root root 4096 Feb 25 21:13 bindrwxr-xr-x 3 root root 4096 Feb 25 21:13 includedrwxr-xr-x 2 root root 4096 Feb 25 21:13 libdrwxr-xr-x 2 root root 4096 Feb 25 21:26 sbindrwxr-xr-x 3 root root 4096 Feb 25 21:13 share
Building the Target Docker Image
Use the following commands to create a Dockerfile that copies the built tcpdump binaries and libraries into a Docker base image. This file also sets the tcpdump binary as the target and redirects the output log to the /data/logs/tcpdump.log file.
Note: The iox-toolchain that you used during the application development steps is not installed in this base image.
$ cat Dockerfile
FROM devhub-docker.cisco.com/iox-docker/ir1101/base-rootfs
COPY tcpdump-bin/ /
CMD ["tcpdump -i eth0 > /data/logs/tcpdump.log"]Use the following commands to build the Docker image:
$ docker build -t ir1101-tcpdump .Sending build context to Docker daemon 27.29MBStep 1/3 : FROM devhub-docker.cisco.com/iox-docker/ir1101/base-rootfs---> 0ec1d65ae4c6Step 2/3 : COPY tcpdump-bin/ /---> Using cache---> 04f9e31780a7Step 3/3 : CMD tcpdump -i eth0 > /data/logs/tcpdump.log---> Running in 6e5a6580d198---> 5cdcb8e8ccc5Removing intermediate container 6e5a6580d198Successfully built 5cdcb8e8ccc5Successfully tagged ir1101-tcpdump:latest
Packaging the Docker Image as an IOx Application
Use the following commands to use the ioxclient to convert the above image into an IOx app package:
$ mkdir pkg
$ ioxclient docker pkg ir1101-tcpdump pkg/Currently active profile : ir1101Command Name: docker-packageWarning: package.yaml not present in project folder. Will attempt to generate one.Unknown rootfs file extension, nonesetting rootfs fs type to ext2No app type specified.Checking device capabilitties using active profile.Device is capable of hosting docker appsGenerating IOx package of type docker with rootfs consisting of layersReplacing symbolically linked layers in docker rootfs, if anyNo symbolically linked layers found in rootfs. No changes made in rootfsRemoving emulation layers in docker rootfs, if anyModifying /bin/sh in the top most layerRemoving following layers from rootfs: [e5d8c829c084af4eafb77e029308960e369445191a053d142e1631357056ef96 55ef611a210cba1011611a14da6986bd41228d8a21abe68448569039fef46490]Finding the minimum schema version for the descriptor fileSetting the descriptor schema version to 2.2Validating generated descriptor file.Validating descriptor file /tmp/desc111672116 with package schema definitionsParsing descriptor file..Found schema version 2.2Loading schema file for version 2.2Validating package descriptor file..File /tmp/desc111672116 is valid under schema version 2.2Updated package metadata file : /home/ir1101/projects/tcpdump-app/pkg/.package.metadataNo rsa key and/or certificate files provided to sign the packageGenerating the envelope packageChecking if package descriptor file is present..Skipping descriptor schema validation..Created Staging directory at : /tmp/085679528Copying contents to staging directoryCreating artifacts manifest fileCreating an inner envelope for application artifactsIncluding rootfs.tarGenerated /tmp/085679528/artifacts.tar.gzParsing Package Metadata file : /tmp/085679528/.package.metadataUpdated package metadata file : /tmp/085679528/.package.metadataCalculating SHA1 checksum for package contents..Root Directory : /tmp/085679528Output file: /tmp/715218663Path: .package.metadataSHA1 : d67e036b75ec5ad72c219164e4ea7a101a9638acPath: artifacts.mfSHA1 : 3ae70f1bc5b0ac6030c5d05dd67c5f72ee81c4c1Path: artifacts.tar.gzSHA1 : e5350c91f1a34c7f5ac3fb0cac755d5f3078ed16Path: envelope_package.tar.gzSHA1 : 7b5621603195f566ebac4c99fc2cedeaa72eb7bbPath: package.yamlSHA1 : 347bcc53d0591b315c586d8de26b4c62728268e3Generated package manifest at package.mfGenerating IOx Package..Package docker image ir1101-tcpdump at /home/ir1101/projects/tcpdump-app/pkg/package.tar
Installing and Running the Application on a Physical IR1101
Use Get Console to access the device, for example:
$ telnet term-server-ip 2002Trying 1.100.80.5...Connected to 1.100.80.5.Escape character is '^]'.'ser2net port 2002 device /dev/iox-ir1101-02 [115200 N81] (CentOS)
iox-ir1101-02> enable
iox-ir1101-02#Install the app.
The app can be installed from any local storage location, such as, flash, bootflash, usbflash0, usbflash1, or the hard disk.
iox-ir1101-02#app-hosting install appid tcpdump package bootflash:tcpdump.tarInstalling package 'bootflash:tcpdump.tar' for 'tcpdump'. Use 'show app-hosting list' for progress.iox-ir1101-02#Feb 27 23:55:44.094: %IM-6-INSTALL_MSG: R0/0: ioxman: app-hosting: Install succeeded: tcpdump installed successfully Current state is DEPLOYEDActivate the app:
iox-ir1101-02#app-hosting activate appid tcpdumptcpdump activated successfullyCurrent state is: ACTIVATEDiox-ir1101-02#Feb 27 23:57:30.211: %IM-6-ACTIVATE_MSG: R0/0: ioxman: app-hosting: Activate succeeded: tcpdump activated successfully Current state is in ACTIVATEDStart the app:
iox-ir1101-02#app-hosting start appid tcpdumptcpdump started successfullyCurrent state is: RUNNINGiox-ir1101-02#Use Get Console to access the and check the log file.
Note: The session command does not work if you are using using the LXC container.
iox-ir1101-02#app-hosting connect appid tcpdump session
/ # psPID USER VSZ STAT COMMAND1 root 6772 S tcpdump -i eth024 root 3192 S /bin/sh26 root 3192 R ps/ #
/ # tail -f /data/logs/tcpdump.log00:22:38.614224 IP6 :: > ff02::1:ffba:2c79: ICMP6, neighbor solicitation, who has fe80::423:64ff:feba:2c79, length 2400:22:38.922208 IP6 :: > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 2800:22:38.994164 IP6 :: > ff02::1:ffa2:8626: ICMP6, neighbor solicitation, who has fe80::5054:ddff:fea2:8626, length 2400:22:39.614200 IP6 fe80::423:64ff:feba:2c79 > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 2800:22:39.614225 IP6 fe80::423:64ff:feba:2c79 > ip6-allrouters: ICMP6, router solicitation, length 1600:22:39.994251 IP6 fe80::5054:ddff:fea2:8626 > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 2800:22:39.994309 IP6 fe80::5054:ddff:fea2:8626 > ip6-allrouters: ICMP6, router solicitation, length 1600:22:40.274165 IP6 fe80::5054:ddff:fea2:8626 > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 2800:22:40.286187 IP6 fe80::423:64ff:feba:2c79 > ff02::16: HBH ICMP6, multicast listener report v2
Note: You can now manage this application using other Cisco IOx methodologies.