Internet Protocol (IP) Internet Protocol (IP) TCP versus UDP TCP - - PDF document

internet protocol ip internet protocol ip tcp versus udp
SMART_READER_LITE
LIVE PREVIEW

Internet Protocol (IP) Internet Protocol (IP) TCP versus UDP TCP - - PDF document

Special Course on Networked Virtual January 30, 2004 Environments Internet Protocol (IP) Internet Protocol (IP) TCP versus UDP TCP versus UDP Low Low- -level protocols used by hosts and routers level protocols used by hosts and routers


slide-1
SLIDE 1

Special Course on Networked Virtual Environments January 30, 2004 Jouni Smed 1

Internet Protocol (IP) Internet Protocol (IP)

  • Low

Low-

  • level protocols used by hosts and routers

level protocols used by hosts and routers

  • Guides the packets from source to destination host

Guides the packets from source to destination host

  • Hides the transmission path

Hides the transmission path

  • phone lines, LANs, WANs, wireless radios, satellite links, carri

phone lines, LANs, WANs, wireless radios, satellite links, carrier er pigeons,… pigeons,…

  • Applications rarely use the IP directly but the protocols that a

Applications rarely use the IP directly but the protocols that are re written on top of IP written on top of IP

  • Transmission Control Protocol (TCP/IP)

Transmission Control Protocol (TCP/IP)

  • User Datagram Protocol (UDP/IP)

User Datagram Protocol (UDP/IP)

TCP versus UDP TCP versus UDP

Transmission Control Protocol Transmission Control Protocol (TCP/IP) (TCP/IP)

  • Point

Point-

  • to

to-

  • point connection

point connection

  • Reliable transmission using

Reliable transmission using acknowledgement and acknowledgement and retransmission retransmission

  • Stream

Stream-

  • based data semantics

based data semantics

  • Big

Big overhead

  • verhead
  • data checksums

data checksums

  • Hard to

Hard to ‘skip ‘skip ahead’ ahead’

User User Datagram Datagram Protocol Protocol (UDP/IP) (UDP/IP)

  • Lightweight data transmission

Lightweight data transmission

  • Differs from TCP

Differs from TCP

  • connectionless transmission

connectionless transmission

  • ‘best

‘best-

  • efforts’

efforts’ delivery delivery

  • packet

packet-

  • based data semantics

based data semantics

  • Packets are easy to process

Packets are easy to process

  • Transmission and receiving

Transmission and receiving immediate immediate

  • No connection information for

No connection information for each host in the operating system each host in the operating system

  • Packet loss can be

Packet loss can be handled handled

UDP and Datagrams in Java UDP and Datagrams in Java

  • Dat agr am

Socket Dat agr am Socket can both send and receive packets can both send and receive packets

  • no server sockets because there is no need to establish a connec

no server sockets because there is no need to establish a connection tion

  • Dat agr am

Packet Dat agr am Packet includes all the data to be sent/received includes all the data to be sent/received

  • maximum size 64 kB

maximum size 64 kB

  • Constructing a receiving packet:

Constructing a receiving packet: byt e byt e byt e byt e[ ] buf f er = [ ] buf f er = ne new ne new byt e byt e byt e byt e[ CAPACI TY] ; [ CAPACI TY] ; Dat agr am Packet Dat agr am Packet dp1 = dp1 = new new new new Dat agr am Packet Dat agr am Packet ( buf f er , CAPACI TY) ; ( buf f er , CAPACI TY) ;

  • Constructing a packet to send:

Constructing a packet to send: byt e byt e byt e byt e[ ] m essage; [ ] m essage; / / The byt es t o send. / / The byt es t o send. Dat agr am Packet Dat agr am Packet dp2 = dp2 = new new new new Dat agr am Packet Dat agr am Packet ( m essage, m

  • essage. l engt h,

( m essage, m

  • essage. l engt h,

addr ess, por t ) ; addr ess, por t ) ;

Datagram Example Datagram Example

