57
354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2 Big Picture: Lab 3 Networks Csaba Andras Moritz physical data link network transport presentation application session physical data link network transport presentation application session physical data link network IP

Big Picture: Lab 3

  • 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

Page 1: Big Picture: Lab 3

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

Page 2: Big Picture: Lab 3

2ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005

Readings

Textbook Chapter 8

Page 3: Big Picture: Lab 3

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.

Page 4: Big Picture: Lab 3

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

Page 5: Big Picture: Lab 3

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

Page 6: Big Picture: Lab 3

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

Page 7: Big Picture: Lab 3

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

Page 8: Big Picture: Lab 3

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

Page 9: Big Picture: Lab 3

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.

Page 10: Big Picture: Lab 3

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

Page 11: Big Picture: Lab 3

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.

Page 12: Big Picture: Lab 3

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

Page 13: Big Picture: Lab 3

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

Page 14: Big Picture: Lab 3

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

Page 15: Big Picture: Lab 3

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.

Page 16: Big Picture: Lab 3

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

Page 17: Big Picture: Lab 3

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

Page 18: Big Picture: Lab 3

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.

Page 19: Big Picture: Lab 3

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

Page 20: Big Picture: Lab 3

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.

Page 21: Big Picture: Lab 3

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

Page 22: Big Picture: Lab 3

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

Page 23: Big Picture: Lab 3

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

Page 24: Big Picture: Lab 3

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

Page 25: Big Picture: Lab 3

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

Page 26: Big Picture: Lab 3

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

Page 27: Big Picture: Lab 3

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

Page 28: Big Picture: Lab 3

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

Page 29: Big Picture: Lab 3

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)

Page 30: Big Picture: Lab 3

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

Page 31: Big Picture: Lab 3

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.

Page 32: Big Picture: Lab 3

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.

Page 33: Big Picture: Lab 3

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

Page 34: Big Picture: Lab 3

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

Page 35: Big Picture: Lab 3

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

Page 36: Big Picture: Lab 3

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

Page 37: Big Picture: Lab 3

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

Page 38: Big Picture: Lab 3

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

Page 39: Big Picture: Lab 3

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.

Page 40: Big Picture: Lab 3

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

Page 41: Big Picture: Lab 3

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.

Page 42: Big Picture: Lab 3

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

Page 43: Big Picture: Lab 3

43ECE 354 © Moritz 2009, some slides modified from Koren, Burleson, UMass and Wolf, Computers as Components, Morgan Kaufman, 2005

BACKUP

Page 44: Big Picture: Lab 3

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.

Page 45: Big Picture: Lab 3

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

Page 46: Big Picture: Lab 3

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

Page 47: Big Picture: Lab 3

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.

Page 48: Big Picture: Lab 3

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

Page 49: Big Picture: Lab 3

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

Page 50: Big Picture: Lab 3

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)

Page 51: Big Picture: Lab 3

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…

Page 52: Big Picture: Lab 3

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

Page 53: Big Picture: Lab 3

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.

Page 54: Big Picture: Lab 3

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

Page 55: Big Picture: Lab 3

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

Page 56: Big Picture: Lab 3

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

Page 57: Big Picture: Lab 3

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.