Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TCP/IP in Embedded
Systems
Mike Anderson
CTO/Chief Scientist
The PTR Group, Inc.
www.ThePTRGroup.com
www.ThePTRGroup.com RTC/GB-1
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
www.ThePTRGroup.com RTC/GB-2
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Connected Systems
• 10 years ago, it was unusual
to find embedded systems
that had network connectivity
• Today, it’s difficult to find
systems that don’t have
network connectivity
requirements
• Ranges from use during
development to heavily
network-centric internet
appliances
www.ThePTRGroup.com RTC/GB-3
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
What is a “Network”
• Anything connected to anything else!
www.ThePTRGroup.com RTC/GB-4
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
What is a “Stack”?
Specialized network functions such as file transfer, virtual terminal,
7 Application electronic mail, and file servers.
Protocols: DNS, TFTP, BOOTP, SNMP, RLOGIN, FTP, SMTP, MIME, NFS
6 Presentation Data formatting and character code conversion and data encryption.
Protocols: Null
2 Data Link Transfer of addressable units of information, frames, and error checking.
Protocols: SLIP, CSLIP, PPP, IEEE 802.2
www.ThePTRGroup.com RTC/GB-6
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
TCP UDP
IP ICMP
Ethernet Custom
Serial Ethernet Older
Ethernet Interface SM Backplane
Ethernet
www.ThePTRGroup.com RTC/GB-7
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Payload
Enet Cksum
www.ThePTRGroup.com RTC/GB-9
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Communication Types
• There are two primary
styles of network
communications
– Connection-based
• Virtual-circuit oriented
– Connection-less
• Datagram oriented
• Which type you pick
depends on the
application
www.ThePTRGroup.com RTC/GB-10
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
IP Routing
• One of IP’s jobs is packet routing
– Remember, best effort only
• Static routing is typically handled with
either files or memory-based tables
• Dynamic routing is done either via RIP,
OSPF or BGP protocols
www.ThePTRGroup.com RTC/GB-11
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Routing Example
Application Application
TCP TCP
IP Router
IP IP IP
Default Explicit
Routing Table Routing Table
Route Route
ARPs may be
Network Gateway Network Gateway
required along the way
0.0.0.0 192.168.1.1 192.168.1.0 10.0.0.1
www.ThePTRGroup.com RTC/GB-12
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
What is a “Socket”
• All this network stuff
seems pretty
complicated
• Sockets are a way to
use a stack for the
application
programmer
• They make a network
connection look like a
file
www.ThePTRGroup.com RTC/GB-13
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
www.ThePTRGroup.com RTC/GB-14
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
www.ThePTRGroup.com RTC/GB-15
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Buffer Movement
Enet Hdr mbuf hdr
IP
Header
TCP
Header mbuf hdr
IP Stack
mbuf hdr
Socket Interface
.
.
.
www.ThePTRGroup.com RTC/GB-16
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
www.ThePTRGroup.com RTC/GB-18
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Fat
User Applications
TCP UDP
IP ICMP
Ethernet Custom
Serial Ethernet Older
Ethernet Interface SM Backplane
Ethernet
www.ThePTRGroup.com RTC/GB-19
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Skinny
User Application
Webserver
Sockets/Streams
TCP UDP
IP
Ethernet
www.ThePTRGroup.com RTC/GB-20
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
gr te TCP Hardware
InIntetegarcak
SSt tack 192 Million pps
orkss
PIC 12C509 VVxxWWodrkstatacckk
TCP Firmware a d XX// te g rarateted s
e d
TThhr reaichee n
IInte g
118 pps rn ch
InInteteranci k
SSt tack
0
Cost/Complexity
www.ThePTRGroup.com RTC/GB-22
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Porting a Stack
• Third-party stacks are often designed to run
with or without a kernel
– They simply require memory allocation, a timer
and a means to get control of the CPU e.g., ISR or
tasking
• You’ll still need to write a device driver for the
NIC
• For best performance the use of interrupts
and DMA is recommended, but polling is
possible for simpler processor architectures
www.ThePTRGroup.com RTC/GB-23
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
www.ThePTRGroup.com RTC/GB-25
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
www.ThePTRGroup.com RTC/GB-26
©Copyright 2002 The PTR Group, Inc.
EMBEDDED, REALT IME SOLUTIONS AND SERVICES
Summary
• We have only begun to scratch the surface
here…
• There are many approaches to TCP/IP
support depending on your needs
• Higher speeds and more sophisticated
protocol support typically require an O/S
• Highest performances are achieved by
marrying O/S with dedicated H/W
• Just because you’re networked doesn’t mean
you can’t be “lite”
www.ThePTRGroup.com RTC/GB-27
©Copyright 2002 The PTR Group, Inc.