t r y t r y t r y t r y { { socket = socket = new new new new Dat agr am Socket Dat agr am Socket ( PO RT) ; ( PO RT) ; socket . r ecei ve( dp1) ; socket . r ecei ve( dp1) ; socket . send( dp2) ; socket . send( dp2) ; } } cat ch cat ch cat ch cat ch ( ( Socket Except i on Socket Except i on e) { e) { / / Coul d not open t he socket . / / Coul d not open t he socket . } } cat ch cat ch cat ch cat ch ( ( I O Except i on I O Except i on e) { e) { / / Pr obl em s wi t h com m uni cat i on. / / Pr obl em s wi t h com m uni cat i on. } } f i nal f i nal l y l y f i nal f i nal l y l y { { socket . cl ose( ) ; socket . cl ose( ) ; } }

Datagram Contents Datagram Contents

  • Sender’s address:

Sender’s address: I net Addr ess I net Addr ess addr = dp. get Addr ess( ) ; addr = dp. get Addr ess( ) ;

  • Sender’s port:

Sender’s port: i nt i nt i nt i nt por t = dp. get Por t ( ) ; por t = dp. get Por t ( ) ;

  • Packet payload size:

Packet payload size: i nt i nt i nt i nt si ze si ze = dp. get Lengt h( ) ; = dp. get Lengt h( ) ;

  • Packet payload data:

Packet payload data: byt e byt e byt e byt e[ ] [ ] dat a dat a = = dp. get Dat a( ) ;

  • dp. get Dat a( ) ;

IP Broadcasting IP Broadcasting

  • Using a single UDP/IP socket, the

Using a single UDP/IP socket, the same packet can be sent to same packet can be sent to multiple destinations by repeating multiple destinations by repeating the send the send call call

  • ‘unicasting’

‘unicasting’

  • great bandwidth is required

great bandwidth is required

  • each host has to maintain a list of

each host has to maintain a list of

  • ther hosts
  • ther hosts
  • IP broadcasting allows a single

IP broadcasting allows a single transmission to be delivered to all transmission to be delivered to all hosts on the network hosts on the network

  • a

a special bit mask of receiving special bit mask of receiving hosts is used as a address hosts is used as a address

  • With UDP/IP, the data is only

With UDP/IP, the data is only delivered to delivered to the applications the applications that that are receiving on a designated port are receiving on a designated port

  • Broadcast

Broadcast is expensive is expensive

  • each host has to receive and

each host has to receive and process every broadcast packet process every broadcast packet

  • Only recommended (and only

Only recommended (and only guaranteed) on guaranteed) on the local LAN the local LAN

  • Not suitable for Internet

Not suitable for Internet-

  • based

based applications applications

slide-2
SLIDE 2

Special Course on Networked Virtual Environments January 30, 2004 Jouni Smed 2

IP Multicasting 1 (3) IP Multicasting 1 (3)

  • Packets are only

Packets are only delivered delivered to to subscribers subscribers

  • Subscribers must explicitly

Subscribers must explicitly request packets from the local request packets from the local distributors distributors

  • No duplicate packets are sent

No duplicate packets are sent down the same distribution path down the same distribution path

  • Original

Original ‘publisher’ ‘publisher’ does not need does not need to know all subscribers to know all subscribers

  • Receiver

Receiver-

  • controlled distribution

controlled distribution

IP Multicasting 2 (3) IP Multicasting 2 (3)

‘Distributors’ Distributors’ are multicast are multicast-

  • capable routers

capable routers

  • They construct a multicast

They construct a multicast distribution tree distribution tree

  • Each multicast distribution tree is

Each multicast distribution tree is represented by a pseudo represented by a pseudo-

  • IP

IP address (multicast IP address, address (multicast IP address, class D address) class D address)

  • 224.0.0.0

224.0.0.0– –239.255.255.255 239.255.255.255

  • some

some addresses are reserved addresses are reserved

  • local applications should use

