internet protocol ip internet protocol ip tcp versus udp
play

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


  1. 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 � Transmission Control Protocol Transmission Control Protocol User User Datagram Datagram Protocol Protocol (TCP/IP) (UDP/IP) � Guides the packets from source to destination host Guides the packets from source to destination host (TCP/IP) (UDP/IP) � � Point Point- -to to- -point connection point connection � Lightweight data transmission Lightweight data transmission � � � Hides the transmission path Hides the transmission path � � Reliable transmission using Reliable transmission using � Differs from TCP Differs from TCP � � � phone lines, LANs, WANs, wireless radios, satellite links, carri phone lines, LANs, WANs, wireless radios, satellite links, carrier er � acknowledgement and acknowledgement and � connectionless transmission connectionless transmission � pigeons,… pigeons,… retransmission retransmission � ‘best ‘best- -efforts’ efforts’ delivery delivery � � Applications rarely use the IP directly but the protocols that a Applications rarely use the IP directly but the protocols that are re � � Stream Stream- -based data semantics based data semantics � packet packet- -based data semantics based data semantics � � written on top of IP written on top of IP � Big Big overhead overhead � Packets are easy to process Packets are easy to process � � � Transmission Control Protocol (TCP/IP) Transmission Control Protocol (TCP/IP) � � data checksums data checksums � Transmission and receiving Transmission and receiving � � � User Datagram Protocol (UDP/IP) User Datagram Protocol (UDP/IP) � � Hard to Hard to ‘skip ‘skip ahead’ ahead’ 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 Datagram Example Datagram Example Socket can both send and receive packets can both send and receive packets � Dat agr am � Dat agr am Socket t r y t r y t r y t r y { { � 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 � socket = new new Dat agr am new Dat agr am Socket ( PO ( PO RT) ; socket = new Socket RT) ; Packet includes all the data to be sent/received includes all the data to be sent/received � Dat agr am � Dat agr am Packet socket . r ecei ve( dp1) ; socket . r ecei ve( dp1) ; � maximum size 64 kB maximum size 64 kB � � Constructing a receiving packet: Constructing a receiving packet: socket . send( dp2) ; socket . send( dp2) ; � byt e byt e byt e byt e[ ] buf f er = [ ] buf f er = ne ne new byt e new byt e[ CAPACI TY] ; byt e byt e [ CAPACI TY] ; } cat ch cat ch ( cat ch ( Socket Except i on Socket Except i on e) { e) { } cat ch Dat agr am Packet dp1 = Dat agr am Packet dp1 = / / Coul d not open t he socket . / / Coul d not open t he socket . new new new Dat agr am new Dat agr am Packet Packet ( buf f er , CAPACI TY) ; ( buf f er , CAPACI TY) ; � Constructing a packet to send: Constructing a packet to send: � } cat ch } cat ch cat ch cat ch ( ( I O I O Except i on Except i on e) { e) { byt e byt e byt e byt e[ ] m [ ] m essage; essage; / / The byt es t o send. / / The byt es t o send. / / Pr obl em / / Pr obl em s wi t h com s wi t h com m m uni cat i on. uni cat i on. Dat agr am Packet dp2 = Dat agr am Packet dp2 = } f i nal f i nal f i nal l y l y { { new new new new Dat agr am Dat agr am Packet Packet ( m ( m essage, m essage, m essage. l engt h, essage. l engt h, } f i nal l y l y addr ess, por t ) ; addr ess, por t ) ; socket . cl ose( ) ; socket . cl ose( ) ; } } Datagram Contents IP Broadcasting Datagram Contents IP Broadcasting � Using a single UDP/IP socket, the Using a single UDP/IP socket, the � With UDP/IP, the data is only With UDP/IP, the data is only � Sender’s address: Sender’s address: � � � same packet can be sent to same packet can be sent to delivered to the applications delivered to the applications that that I net Addr ess addr = dp. get Addr ess( ) ; I net Addr ess addr = dp. get Addr ess( ) ; multiple destinations by repeating multiple destinations by repeating are receiving on a designated port are receiving on a designated port the send call call � Sender’s port: Sender’s port: the send � Broadcast Broadcast is expensive is expensive � � � ‘unicasting’ ‘unicasting’ � � each host has to receive and each host has to receive and � i nt i nt i nt i nt por t = dp. get Por t ( ) ; por t = dp. get Por t ( ) ; � great bandwidth is required great bandwidth is required process every broadcast packet process every broadcast packet � � Packet payload size: Packet payload size: � each host has to maintain a list of each host has to maintain a list of � Only recommended (and only Only recommended (and only � � � other hosts other hosts guaranteed) on the local LAN guaranteed) on the local LAN i nt i nt i nt i nt si ze si ze = dp. get Lengt h( ) ; = dp. get Lengt h( ) ; � Not suitable for Internet Not suitable for Internet- -based based � � Packet payload data: Packet payload data: � � IP broadcasting allows a single IP broadcasting allows a single applications applications � transmission to be delivered to all transmission to be delivered to all byt e byt e[ ] [ ] dat a dat a = = dp. get Dat a( ) ; dp. get Dat a( ) ; byt e byt e 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 Jouni Smed 1

Recommend


More recommend