Big Picture Lab 4 - University of Massachusetts Amherst

Download Report

Transcript Big Picture Lab 4 - University of Massachusetts Amherst

Big Picture: Lab 3
Networks
Csaba Andras Moritz
application
presentation
session
transport
network
data link
physical
IP
network
data link
physical
application
presentation
session
transport
network
data link
physical
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Readings
Textbook Chapter 8
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
2
Outline - Networking for Embedded Systems





Why we use networks.
Network abstractions.
Embedded Networks and TCP/IP.
Example networks.
Networks programming with sockets.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
3
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
4
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
5
Evolution of embedded
networking
Network
central: Adapt product design with
Network
connected:
On-lineconnection
connection with
respect
to
the
network
Fully networked:
Network aware:
retrieval the functionality is defined
theInformation
system
the networkfashion
from the system in aby•rudimentary
Integrate network functions with embedded
• Put control
hardware/software
next to the
hardware
and
software
• Devices controlling each other
• Status information:
errors,
wear, use of connections, protocols
embedded
system
•
Standardisation
• Intelligent
environments,
all equipment in the
Standalone:
• Using
existing
connections
and
resources
• embedded
Interaction!
network
central
network
aware
background
(Philips: “ambient intelligence”)
hardware
and software:
already
available
within
the system
time
• invisible
• Off-line
analysis of data
• are, in fact,
an
• Transport:
telephone,
Internet
standalone aspect network connected
fully networked
implementation
of the product
http://aquarium.eesi.tue.nl
Advantage:
Advantage:
• service: access to embedded software:
Advantage: • service:
Advantage:
http://www.research.philips.com/generalinfo/special/ambintel/index.html
diagnostics,
leasing
of appliances
debugging,
replacement,
sell features
• remote diagnosis
• •service:
new
markets
• owner:
remote
monitor
& control,
owner:
standardisation,
newsecurity,
software 6
• owner: ease offleet
use,maintenance
comfort, integration
production-control,
•
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
Networks in embedded systems
initial processing
more processing
PE
sensor
PE
actuator
PE
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
7
Networking for Embedded Systems





Why we use networks.
Network abstractions.
Embedded Networks and TCP/IP.
Example networks.
Networks programming with sockets
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
8
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
9
OSI model
application
end-user interface
presentation
data format
session
application dialog control
transport
connections
network
end-to-end service
data link
reliable data transport
physical
mechanical, electrical
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
10
Hardware architectures
Many different types of networks:
• topology;
• scheduling of communication;
• routing.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
11
Point-to-point networks
One source, one or more destinations, no data
switching (serial port):
PE 1
PE 2
link 1
PE 3
link 2
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
12
Bus networks
Common physical connection:
PE 1
header
PE 2
address
PE 3
data
PE 4
ECC
packet format
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
13
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.
fixed
A
B
C
A
B
C
round-robin
A
B
C
B
C
A
A,B,C
A,B,C
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
14
Ethernet
 Dominant non-telephone LAN.
 Versions: 10 Mb/s, 100 Mb/s, 1 Gb/s, 10Gb/s.
 Goal: reliable communication over an unreliable
medium.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
15
Ethernet topology
Bus-based system, several possible physical
layers:
A
B
C
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
16
Ethernet packet format
preamble
start
frame
source
adrs
dest
data
length
padding CRC
adrs
payload
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
17
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
18
Networking for Embedded Systems





Why we use networks.
Network abstractions.
Embedded Networks and TCP/IP.
Example networks.
Networks programming with sockets
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
19
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
20
IP in communication
application
application
presentation
presentation
session
session
transport
IP
transport
network
network
network
data link
data link
data link
physical
physical
physical
node A
router
node B
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
21
Another look at TCP/IP for Embedded Devices
OSI Model
Layers
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
TCP/IP
Layers
TCP/IP Protocol Suite
Application
Layer
Telnet FTP SMTP
DNS POP3 SNMP
Transport
Layer
TCP
UDP
Internet
Layer
Link
Layer
Physical
Layer
IP
802.2
LLC
Ethernet
PPP
SLIP
Serial Port
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
22
TCP/IP Basics : Data Encapsulation
Application Data
App Header
Application Data
TCP Header App Header
Application Data
IP Header
TCP Header App Header
Application Data
Ethernet Header IP Header
TCP Header App Header
Application Data
Ethernet Trailer
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
23
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).
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
24
Networking for Embedded Systems





Why we use networks.
Network abstractions.
Embedded Networks and TCP/IP.
Example networks.
Networks programming with sockets
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
25
Embedded protocols and software
Request connection
Remote user
Program code
sensors
Applet
HTML browser
UDP
ES-Server
HTTP
(applet code)
actuators
HTTP server
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
26
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
27
Networking for Embedded Systems





Why we use networks.
Network abstractions.
Embedded Networks and TCP/IP.
Example networks.
Networks programming with sockets
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
28
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)
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
29
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
30
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
31
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
32
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
33
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
34
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
35
Connection-oriented use
Connection is first established between client and server
System 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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
36
Connection-oriented protocol
Client side
• socket() // same meaning as in server
• connect() //establish contact between local-remote
site
• read() write() //transfer data
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
37
Example, connection-oriented sequence
socket()
bind()
SERVER
CLIENT
listen()
accept()
Blocks
Until
connect
socket()
Connection establishment
connect()
Data(request)
read()
write()
Data (reply)
write()
read()
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
38
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
39
Example 2, connectionless sequence of calls
socket()
bind()
SERVER
CLIENT
recvfrom(addr1,…)
Blocks
Until data
received from client
socket()
bind()
Data(request)
sendto(addr1,…)
Data (reply)
sendto(addr2,…)
recvfrom(addr2,…)
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
40
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
41
What's next ?
 Lab 3 details by TA
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
42
BACKUP
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
43
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
44
The effect of Internet
• Data transport (large
distance)
• Standards: ftp, email, ...
network aware
• Distributed access
standalone
Interoperability
network
central
• Standards
for
time
offering services:
Jini, UPnP, OSGi
• Platform for
• Standards for
network connected• datafully
networked
exchange
• software architectures
integration
• communication: HTTP,•Java,
TCP, UDP, ....
..... + information exchange!!
• visualisation: browsers
• Global addressing
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
45
Example: A coffee maker
Switch and heat control
not networked
individually
Request connection
Program code
Remote user
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
46
Example: Javacam
 Hardware platform:
• parallel-port camera;
• National Semi NS486SXF;
• 1.5 Mbytes memory.
 Uses memory-efficient Java Nanokernel.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
47
Javacam architecture
QuickCam Web browser
applet
Quickcam
server
HTTP
QuickCam
Java VM
Java nanokernel
486
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
48
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
49
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)
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
50
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…
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
51
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
52
IP packet
 Includes:
•
•
•
•
version, service type, length
time to live, protocol
source and destination address
data payload
 Maximum data payload is 65,535 bytes.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
53
Embedding TCP/IP – The Advantages
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
•
Internet
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
54
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
55
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
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
56
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.
ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005
57