local applications should use 239.0.0.0 239.0.0.0– –239.255.255.255 239.255.255.255

  • Address collisions possible

Address collisions possible

  • Internet Assigned Number

Internet Assigned Number Authority (IANA) Authority (IANA)

  • Application

Application can specify the IP can specify the IP time time-

  • to

to-

  • live

live (TTL) value (TTL) value

  • how far multicast packets should

how far multicast packets should travel travel

  • 0: to the local host

0: to the local host

  • 1: on the local LAN

1: on the local LAN

  • 2

2– –31 31: to the local site (network) : to the local site (network)

  • 32

32– –63 63: to the local region : to the local region

  • 64

64– –127 127: to the local continent : to the local continent

  • 128

128– –254 254: deliver globally : deliver globally

IP Multicasting 3 (3) IP Multicasting 3 (3)

  • Provides desirable network efficiency

Provides desirable network efficiency

  • Allows partitioning of different types of data by using multiple

Allows partitioning of different types of data by using multiple multicast addresses multicast addresses

  • NVE participants can announce their presence by using

NVE participants can announce their presence by using application’s application’s well well-

  • known multicast address

known multicast address

  • Older routers do not support multicasting

Older routers do not support multicasting

  • Multicast

Multicast-

  • aware routers communicate directly by

aware routers communicate directly by ‘tunneling’ ‘tunneling’ data past the non data past the non-

  • multicast routers (Multicast Backbone,

multicast routers (Multicast Backbone, Mbone Mbone) )

  • Participant’s local router has to be multicast

Participant’s local router has to be multicast-

  • capable

capable

Multicasting in Java Multicasting in Java

  • Uses

Uses Dat agr am Packet Dat agr am Packet as in UDP as in UDP

  • Sender sends datagram packets to a multicast address

Sender sends datagram packets to a multicast address

  • Receiver joins the multicast address (group):

Receiver joins the multicast address (group): M ul t i cast Socket M ul t i cast Socket socket = socket = new new new new M ul t i cast Socket M ul t i cast Socket ( PO RT) ; ( PO RT) ; I net Addr ess I net Addr ess gr oup = gr oup = I net Addr ess I net Addr ess. get ByNam e( G RO UP_ADDRESS) ; . get ByNam e( G RO UP_ADDRESS) ; socket . j oi nG r oup( gr oup) ; socket . j oi nG r oup( gr oup) ;

  • Packets are received like normal UDP datagrams:

Packets are received like normal UDP datagrams: socket . r ecei ve( dp) ; socket . r ecei ve( dp) ;

  • Finally the receiver leaves the group and closes the socket:

Finally the receiver leaves the group and closes the socket: socket . l eaveG r oup( gr oup) ; socket . l eaveG r oup( gr oup) ; socket . cl ose( ) ; socket . cl ose( ) ;

Multicast Example: Sender Multicast Example: Sender

cl cl as ass M ul t i cast Sender { pr i v pr i vat at e Dat agr am Socket socket ; publ publ i c i c M ul t i cast Sender ( ) { t r y t r y { socket = new new Dat agr am Socket ( PO RT) ; } cat cat ch ch ( Socket Except i on e) { / * Const r uct i on f ai l ed. * / } } publ publ i c i c v voi d send( byt byt e[ ] dat a) { t r y t r y { Dat agr am packet = new new Dat agr am Packet ( dat a, dat a. l engt h, G RO UP_ADDRESS, PO RT) ; socket . send( packet ) ; } cat cat ch ch ( I O Except i on e) { / * Sendi ng f ai l ed. * / } } publ publ i c i c v voi d f i nal i ze( ) { i f i f ( socket ! = nul l nul l ) socket . cl ose( ) ; supe super . f i nal i ze( ) ; } }

Multicast Example: Receiver Multicast Example: Receiver

