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 -v pwd
/tcpdump-bin:/opt/build -it devhub-docker.cisco.com/iox-docker/ir1101/base-rootfs
Run 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 flex
Enter 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.gz
Connecting to www.tcpdump.org/ (198.199.88.104:80)
tcpdump-4.99.1.tar.gz 100%
|**************************************************************************************************************** 1126k 0:00:00 ETA
/tcpdump # ls
tcpdump-4.99.1.tar.gz
/tcpdump # wget https://www.tcpdump.org/index.html#latest-releases/libpcap-1.10.1.tar.gz
Connecting 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.gz
Enter 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 install
To confirm that lib and bin are installed under /opt/build, enter the following commands:
/tcpdump/tcpdump-4.99.1 # ls /opt/build
bin include lib sbin share
/tcpdump/tcpdump-4.99.1 # exit
To 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-bin
drwxr-xr-x 2 root root 4096 Feb 25 21:13 bin
drwxr-xr-x 3 root root 4096 Feb 25 21:13 include
drwxr-xr-x 2 root root 4096 Feb 25 21:13 lib
drwxr-xr-x 2 root root 4096 Feb 25 21:26 sbin
drwxr-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.29MB
Step 1/3 : FROM devhub-docker.cisco.com/iox-docker/ir1101/base-rootfs
---> 0ec1d65ae4c6
Step 2/3 : COPY tcpdump-bin/ /
---> Using cache
---> 04f9e31780a7
Step 3/3 : CMD tcpdump -i eth0 > /data/logs/tcpdump.log
---> Running in 6e5a6580d198
---> 5cdcb8e8ccc5
Removing intermediate container 6e5a6580d198
Successfully built 5cdcb8e8ccc5
Successfully 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 : ir1101
Command Name: docker-package
Warning: package.yaml not present in project folder. Will attempt to generate one.
Unknown rootfs file extension, none
setting rootfs fs type to ext2
No app type specified.
Checking device capabilitties using active profile.
Device is capable of hosting docker apps
Generating IOx package of type docker with rootfs consisting of layers
Replacing symbolically linked layers in docker rootfs, if any
No symbolically linked layers found in rootfs. No changes made in rootfs
Removing emulation layers in docker rootfs, if any
Modifying /bin/sh in the top most layer
Removing following layers from rootfs: [e5d8c829c084af4eafb77e029308960e369445191a053d142e1631357056ef96 55ef611a210cba1011611a14da6986bd41228d8a21abe68448569039fef46490]
Finding the minimum schema version for the descriptor file
Setting the descriptor schema version to 2.2
Validating generated descriptor file.
Validating descriptor file /tmp/desc111672116 with package schema definitions
Parsing descriptor file..
Found schema version 2.2
Loading schema file for version 2.2
Validating package descriptor file..
File /tmp/desc111672116 is valid under schema version 2.2
Updated package metadata file : /home/ir1101/projects/tcpdump-app/pkg/.package.metadata
No rsa key and/or certificate files provided to sign the package
Generating the envelope package
Checking if package descriptor file is present..
Skipping descriptor schema validation..
Created Staging directory at : /tmp/085679528
Copying contents to staging directory
Creating artifacts manifest file
Creating an inner envelope for application artifacts
Including rootfs.tar
Generated /tmp/085679528/artifacts.tar.gz
Parsing Package Metadata file : /tmp/085679528/.package.metadata
Updated package metadata file : /tmp/085679528/.package.metadata
Calculating SHA1 checksum for package contents..
Root Directory : /tmp/085679528
Output file: /tmp/715218663
Path: .package.metadata
SHA1 : d67e036b75ec5ad72c219164e4ea7a101a9638ac
Path: artifacts.mf
SHA1 : 3ae70f1bc5b0ac6030c5d05dd67c5f72ee81c4c1
Path: artifacts.tar.gz
SHA1 : e5350c91f1a34c7f5ac3fb0cac755d5f3078ed16
Path: envelope_package.tar.gz
SHA1 : 7b5621603195f566ebac4c99fc2cedeaa72eb7bb
Path: package.yaml
SHA1 : 347bcc53d0591b315c586d8de26b4c62728268e3
Generated package manifest at package.mf
Generating 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 2002
Trying 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.tar
Installing 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 DEPLOYED
Activate the app:
iox-ir1101-02#app-hosting activate appid tcpdump
tcpdump activated successfully
Current state is: ACTIVATED
iox-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 ACTIVATED
Start the app:
iox-ir1101-02#app-hosting start appid tcpdump
tcpdump started successfully
Current state is: RUNNING
iox-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
/ # ps
PID USER VSZ STAT COMMAND
1 root 6772 S tcpdump -i eth0
24 root 3192 S /bin/sh
26 root 3192 R ps
/ #
/ # tail -f /data/logs/tcpdump.log
00:22:38.614224 IP6 :: > ff02::1:ffba:2c79: ICMP6, neighbor solicitation, who has fe80::423:64ff:feba:2c79, length 24
00:22:38.922208 IP6 :: > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
00:22:38.994164 IP6 :: > ff02::1:ffa2:8626: ICMP6, neighbor solicitation, who has fe80::5054:ddff:fea2:8626, length 24
00:22:39.614200 IP6 fe80::423:64ff:feba:2c79 > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
00:22:39.614225 IP6 fe80::423:64ff:feba:2c79 > ip6-allrouters: ICMP6, router solicitation, length 16
00:22:39.994251 IP6 fe80::5054:ddff:fea2:8626 > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
00:22:39.994309 IP6 fe80::5054:ddff:fea2:8626 > ip6-allrouters: ICMP6, router solicitation, length 16
00:22:40.274165 IP6 fe80::5054:ddff:fea2:8626 > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
00: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.