Documente Academic
Documente Profesional
Documente Cultură
12
Networking
12-1
Introduction
Routing Protocols
Networking
12.1 Introduction VxWorks Network Conguration Routing Protocols Remote Access Services
12-2
Network Stack
Network Protocols
Machines on a network must agree to exchange data in some standard way. Internet protocol suite (also called TCP/IP) provides system independent protocols. VxWorks provides an implementation of TCP/IP protocol suite based on the 4.4BSD release Features include:
q q
Increased congurability and scalability MUX layer Support for contemporary Internet features
12-3
Internet protocols are standardized through Requests for Comments (RFCs) circulated by the Internet Engineering Task Force (IETF). These RFCs are the authoritative guide to how these protocols should work. RFCs can be found at www.ietf.org/rfc/.
Unix Network Programming, volume I, 2nd ed. (Stevens), 1997. Internetworking with TCP/IP volume III, 2nd ed. (Comer), 1996. TCP/IP Illustrated, Volume 1 (Stevens), 1994. TCP/IP Illustrated, Volume 2 (Wright and Stevens), 1995. Internetworking with TCP/IP volume I, 3rd ed. (Comer), 1995. Internetworking with TCP/IP volume II, 2nd ed. (Comer), 1994. The Design and Implementation of the 4.4 BSD UNIX Operating System (McKusick et. al.), 1996.
Network Components
netDrv NFS RPC zbuf API Tornado tgtsvr rlogin telnet rsh ftp
UDP
The MUX layer is a thin API layer that decouples network interface drivers from the network protocol.
TCP, Transmission Control Protocol, and UDP, User Datagram Protocol, are both transport level protocols. UDP is a lightweight datagram delivery service, and TCP is a full-featured connection-based protocol which provides reliable data transport.
Berkeley sockets, zbuf sockets, and RPC are supported network programming APIs.
The zbuf Sockets API uses buffer loaning to speed up network communication.
Network Scalability
Selective inclusion of core TCP/IP networking protocols is provided.
TCP/IP parameters can be set by setting properties of individual components. Examples: TCP Connection Timeout, IP Time-to-Live value, TCP/UDP receive and send buffer sizes, and tuning of internal buffers. (See VxWorks Network Programmers Guide.)
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-5
ICMP (Internet Control Message Protocol), congurable separately from IP, handles error and informational messages at the IP layer. Two such messages are echo reply (used by ping()) and redirect (used to repair bad routing entries).
IGMP (Internet Group Management Protocol) is used by hosts and routers to support multicasting.
The network library support component includes the library netLib which provides support for network drivers through the system task tNetTask.
Internal buffering is in the form of pre-allocated memory pools of xedsize mBlks and clBlks. The size and number of blocks in these pools can be changed to tune stack performance, but be sure to read the VxWorks Network Programmers Guide description rst!
Network Services
VxWorks network services include:
q q
DHCP/BOOTP Simple Network Time Protocol (SNTP) DNS resolver Dynamic Routing (RIPv1/RIPv2/OSPF) rlogin/telnet Remote command execution Remote le access Multicasting, including IGMP
12-6
To use these network services the appropriate components must be included in the VxWorks image.
DHCP, Dynamic Host Conguration Protocol, and BOOTP are two protocols supporting booting a target from a remote boot server. DHCP will be discussed in in this chapter.
DNS, Domain Name Service, allows a target to look up remote hosts by name. DNS will be discussed in this chapter.
WindWeb server (HTTP server) SNMP STREAMS eNavigator (an embeddable browser and toolkit)
Networking
Introduction 12.2 VxWorks Network Conguration Routing Protocols Remote Access Services
12-7
Host Names
To associate a name with an internet address:
hostShow ( )
The name of the boot host is automatically added to the table from the boot parameters.
12-8
Example:
-> hostShow
hostname -------t12-164 localhost wolverine tuolumne value = 0 = inet address aliases ------------ ----------147.11.12.164 127.0.0.1 147.11.12.165 147.11.12.14 todd 0x0
resolvGetHostByName() -- send a DNS query to the name server for the IP address of a host. resolvGetHostByAddr() -- send a DNS query to the name server for the host name of an IP address.
12-9
The name server must have a corresponding route in the target routing table.
hostLib contains two related routines, hostGetByName() and hostGetByAddr(), which normally use the local host name table. However, if resolvLib is congured and a host name or IP address is not found locally, then a DNS query will be sent.
must be
added to VxWorks. The resolver must be initialized before use. Required information includes RESOLVER_DOMAIN and RESOLVER_DOMAIN_SERVER. This can be done through the project facility or by calling resolvInit().
12-10
Example conguration:
q
wrs.com 147.11.254.1
FALSE
Setting the DNS_DEBUG ag will result in diagnostic messages being sent to the console when DNS queries are made.
DHCP Basics
DHCP Server DHCP relay agent DHCP Client
Dynamic Host Conguration Protocol (DHCP) allows a host to acquire an IP address, and possibly boot parameters, from a remote host. A DHCP client can obtain a temporary lease of an IP address from a DHCP server, which maintains a database of available addresses and other parameters. A DHCP relay agent is necessary to support DHCP operation across subnet boundaries.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-11
The DHCP server database can contain entries that allow BOOTP client requests to be handled. (BOOTP is a simpler protocol allowing remote clients to obtain boot parameters.)
See the VxWorks Network Programmers Guide chapter on Booting over the Network for more details on DHCP boot conguration.
DHCP Conguration
DHCP Client
Add component /network components /
networking protocols/ network applications/ DHCPv4 runtime client.
Default parameters: DHCP client port number = 68 DHCP server port number = 67 Desired lease length = 3600 seconds Minimum acceptable lease length = 30 seconds
DHCP Server
Default parameters: Port numbers the same as for client DHCP server port number = 67 Max number of hops for DHCP = 4
12-12
The DHCP relay agent conguration is described in the help page for dhcpsLib. (Yes, the server help le!)
A DHCP server requires a database of addresses and boot parameters. A default database is found in .../target/cong/comps/src/net/usrNetDhcpsCfg.c.
Details on database entries and a server hook to assign permanent storage for dynamically added addresses can be found on the help page for dhcpsLib.
Networking
Introduction VxWorks Network Conguration 12.3 Routing Protocols Remote Access Services
12-13
Routing Overview
Static Routing
Dynamic Routing
Routing Overview
Internet Protocol (IP) routing algorithm:
if (destination on a directly attached network) send data to destination else use routing table to find correct router send data to router
Statically, by adding routes to a local routing table using mRouteAdd() or routeAdd( ). Or dynamically, where hosts exchange routing information using a routing protocol.
VxWorks supports two routing protocols: Routing Information Protocol (RIP) and Open Shortest Path First (OSPF).
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-14
RIPv1 and RIPv2 are both supported by ripLib. Differences between these versions is discussed later.
12-15
routeAdd() and routeShow(), while obsolete, are provided for backwards compatibility.
Routing example:
->mRouteShow
Destination 0.0.0.0 127.0.0.1 147.11.12.0 Mask 0 0 ffffff0 TOS Gateway 0 0 0 90.0.0.1 127.0.0.1 90.0.0.254 Flags RefCnt Use Interface Proto 101 5 3 0 0 0 0 0 0 nt0 lo0 nt0 0 0 1
value = 0 = 0x0
->arptabShow
LINK LEVEL ARP TABLE destination gateway ags Refcnt Use Interface -------------------------------------------------------------------------147.11.12.14 08:00:20:7b:06:fb 405 0 45 ei0 147.11.12.165 00:60:97:4f:d5:16 405 0 0 ei0 -------------------------------------------------------------------------value = 75 = 0x4b = K
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-16
ARP is the Address Resolution Protocol, a protocol to nd link layer addresses (ethernet addresses in this example) given an IP address.
A ag value of 0x405 is 0x400 (generated by ARP) + 0x4 (host specic entry) + 0x1 (route is up)
Faster update as link states change Ability to calculate the most efcient route if there are multiple routes to a destination Easier maintenance
These protocols do not affect the Internet routing algorithm, but instead impose a routing policy when constructing the routing table. VxWorks supports RIP versions 1 and 2 and OSPF (an optional component).
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-17
RIP and OSPFs are examples of IGPs (Interior Gateway Protocols) which allow routers within an organization (in formal networking lingo, an autonomous system) to exchange routing information.
support for classless addressing ability to use multicasting and broadcasting support for authentication
use ping( ) for testing routes See ripLib in the VxWorks Reference Manual for details.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-18
OSPF is a link state protocol -- such protocols do not require wholesale exchange of routing tables. Instead, OSPF routers exchange information about link states. This information is used by each router to calculate an optimal routing table. Link state information includes a link weight, which reects delays and bandwidth restrictions on that network segment. Advantages of OSPF over RIP:
q q
Link state metrics lead to better optimized routes than hop counts. Routing updates occur more promptly. OSPF can accomodate larger and more complex organization networks (RIP is limited to hop counts < 16).
Networking
Introduction VxWorks Network Conguration Routing Protocols 12.4 Remote Access Services
12-19
12-20
A TFTP (Trivial File Transfer Protocol) client and server are also supplied. TFTP is a light-weight version of FTP implemented using UDP. It does not support any authentication. See tftpLib and tftpdLib for details.
The Target Server File System (TSFS) allows a target to access a hostbased le system using the target server - WDB agent connection. For details, see the WindView chapter.
Additional tools can also be linked: Target resident symbol table. Target resident show routines. Target resident module loader/unloader.
rlogin and telnet offer an alternative to crossdevelopment using the Tornado target server.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-21
Target-based tools may be useful for in-the-eld debugging and upgrading when a Tornado target server is unavailable. Inclusion of these tools increases your image size signicantly.
Modify LOGIN_USER_NAME and LOGIN_PASSWORD parameters . Add additional users with loginUserAdd( ). An example of initializing the user login table:
q q
In the above code, loginUserAdd( ) adds a user to the login table. The second argument bcRzQdybze is the pasword poloPonY encrypted with the vxencrypt tool.
12-22
NFS server provides: mountLib nfsdLib Implements Mount Protocol as dened in Internet RFC 1094. Implements Network File System Protocol as dened in Internet RFC 1094.
Manages mount requests Enqueues incoming NFS requests Process incoming NFS requests (number of tasks congurable)
To access le systems other than DOS from a remote host, use the VxWorks FTP server.
Refer to your host documentation for details on mounting a NFS le system on the remote system.
12-23
VxServer
-> pBlkDev = ramDevCreate (0, 512, 0, 400,0) -> dosFsMkfs (/RAM1, pBlkDev) -> fd = creat(/RAM1/dataFile,2) -> write(fd,dataPtr,nBytes) -> close (fd)
VxClient
-> netDevCreate (VxServer:, VxServer, 1) -> fd = open(VxServer: /RAM1/dataFile, 2) -> read(fd, dataBuf, maxSize) -> close (fd)
Can also use FTP to boot one VxWorks target from another.
Efcient le access. Congurable number of servers pre-spawned. Can access le systems other than DOS. All network hosts have FTP client.
FTP Advantages:
q q
12-24
12-25
Windows NT, Windows 98, and Windows 95 require additional software to support NFS. Numerous third-party packages are available.
Defaults (NFS_GROUP_ID = 100 and NFS_USER_ID = 2001) will need to be changed. UNIX users can get the required values using:
% id
uid=219(marc) gid=700(training)
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-26
For UNIX hosts, exported le systems and access permissions are often specied in /etc/exports. Under Solaris, the appropriate le is /etc/dfs/dfstab. (UNIX Host)
For PC hosts, export and access information are stored as specied by NFS software. Authentication may not be necessary. (PC Host)
-> nfsDevShow
device name file system ------------------------/usrNfs styx:/usr /dinoNfs columbia:/dino value = 0 = 0x0
Entire le read into target memory on open( ). read( )/write( ) act on copy of le in memory. File not written to remote host until close( ).
Cant access large les (constrained by available memory). ioctl (fd, FIOSYNC, 0) is not supported. dirLib routines opendir / readdir do not work on netDrv directories. stat / fstat are only partially implemented.
12-27
stat and fstat only work on regular les. The only elds that are lled in are the le size, le type (always IFREG if netDrv can open it), and device pointer
12-28
FTP le access requires a name and a password set via remCurIdSet( ) or:
iam (team8, team8Password);
When using FTP, the netDrv routines call lower level functions implemented in the FTP client library, ftpLib.
VxWorks
socket
VxWorks programs can invoke remote shell (RSH) commands on a UNIX host. A le descriptor called a socket is created. Can read( ) from this socket to get command output.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
12-29
Commercial RSH servers are available for Windows machines, for instance from Denicomp Systems. Shareware implementations are also available on the web.
Access permission requires a user name to be set on the target via remCurIdSet( ) or iam().
For RSH permission, can put target name in either ~/.rhosts, or in /etc/hosts.equiv. The latter is dangerous, as it allows a VxWorks user to set a name and access les arbitrarily. The former only allows a VxWorks user to access les as a single, usually non-root, user.
stdout
fd1 fd2
UNIX shell
stderr
RSH client
The RSH server can restrict access by a target to a specic user name, i.e., the localUser parameter.
For additional remote command execution routines see remLib in the Reference Manual.
Close the socket le descriptor when your task has nished using it.
FTP is part of the TCP/IP protocol suite, so it is available on all networked hosts. FTP is faster on open/close, since there is no shell delay. FTP server is supplied with VxWorks. FTP clear text password goes over the network on each open( ) and close( ).
12-31
A netDrv device for accessing les on the boot host is automatically created at boot time.
Remote shell protocol (RSH) is a UNIX protocol for executing commands remotely. (UNIX Host)
Reads and writes only needed parts of the le. Can access arbitrarily large les. open( )/close( ) much faster. Can use dirLib routines. Can ush le changes with FIOSYNC. All networked hosts have an FTP server. Easier to congure. read( )/write( ) slightly faster.
12-32
Summary
Internet Protocol for node-to-node routing. MUX layer decouples link-layer driver and network protocol. Conguring the network
q
Congure host name table using hostAdd() or use DNS resolver. Congure hosts routing table using mrouteAdd() or use RIP/OSPF.
12-33
Summary
DHCP allows a host to obtain IP address leases and boot parameters from a remote server. DHCP components:
q q
rlogin (UNIX Host) and telnet support. FTP and NFS servers allows local VxWorks les to be accessed by a remote machine.
12-34
Summary
nfsDrv mounts remote le systems with nfsMount( )
q q
Reads and writes portion of remote le. File system must be exported by remote host. Entire le is read into VxWorks on open( ), and not updated until close( ). Uses either RSH (UNIX Host) or FTP for le transfer. RSH requires name and entry in .rhosts. (UNIX Host) FTP requires name and password.
12-35