cl as cl ass M ul t i cast Recei ver { pr i va pr i vat e t e M ul t i cast Socket socket ; publ i publ i c M ul t i cast Recei ver ( ) { t r y t r y { socket = new new M ul t i cast Socket ( PO RT) ; socket . j oi nG r oup( G RO UP_ADDRESS) ; } cat ch cat ch ( I O Except i on e) { / * Joi ni ng f ai l ed. * / } } publ i publ i c b c byt e yt e[ ] r ecei ve( ) { byt e byt e[ ] buf f er = new byt new byt e[ BUFFER_SI ZE] ; Dat agr am Packet packet = ne new Dat agr am Packet ( buf f er , buf f er . l engt h) ; t r y t r y { socket . r ecei ve( packet ) ; r et ur n r et ur n packet . get Dat a( ) ; } cat ch cat ch ( I O Except i on e) { / * Recei vi ng f ai l ed. * / } r et ur r et ur n n n nul l ul l ; } publ i publ i c v c voi d

  • i d f i nal i ze( ) {

i f i f ( socket ! = nul l nul l ) { socket . l eaveG r oup( ) ; socket . cl ose( ) ; } super super . f i nal i ze( ) ; } } } }

slide-3
SLIDE 3

Special Course on Networked Virtual Environments January 30, 2004 Jouni Smed 3

Selecting Selecting an an NVE Protocol 1 (4) NVE Protocol 1 (4)

  • Multiple protocols can be used in a single system

Multiple protocols can be used in a single system

  • Not which protocol should I use in my NVE but which

Not which protocol should I use in my NVE but which protocol should I use to transmit protocol should I use to transmit this piece of information this piece of information? ?

  • Using TCP/IP

Using TCP/IP

  • reliable data transmission between two hosts

reliable data transmission between two hosts

  • packets are delivered in order, error handling

packets are delivered in order, error handling

  • relatively easy to use

relatively easy to use

  • point

point-

  • to

to-

  • point limits its use in large

point limits its use in large-

  • scale

scale NVEs NVEs

  • bandwidth overhead

bandwidth overhead

Selecting Selecting an an NVE Protocol 2 (4) NVE Protocol 2 (4)

  • Using UDP/IP

Using UDP/IP

  • lightweight

lightweight

  • ffers no reliability
  • ffers no reliability nor

nor guarantees the order of packets guarantees the order of packets

  • packets can be sent to multiple hosts

packets can be sent to multiple hosts

  • deliver time

deliver time-

  • sensitive information among a large number of hosts

sensitive information among a large number of hosts

  • more complex services

more complex services have have to be implemented in the application to be implemented in the application

  • serial

serial numbers, timestamps numbers, timestamps

  • recovery of lost packets

recovery of lost packets

  • positive acknowledgement scheme

positive acknowledgement scheme

  • negative acknowledgement scheme

negative acknowledgement scheme

  • more effective when the destination knows the sources and their

more effective when the destination knows the sources and their frequency frequency

  • transmit a quench packet if packets are received too

transmit a quench packet if packets are received too often

  • ften

Selecting Selecting an an NVE Protocol 3 (4) NVE Protocol 3 (4)

  • Using IP broadcasting

Using IP broadcasting

  • design considerations similar to (

design considerations similar to (unicast unicast) UDP/IP ) UDP/IP

  • limited to LAN

limited to LAN

  • not for

not for NVEs NVEs with with a large a large number of participants number of participants

  • to

to distinguish different applications distinguish different applications using the same using the same port port number number (or (or multicast multicast address): address):

  • Avoid the problem entirely: assign the necessary number

Avoid the problem entirely: assign the necessary number

  • Detect conflict and renegotiate: notify the participants and dir

Detect conflict and renegotiate: notify the participants and direct them to ect them to migrate a new port number migrate a new port number

  • Use protocol and instance magic numbers: each packet includes a

Use protocol and instance magic numbers: each packet includes a magic magic number at a well number at a well-

  • known position

known position

  • Use encryption

Use encryption

Selecting Selecting an an NVE Protocol 4 (4) NVE Protocol 4 (4)

  • Using IP multicasting

