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