Packet logging – Comtrol eCos User Manual
Page 806

Synthetic Target Ethernet Driver
physical hardware to provide these addresses, so normally MAC addresses will be invented. That means that each
time the eCos application is run it will have different MAC addresses, which makes it more difficult to compare
the results of different runs. To get more deterministic behaviour it is possible to specify the MAC addresses in the
target definition file:
synth_device ethernet {
eth0 ethertap tap3 00:01:02:03:FE:05
eth1 ethertap tap4 00:01:02:03:FE:06
...
}
During the initialization phase the eCos application will instantiate the various network devices. This will cause
the I/O auxiliary to load the
ethernet.tcl
script and spawn rawether processes, which in turn will
open
/dev/net/tun
and perform the appropriate
ioctl
calls. On the Linux side there will now be new network in-
terfaces such as
tap3
, and these can be configured like any other network interface using commands such as
ifconfig. In addition, if the Linux system is set up with hotplug support then it may be possible to arrange for
the network interface to become active automatically. On a Red Hat Linux system this would require files such as
/etc/sysconfig/network-scripts/ifcfg-tap3
, containing data like:
DEVICE="tap3"
BOOTPROTO="none"
BROADCAST=10.2.2.255
IPADDR="10.2.2.1"
NETMASK="255.255.255.0"
NETWORK=10.2.2.0
ONBOOT="no"
This gives the Linux interface the address
10.2.2.1
on the network
10.2.2.0
. The eCos network
device should be configured with a compatible address. One way of doing this would be to enable
CYGHWR_NET_DRIVER_ETH0_ADDRS
, set
CYGHWR_NET_DRIVER_ETH0_ADDRS_IP
to
10.2.2.2
, and similarly
update the
NETMASK
,
BROADCAST
,
GATEWAY
and
SERVER
configuration options.
It should be noted that the ethertap facility provides a virtual network, and any packets transmitted by the eCos
application will not appear on a real network. Therefore usually there will no accessible DHCP server, and eCos
cannot use DHCP or BOOTP to obtain IP address information. Instead the eCos configuration should use manual
or static addresses.
An alternative approach would be to set up the Linux box as a network bridge, using commands like brctl to
connect the virtual network interface
tap3
to a physical network interface such as
eth0
. Any packets sent by the
eCos application will get forwarded automatically to the real network, and some packets on the real network will
get forwarded over the virtual network to the eCos application. Note that the eCos application might also get some
packets that were not intended for it, but usually those will just be discarded by the eCos TCP/IP stack. The exact
details of setting up a network bridge are left as an exercise to the reader.
Packet Logging
The ethernet support comes with support for logging the various packets that are transferred, including a simple
protocol analyser. This generates simple text output using the filter mechanisms provided by the I/O auxiliary, so
it is possible to control the appearance and visibility of different types of output. For example the user might want
to see IPv4 headers and all ICMPv4 and ARP operations, but not TCP headers or any of the packet data.
702