Using IP multicasting

  • provides

provides a quite a quite efficient efficient way way to transmit to transmit information among a large information among a large number of hosts number of hosts

  • information delivery is restricted

information delivery is restricted

  • time

time-

  • to

to-

  • live

live

  • group

group subscriptions subscriptions

  • preferred method for large

preferred method for large-

  • scale

scale NVEs NVEs

  • how

how to separate to separate the information the information flows among different multicast flows among different multicast groups groups

  • a single

a single group/address for all information group/address for all information

  • several multicast

several multicast groups to segment the information groups to segment the information

Communication Architectures Communication Architectures

  • Logical connections

Logical connections

  • how the messages flow

how the messages flow

  • Physical connections

Physical connections

  • the wires

the wires between the between the computers computers

  • the limiting factor in

the limiting factor in communication architecture communication architecture design design p1 p2 LAN Two players on a LAN

Example: How May Players Can We Example: How May Players Can We Put into a Two Put into a Two-

  • Player LAN?

Player LAN?

  • Distributed Interactive Simulation

Distributed Interactive Simulation (DIS) protocol data unit (PDU): (DIS) protocol data unit (PDU): 144 bytes (1,152 bits) 144 bytes (1,152 bits)

  • Graphics: 30 frames/second

Graphics: 30 frames/second

  • PDU rates

PDU rates

  • aircraft 12 PDU/second

aircraft 12 PDU/second

  • ground vehicle 5 PDU/second

ground vehicle 5 PDU/second

  • weapon firing 3 PDU/second

weapon firing 3 PDU/second

  • fully articulated human 30

fully articulated human 30 PDU/second PDU/second

  • Bandwidth

Bandwidth

  • Ethernet LAN 10 Mbps

Ethernet LAN 10 Mbps

  • modems 56 Kbps

modems 56 Kbps

  • Assumptions:

Assumptions:

  • sufficient processor power

sufficient processor power

  • no other network usage

no other network usage

  • a mix of player types

a mix of player types

⇒ ⇒ LAN: 8,680 packets/second LAN: 8,680 packets/second

fully articulated humans + firing = fully articulated humans + firing = 263 humans 263 humans aircrafts + firing = 578 aircrafts aircrafts + firing = 578 aircrafts ground vehicles + firing = 1,085 ground vehicles + firing = 1,085 vehicles vehicles

  • Typical NPSNET

Typical NPSNET-

  • IV DIS battle

IV DIS battle

  • limits to 300 players on a LAN

limits to 300 players on a LAN

  • processor and network

processor and network limitations limitations

slide-4
SLIDE 4

Special Course on Networked Virtual Environments January 30, 2004 Jouni Smed 4

Example (cont’d) Example (cont’d)

⇒ ⇒ Modem: 48 packets/second Modem: 48 packets/second

fully articulated humans + firing = 1 fully articulated humans + firing = 1 human human aircrafts + firing = 3 aircrafts aircrafts + firing = 3 aircrafts ground vehicles + firing = 6 vehicles ground vehicles + firing = 6 vehicles

  • Redesign packets

Redesign packets

  • size 22%, 32 bytes

size 22%, 32 bytes

⇒ ⇒ Modem: 218 packets/second Modem: 218 packets/second

fully articulated humans + firing = 7 fully articulated humans + firing = 7 human human aircrafts + firing = 14 aircrafts aircrafts + firing = 14 aircrafts ground vehicles + firing = 27 vehicles ground vehicles + firing = 27 vehicles

  • In a two

In a two-

  • player NVE on a LAN,

player NVE on a LAN, the protocol selection (TCP, UDP, the protocol selection (TCP, UDP, broadcast,...) hardly matters broadcast,...) hardly matters

  • As the number of live or

As the number of live or autonomous players increase an autonomous players increase an efficient architecture becomes efficient architecture becomes more important more important

Multiplayer Client Multiplayer Client-

  • Server

