Sunteți pe pagina 1din 35

Chapter

12
Networking

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-1

Introduction

VxWorks Network Conguration

Routing Protocols

Remote Access Services

Networking
12.1 Introduction VxWorks Network Conguration Routing Protocols Remote Access Services

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-2

Network Stack

VxWorks Network Conguration

Available Network Facilities

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

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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/.

Good books on network programming:


q q

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.

For an overview and internals of network protocols:


q q

Network Components
netDrv NFS RPC zbuf API Tornado tgtsvr rlogin telnet rsh ftp

Sockets TCP IP MUX


Ethernet SLIP/PPP
12-4

UDP

Shared Memory Network

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

The MUX layer is a thin API layer that decouples network interface drivers from the network protocol.

IP, the Internet Protocol, is responsible for point-to-point delivery of datagrams.

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

User can build other network services as needed.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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.

A number of optional networking products are available, including:


q q

WindWeb server (HTTP server) SNMP STREAMS eNavigator (an embeddable browser and toolkit)

Networking
Introduction 12.2 VxWorks Network Conguration Routing Protocols Remote Access Services

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-7

Host Names and Tables

Domain Name Service

Dynamic Host Conguration Protocol

Host Names
To associate a name with an internet address:

hostAdd (hostName, hostAddr)


To display host name table use:

hostShow ( )
The name of the boot host is automatically added to the table from the boot parameters.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-8

Example:

-> hostAdd tuolumne, 147.11.12.14


value = 0 = 0x0

-> hostAdd todd, 147.11.12.14


value = 0 = 0x0

-> 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

Domain Name System


Domain Name System (DNS) is a distributed client/server application supporting host names being stored in a distributed database. DNS requires a name server and, on the client side, a resolver. VxWorks supports resolver functionality in resolvLib. resolvLib includes the following routines:
q

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.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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.

DNS is described in RFCs 1034 and 1035.

DNS Resolver Conguration


The DNS resolver component (/network
components/networking applications/DNS resolver)

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().

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-10

Example conguration:
q

RESOLVER_DOMAIN RESOLVER_DOMAIN_SERVER DNS_DEBUG

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.)

The VxWorks implementation of DHCP conforms to RFC 1541.

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

Add component /network components /


networking protocols/ network applications / DHCP Server.

Default parameters: Port numbers the same as for client DHCP server port number = 67 Max number of hops for DHCP = 4

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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

The target routing table can be built in two ways:


q

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

mRouteAdd(), strangely enough, is found in routeLib.

RIPv1 and RIPv2 are both supported by ripLib. Differences between these versions is discussed later.

OSPF is an optional product.

Adding Static Routes in VxWorks


To add multiple routes to the same location, use

mRouteAdd (dest, gateway, mask, tos, ags)


Can use a destination/gateway internet address in dot notation. Specify destination subnet mask and IP typeof-service. See routeLib help page for details. To add a route to the 90.0.0.0 /24 network through the router gatehost: mRouteAdd (90.0.0.0, gatehost, 0xffffff00, 0, 0) Routing table show routines, mRouteShow() or routeShow() require the component /network
components/networking protocols/network debugging/ Network show routines.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-15

To delete a route, use mRouteEntryDelete( ) or mRouteDelete( ).

routeAdd() and routeShow(), while obsolete, are provided for backwards compatibility.

Routing example:

->mRouteAdd (147.11.12.0, 90.0.0.254, 0xffffff00, 0, 0)


value = 0 = 0x0

->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

Network Show Routines


Are used to display network statistics and debugging information. Conguration information and statistics can be shown for protocols (IP, ICMP, TCP, etc.) , buffering, network interfaces, etc. Example (ARP table entries):

->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)

The components for network show routines are:

Dynamic Routing Overview


Dynamic routing protocols allow hosts (typically routers) to exchange routing information. Advantages over statically created routing tables include:
q q

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

The common UNIX routing daemon routed uses RIP.

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.

Routing Internet Protocol


RIP uses UDP to exchange routing information. RIP is a distance vector protocol -- each route includes a number of hop counts. If multiple paths to a destination exist, RIP chooses the most efcient route by minimizing this count. RIPv2 updates RIPv1 by including:
q q

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

RIPv2 can also process RIPv1 messages.

RIPv1 is described in RFC 1058 and RIPv2 in RFC 1388.

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 implements OSPF version 2, as dened in RFC 1583.

Networking
Introduction VxWorks Network Conguration Routing Protocols 12.4 Remote Access Services

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-19

Remote Access Services Supported by VxWorks

Server Services: rlogin, telnet, FTP, NFS

Client Services: NFS, RSH, FTP

VxWorks Remote Services


VxWorks

SERVER rlogin telnet NFS FTP

CLIENT nfsDrv NFS netDrv FTP RSH

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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.

Remote Login and Telnet


rlogin (UNIX) and telnet (Internet protocol)
Include /network components/networking protocols/network applications/RLOGIN server/ TELNET server

The target resident shell is required:


/development tool components/ target shell components/target shell

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.

Security can be installed:


q

Add the component /network components/networking protocols/network


applications/RLOGIN|TELNET password protection

Modify LOGIN_USER_NAME and LOGIN_PASSWORD parameters . Add additional users with loginUserAdd( ). An example of initializing the user login table:
q q

... loginInit(); loginUserAdd(marco, bcRzQdybze); ...

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.

NFS Server Overview


Allows remote hosts to access a targets DOS le systems using NFS protocol. By default no authentication is performed. Add the component /network components/networking protocols/network lesystems/NFS server. NFS server conguration supports: 1. Create a mountable DOS le system:
dosFsDevInitOptionsSet (DOS_OPT_EXPORT);

2. Export DOS le system:


nfsExport (name, fsId, rdOnly, notUsed);

3. Mount le system on remote host.


Tornado Training Workshop Copyright Wind River Systems Wind River Systems

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.

NFS server requires the following tasks:


q q

tMountd tNfsd tNfsd0-tNfsd3

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.

VxWorks FTP Server


The FTP server component is included by conguring /network components/networking protocols/network lesystems/FTP server. When target is booted, should see tFtpdTask (server daemon) running. FTP security, which will require a valid user name and password from clients, can be included by conguring /network components/networking protocols/network lesystems/FTP server security. The RLOGIN/TELNET password protection component allows a single user name and encrypted password. Additional users can be added by calling loginUserAdd() in application initialization code.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems

12-23

Example: VxWorks Server and VxWorks Client

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.

NFS vs. FTP Server


NFS Advantages:
q q

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

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-24

NFS Client Service


Network File System (NFS) was developed by Sun Microsystems. Allows efcient access to les. NFS transfers and buffers les in pieces (usually 8 Kbytes). Remote le systems are mounted, then accessed as if they were local le systems. VxWorks provides NFS client and server. The NFS client component can be found under /network
components/networking protocols/network lesystems/NFS client.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-25

Windows NT, Windows 98, and Windows 95 require additional software to support NFS. Numerous third-party packages are available.

NFS Client Conguration


To access les on a remote machine using NFS: 0. Export servers le system: Makes the local le system available to remote host with appropriate access permissions 1. Mount the le system on the client.
nfsMount (host, fileSystem, localName)

2. Set the clients authentication parameters:


nfsAuthUnixSet (hostName, uid, gid, ngids,aup_gids)

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

Exporting the servers le system, is host-dependent:

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)

To nd the remote host a le system is mounted from:

-> nfsDevShow
device name file system ------------------------/usrNfs styx:/usr /dinoNfs columbia:/dino value = 0 = 0x0

netDrv File Access Clients


netDrv allows access to remote les:
q q

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.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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

Creating network Devices


STATUS netDevCreate (devName, host, protocol)
devName host protocol Example -> netDevCreate (ohio:, ohio, 1) -> fd = open (ohio:/u/teamN, 2) Local name of device to create. By convention, ends with :. Name of remote machine (from previous hostAdd( )). Protocol to transfer les to/from VxWorks (0=RSH or 1=FTP).

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-28

FTP le access requires a name and a password set via remCurIdSet( ) or:
iam (team8, team8Password);

RSH access requires your target name in ~/.rhosts.

When using FTP, the netDrv routines call lower level functions implemented in the FTP client library, ftpLib.

Executing Remote Commands


UNIX
RSH server shell shell cmd RSH client

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.

rcmd() and rlogin() to UNIX also use the RSH protocol.

UNIX: Remote Command Execution


int rcmd (host, remotePort, localUser, remoteUser, cmd, pFd2)
host remotePort localUser remoteUser cmd pFd2 Host name or inet number. Remote port number to connect to, typically 514 (RSH server). Name of local user. User name on remote host. Shell command string to execute. If non-zero, a socket for stderr is foreach i (*.o)returned through this pointer.

Returns a socket le descriptor or ERROR.


12-30

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

stdout

fd1 fd2

UNIX shell

stderr

RSH client

int fd1, fd2; ... fd1 = rcmd (..., &fd2); ...

The remoteUser parameter is used by the RSH server to nd a .rhosts le.

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.

netDrv Client Services Comparison


Advantages of FTP over RSH:
q

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( ).

Advantages of RSH over FTP:


q

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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)

File transfer protocol (FTP) is an internet protocol for remote le transfer.

netDrv vs. nfsDrv


Advantages of nfsDrv over netDrv:
q q

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.

Advantages of netDrv over nfsDrv:


q q

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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.

Show routines are available to troubleshoot network conguration.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-33

Summary
DHCP allows a host to obtain IP address leases and boot parameters from a remote server. DHCP components:
q q

DHCP Server DHCP Relay Agent DHCP Client

rlogin (UNIX Host) and telnet support. FTP and NFS servers allows local VxWorks les to be accessed by a remote machine.

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

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.

netDrv devices created with netDevCreate( ).


q

rcmd ( ) and rlogin() (UNIX Host)

Tornado Training Workshop

Copyright Wind River Systems Wind River Systems

12-35

S-ar putea să vă placă și