Upload
hamlet
View
26
Download
0
Embed Size (px)
DESCRIPTION
application. application. presentation. presentation. session. session. transport. transport. IP. network. network. network. data link. data link. data link. physical. physical. physical. Big Picture: Lab 3. Networks Csaba Andras Moritz. Readings. Textbook Chapter 8. - PowerPoint PPT Presentation
Citation preview
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Big Picture: Lab 3Networks
Csaba Andras Moritz
physicaldata linknetworktransport
presentationapplication
session
physicaldata linknetworktransport
presentationapplication
session
physicaldata linknetworkIP
2ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Readings
Textbook Chapter 8
3ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Outline - Networking for Embedded Systems Why we use networks. Network abstractions. Embedded Networks and TCP/IP. Example networks. Networks programming with sockets.
4ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Technical background Moore: number of transistors/mm2 doubles every 18
months• processing power and memory capacity become
abundant Metcalfe: the “value” of a network is proportional to the
square of the number of nodes• adding a node benefits existing nodes• the larger the network the larger the benefit
Gilder: Internet bandwidth triples every 18 months
5ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Embedded Systems evolution
Hardware replaces software• functionality• features
Digitization and manipulation of signals
Configuration/programming of systems from outside
Completely networked systems
increase in networking
6ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
time
standalone fully networked
network aware
network connected
network central
standalone fully networked
network aware
network connected
network central
Network central: Adapt product design withrespect to the network connection
• Integrate network functions with embedded hardware and software
• Standardisation of connections, protocols
Advantage:• service: access to embedded software:
debugging, replacement, sell features• owner: standardisation, new software
Standalone: embeddedhardware and software:• invisible• are, in fact, an
implementation aspect of the product
Fully networked: the functionality is definedby the network
• Devices controlling each other• Intelligent environments, all equipment in the
background (Philips: “ambient intelligence”)
•
Advantage: http://www.research.philips.com/generalinfo/special/ambintel/index.html
• service: new markets• owner: ease of use, comfort, integration
Network connected: On-line connection withthe system
• Put control hardware/software next to the embedded system
• Interaction!
http://aquarium.eesi.tue.nl
Advantage:• service: diagnostics, leasing of appliances• owner: remote monitor & control, security,
production-control, fleet maintenance
Network aware: Information retrievalfrom the system in a rudimentary fashion
• Status information: errors, wear, use• Using existing connections and resources
already available within the system• Off-line analysis of data• Transport: telephone, Internet
Advantage: • remote diagnosis
Evolution of embedded networking
7ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Networks in embedded systems
PEPE sensor
PE actuator
initial processing
more processing
8ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Networking for Embedded Systems
Why we use networks. Network abstractions. Embedded Networks and TCP/IP. Example networks. Networks programming with sockets
9ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Network abstractions
International Standards Organization (ISO) developed the Open Systems Interconnection (OSI) model to describe networks:• 7-layer model.
Provides a standard way to classify network components and operations.
10ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
OSI model
physical mechanical, electrical
data link reliable data transport
network end-to-end service
transport connections
presentation data format
session application dialog control
application end-user interface
11ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Hardware architectures
Many different types of networks:• topology;• scheduling of communication;• routing.
12ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Point-to-point networks
One source, one or more destinations, no data switching (serial port):
PE 1 PE 2 PE 3
link 1 link 2
13ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Bus networks
Common physical connection:
PE 1 PE 2 PE 3 PE 4
header address data ECC packet format
14ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Bus arbitration
Fixed: Same order of resolution every time.Fair: every PE has same access over long periods.
• round-robin: rotate top priority among PEs.
A,B,C A,B,C
fixed
round-robin
A B C A B C
A B C AB C
15ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Ethernet
Dominant non-telephone LAN. Versions: 10 Mb/s, 100 Mb/s, 1 Gb/s, 10Gb/s. Goal: reliable communication over an unreliable
medium.
16ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Ethernet topology
Bus-based system, several possible physical layers:
A B C
17ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Ethernet packet format
preamblestart
framesourceadrs
destadrs
datapayload
length padding CRC
18ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Ethernet performance
Carrier sense multiple access with collision detection (CSMA-CD)• sense collisions;• exponentially back off in time;• retransmit.
Quality-of-service tends to non-linearly decrease at high load levels.
Can’t guarantee real-time deadlines. However, may provide very good service at proper load levels.
19ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Networking for Embedded Systems
Why we use networks. Network abstractions. Embedded Networks and TCP/IP. Example networks. Networks programming with sockets
20ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Internet Protocol
Internet Protocol (IP) is basis for Internet. Provides an internetworking standard: between
two Ethernets, Ethernet and token ring, etc. Higher-level services are built on top of IP.
21ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
IP in communication
physical
data link
network
transport
presentation
application
session
physical
data link
network
transport
presentation
application
session
physical
data link
network
node A router node B
IP
22ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Another look at TCP/IP for Embedded Devices
Application Layer
PresentationLayer
Session Layer
Transport Layer
Network Layer
Data Link Layer
Physical Layer
Application Layer
Transport Layer
InternetLayerLink
Layer
OSI ModelLayers
TCP/IPLayers
Physical Layer
Telnet FTP SMTP DNS POP3 SNMP
TCP UDP
IP802.2LLC
PPP SLIP
Ethernet Serial Port
TCP/IP Protocol Suite
23ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
TCP/IP Basics : Data Encapsulation
Application Data
TCP Header
IP Header
Ethernet Header
Application Data
Application Data
Application Data
TCP Header
TCP HeaderIP Header Ethernet Trailer
Application Data
App Header
App Header
App Header
App Header
24ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
IP addresses
32 bits in early IP, 128 bits in IPv6. Typically written in form xxx.xxx.xxx.xxx.
Each group ranges from 0 to 255
Names (foo.baz.com) translated to IP address by domain name server (DNS).
25ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Networking for Embedded Systems
Why we use networks. Network abstractions. Embedded Networks and TCP/IP. Example networks. Networks programming with sockets
26ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Embedded protocols and software
Remote user
Request connection
Program code
HTML browser
AppletES-Server
HTTP server HTTP(applet code)
UDP
sensors
actuators
27ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Components HTTP server:
• standardized access: URL • code download: Java applet
ES server: provide “driver interface” for embedded system
HTTP browser (client): • setup contact• run machine-independent code• “programmable interactive remote control”
Applet: • interface to user
28ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Networking for Embedded Systems
Why we use networks. Network abstractions. Embedded Networks and TCP/IP. Example networks. Networks programming with sockets
29ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Networked systems programming
Distributed systems programming is needed in many of today’s applications• Web servers, web caches, client-server applications, network
devices, …From low level to services
• Sockets (low-level API) • RPC, RMI (higher-level API)• CORBA (also adds services, component model) LATER!• EJB, J2EE, (Java version); .net (Microsoft)• Jini (Java’s answer to networked services and devices)
30ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Sockets
Low-level communication interface (API) Network Programming Defined 1981Bolt, Beranek and Newman (BBN) Originally developed for the C language TCP/IP version with Unix called BSD sockets To some extent similar to file IO
31ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Sockets
What is a socket?• It is a peer-to-peer communication “endpoint” abstraction• Hides details of network for programming communication
situations• Interfaces to some common network protocols (e.g. TCP, UDP,
XNS, NetBIOS, IP, etc.)
Many high level APIs are based on sockets• 1985 Sun introduced RPC and NFS (Network File System) over
sockets.
32ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Socket Ports
On TCP/IP networks:• Socket = Internet Address(IP) + Port Address
• Port is an “entry point” to an application that resides on a host.
33ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Socket Ports cont.
Typically a communication is assigned to a port, a process can request/assign to access a port-number.
TCP and UDP protocols (most common TCP/IP transport protocols) use port numbers 1-1023 that are reserved.
Standard Internet apps (FTP, TELNET, TFTP, SMTP, SNMP,..) use ports between 1-255.
> 1023 can be used for new user-level servers
34ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Socket types
Three types: • Stream (e.g. interface to TCP),
• session based reliable service that takes care of connection maintenance, packet reassembly, etc.
• Mimics UNIX file system semantics
• Datagram (e.g. interface to UDP, NetBIOS), • handles independent packets. • Unreliable; 5% of datagrams don’t make it. • Needs higher level acknowledgement service.
• Raw (e.g. interface to IP, etc.), • Programming interface to lower-level protocols
35ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Sockets
To initiate a connection one must fix the roles: client or server
A network connection can be connection-oriented or connectionless• With a connectionless protocol there is nothing like an “Open”
communication; every network IO operation can be with different process/host
• In a connection based operation a peer-to-peer channel is opened
36ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Connection-oriented use
Connection is first established between client and serverSystem Calls at server side
• socket() // creates endpoint, specify protocol (TCP, UDP, XNS, etc.), specify type (i.e. stream, datagram, etc.) Returns a small integer similar to file descriptor.
• bind() // register and bound network address to socket• listen() // signal willingness to receive connections• accept() // accept a connection• read(), write() // transfer data
37ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Connection-oriented protocol
Client side• socket() // same meaning as in server• connect() //establish contact between local-remote
site• read() write() //transfer data
38ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Example, connection-oriented sequence
socket()
bind()
listen()
accept()
read()
write()
socket()
connect()
write()
read()
SERVERCLIENT
Connection establishment
Data(request)
Data (reply)
BlocksUntilconnect
39ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
System calls connectionless case
sendto(addr,) // send datagrams (data packets)recvfrom(addr,..) // receive datagrams
Compared to the connection-oriented read() and write() these calls have arguments for remote protocol-specific addresses.
40ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Example 2, connectionless sequence of calls
socket()
bind()
recvfrom(addr1,…)
sendto(addr2,…)
socket()
bind()
sendto(addr1,…)
recvfrom(addr2,…)
SERVERCLIENT
Data(request)
Data (reply)
BlocksUntil data received from client
41ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Summary Sockets
Abstraction for network programming. Advantage:
• Best performance in distributed embedded applications, fine-tuning opportunities.
• Many known high-level protocols use sockets as underlying communication mechanisms.
Disadvantages: • lots of details to address, many parameters to control.• Requires understanding of system issues and network
protocols.
42ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
What's next ?
Lab 3 details by TA
43ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
BACKUP
44ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Internet-enabled embedded system
Internet-enabled embedded system: any embedded system that includes an Internet interface (e.g., burglar alarm system).
Internet appliance: embedded system designed for a particular Internet task (e.g. email).• UMASS ECE SDP Internet-connect Refrigerator
Laser printer. Personal digital assistant (PDA). Home automation system.
45ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
time
standalone fully networked
network aware
network connected
network central
standalone fully networked
network aware
network connected
network central
The effect of Internet
• Data transport (large distance)
• Standards: ftp, email, ...• Distributed access
Interoperability• Standards for
offering services: Jini, UPnP, OSGi
• Platform for • data exchange• integration
..... + information exchange!!
• Standards for• software architectures• communication: HTTP, Java,
TCP, UDP, ....• visualisation: browsers
• Global addressing
46ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Remote user
Request connection
Program code
Example: A coffee maker
Switch and heat control not networked individually
47ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Example: Javacam
Hardware platform:• parallel-port camera;• National Semi NS486SXF;• 1.5 Mbytes memory.
Uses memory-efficient Java Nanokernel.
48ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Javacam architecture
Web browser
QuickCam
486
Java nanokernel
Java VM
HTTPQuickcamserver
QuickCamapplet
49ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Fully networked devices Separate user interface and driver functions It must be simple to attach to the network
• lightweight • easy to handle
Zero configuration connection • builds a logical network automatically• peer to peer in absence of server
Zero configuration interoperable • service publication and discovery • devices control each other• no fixed identification
50ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Differences connectionless vs. connection-oriented
Connection establishing not required• Blocks until data is received as opposed until connection is
established• Note: Client could also use connect() and read() write() in the
connectionless case, but not “real connect” as it returns immediately, i.e. does not block as there is no connection established.
Use of the sendto() and recvfrom() as opposed to the read() and write() system calls
The client registers an address for itself with the bind() to be able to receive messages back (this address is sent with data automatically)
51ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
More on the differences
Connectionless is often useful • Lower overhead, no session creation required• Discovery type of situations: broadcasting queries to
the network and learning who is out there…• Quick messages (e.g. heartbeat, “I am alive”)• Can send to 500 nodes, would need 500 sessions
with the connection-oriented model• If one of the messages are not received no problem…
52ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
To Sum Up
TCP/IP is close to 20 years old, but it has outlasted more modern protocols and has become the de-facto standard for the internet
Proliferation of internet enabled devices is predicted in the next wave of the internet
As developers try to get their embedded devices on the net, they face the issue of the networking problem exceeding the application problem
Practical solutions are currently available to connect embedded devices to the internet in a cost effective manner
Proper selection of methodology is important to make a successful enabled Internet Appliance
53ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
IP packet
Includes:• version, service type, length• time to live, protocol• source and destination address• data payload
Maximum data payload is 65,535 bytes.
54ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Embedding TCP/IP – The Advantages
Internet
� Provides a universal, flexible, User Interface for the Device� UI can be exposed using a standard browser� Opens possibilities of remote diagnostics and software upgrade
55ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Embedding TCP/IP – The issues
� Resource Limitations– Code Size– Data Size– CPU Processing capacity
� Operating System Services– Timer Services– Memory Management– Network Drivers
� Processing Latency– Layer to layer buffering
56ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Sockets and Java
Before RMI and CORBA support has been designed for Java this was the only way to do network programming
Java.net package contains• Set of classes that let you download and manipulate URL
objects• A native Java implementation of Berkeley (BSD) sockets
57ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Java sockets
Semantics the same as we discussed earlier Java.net contains most of the classes needed Java.io contains socket related stream classes
• A socket may be associated with a “stream” in Java (provided by the Socket class implementation)
• Streams are fun as they hide devices, its like a data pipe• You can use OutputStream, InputStream, and other stream
classes derived from these with sockets. Somewhat similar to file access.