Download - L7a_TCP_UDP_EX
1
9/2000 1
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
TCP/IP - Example
9/2000 2
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
TCP/IP Protocol Suite
Application
Transport
Internet
Data Link
Physical
2
9/2000 3
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
TCP/IP And OSI Model
9/2000 4
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
L5 data
L5 data H4
L4 data H3
L3 data H2T2
01010101010110101
L5 data
L5 data H4
L4 data H3
L3 data H2T2
01010101010110101
5
4
3
2
1
5
4
3
2
1
Transmission medium
An Exchange Using the TCP Model
3
9/2000 5
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
TCP/IP Model - An Example
• The application being used is SMTP (electronic mail)• The message content is “hi” (ASCII - 68+69)• How this message flows through all the layers till it finally
reaches the destination.
9/2000 6
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
Application Layer
ApplicationEg. SMTP - Email
Application
Presentation
Session
6869
Message(2 bytes)
Local part@Domain name
Address of themailbox on thelocal site
The domain nameof the destination
Message formatting, data compression, data encryption,and synchronization of data exchange
4
9/2000 7
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
Transport Layer
TCP UDP
TransportH
TCP Header(20 bytes)
User datagram(22 bytes)
6869
2 bytes
End-to-end delivery of message, addressing service points,reliable delivery, multiplexing
9/2000 8
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
TCP Header
- 520 - 520
- 6869
5H
5
9/2000 9
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
Network Layer
IP
NetworkH
IP header(20 bytes)
Datagram(42 bytes)
Source-to-destination delivery, addressing, address resolution
User datagram(22 bytes)
9/2000 10
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
IP Header
4H 5H 0026H
0.0.0
80H 11H
9594H
128.194.55.152
128.194.55.254
6
9/2000 11
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
Data Link & Physical Layer
Data link
Physical
Protocols defined by theunderlying layer
10010101010001
H
Frame(68 bytes)
Bits
Header(14 bytes)
Datagram
Delivering data units, flow control, error detection, access control, conversion of data bits into electric signals and transmission
T
Trailer(4 bytes)
9/2000 12
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
802.3 MAC Frame
• Destination address : 00:c0:02:16:67:36• Source address : 00:80:5f:57:a9:a8• Type : 0800H (IP)
Type
7
9/2000 13
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
UDP: Example
9/2000 14
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
USER DATAGRAM PROTOCOL
• Connectionless• Unreliable• Simple• Packet Oriented• Simple Application Interface
8
9/2000 15
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
UDP Frame
Source Port(16 Bits)
Destination Port(16 Bits)
Length(16 Bits)
Checksum(16 Bits)
DATA
Length of Datagram
Optional : 16 bit one’s complement sum of the pseudo IP header, the UDP Header and the Data.
9/2000 16
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
PROTOCOLS USING UDP
• SNMP • DNS• BOOTP• TFTP• SUNRPC• SNMPTRAP• NFS• RIP• GDP• BIFF• WHO• SYSLOG
9
9/2000 17
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
UDP FRAME CAPTURED
ADDR HEX ASCII0000: 00 60 2f dd 1d 20 08 00 20 8f 9b 39 08 00 45 00 | .`/.. .. ..9..E.0010: 00 48 7c 20 40 00 ff 11 b0 8e 82 bf a3 74 82 bf | .H| @........t..0020: a6 02 a5 f2 00 35 00 34 f9 ba 4f 04 01 00 00 01 | .....5.4..O.....0030: 00 00 00 00 00 00 01 32 03 31 36 36 03 31 39 31 | .......2.166.1910040: 03 31 33 30 07 69 6e 2d 61 64 64 72 04 61 72 70 | .130.in-addr.arp0050: 61 00 00 0c 00 01 | a..…
UDP: ----- UDP Header -----UDP:UDP: Source port = 42482
UDP: Destination port = 53 (Domain)UDP: Length = 52
UDP: Checksum = F9BA (correct)UDP: [44 byte(s) of data]
9/2000 18
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
UDP DATAGRAMS in JAVA
• Applications that communicate via datagrams send and receive completely independent packets of information. These clients andservers do not have and do not need a dedicated point-to-point channel. The delivery of datagrams to their destinations is not guaranteed. Nor is the order of their arrival.
Definition: A datagram is an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed.
• The java.net package contains two classes to help you write Java programs that use datagrams to send and receive packets over the network: DatagramSocket, DatagramPacket, and MulticastSocket
• An application can send and receive DatagramPackets through aDatagramSocket. In addition, DatagramPackets can be broadcast to
multiple recipients all listening to a MulticastSocket.
10
9/2000 19
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
To Send Datagrams
int port;InetAddress address;DatagramSocket socket = null;DatagramPacket packet;byte[] sendBuf = new byte[256];
DatagramSocket socket = new DatagramSocket();
byte[] buf = new byte[256];InetAddress address =
9/2000 20
Telecommunication Engineering Technology, Texas A&M University LAN WAN Lecture Notes - Copyright Jeff M. McDougall 2001
To Receive Datagrams
int port;InetAddress address;DatagramSocket socket = null;DatagramPacket packet;byte[] sendBuf = new byte[256];
DatagramSocket socket = newDatagramSocket(port);
byte[] buf = new byte[256];
packet = new DatagramPacket(buf, buf.length);
socket.receive(packet);