Server Systems: Systems: Logical Logical Architecture Architecture

  • Client

Client-

  • server system

server system

  • each player sends packets to

each player sends packets to

  • ther
  • ther players via a server

players via a server

  • Server slows down the message

Server slows down the message delivery delivery

  • Benefits of

Benefits of having a having a server server

  • no need to

no need to send all packets to all send all packets to all players players

  • compress multiple packets to a

compress multiple packets to a single packet single packet

  • smooth out

smooth out the packet flow the packet flow

  • reliable communication without

reliable communication without the overhead of a fully connected the overhead of a fully connected NVE NVE

  • administration

administration

p1 p2 pn Communication paths Multiplayer client-server - logical architecture

Multiplayer Client Multiplayer Client-

  • Server Systems:

Server Systems: Physical Architecture (on a LAN) Physical Architecture (on a LAN)

  • All messages in the same wire

All messages in the same wire

  • Server has to provide some added

Server has to provide some added-

  • value function

value function

  • collecting data

collecting data

  • compressing and redistributing information

compressing and redistributing information

  • additional computation

additional computation

p1 p2 LAN Multiplayer client-server - physical architecture on a LAN pn Server

Physical Physical Architecture Can Architecture Can Match Match the the Logical Logical Architecture Architecture

p1 p2 pn Server Phone lines Multiplayer client-server - physical architecture with phone lines

Multiplayer Multiplayer Client Client-

  • Server,

Server, with Multiple with Multiple-

  • Server

Server Architectures Architectures

  • Players

Players can locate in the same can locate in the same place in the NVE, but place in the NVE, but reside on reside on different different servers servers

  • Real World ≠ Virtual World

Real World ≠ Virtual World

  • Server

Server-

  • to

to-

  • server connections

server connections transmit transmit the world the world state state information information

  • WAN, LAN

WAN, LAN

  • Each server serves a number of

Each server serves a number of client players client players

  • LAN, modem, cable modem

LAN, modem, cable modem

  • Scalability

Scalability

p1,1 p1,2 p1,n p2,1 p2,2 p2,n p3,1 p3,2 p3,n Server 2 Server 3 Server 1

Peer Peer-

  • to

to-

  • Peer Architectures

Peer Architectures

  • In the

In the ideal ideal large large-

  • scale NVE

scale NVE design, design, avoid having avoid having servers at all servers at all

  • eventually we cannot scale out

eventually we cannot scale out

  • a finite

a finite number of players number of players

  • Design

Design goal goal

  • peer

peer-

  • to

to-

  • peer communication

peer communication

  • scalable within resources

scalable within resources

  • Peer

Peer-

  • to

to-

  • peer: communication

peer: communication goes goes directly from the sending player to directly from the sending player to the receiving player (or the receiving player (or a set a set of

  • f

them) them)

p1 p2 LAN Peer-to-peer on a LAN pn

p1,1 p1,2 p1,n p2,1 p2,2 p2,n p3,1 p3,2 p3,n Server 2 Server 3 Server 1

p3 p4 p2 p1

slide-5
SLIDE 5

Special Course on Networked Virtual Environments January 30, 2004 Jouni Smed 5

Peer Peer-

  • to

to-

  • Peer with Multicast

Peer with Multicast

  • For a scalable NVE on a LAN, use

For a scalable NVE on a LAN, use multicast multicast

  • To utilize multicast, assign packets

To utilize multicast, assign packets to proper multicast groups to proper multicast groups

  • Area

Area-

  • of
  • f-
  • interest management

interest management

  • assign outgoing packets to the

assign outgoing packets to the right groups right groups

  • receive incoming packets to the

receive incoming packets to the appropriate multicast groups appropriate multicast groups

  • keep track of available groups

keep track of available groups

  • even out stream information

even out stream information

p1 p2 Network AOIM software layer pn AOIM 1 AOIM 1 AOIM 1

Basic Basic Architecture Components Architecture Components

(Hint: This would be a good time to browse the additional literature.)