· 1 1 ˘ ˇ ˆ ( ˙ ˘ ˝ ˛ ˚ ˜ ˜I ˜˜ # %& #y ˛ ! ’’( A note on the use of these ppt...
Transcript of · 1 1 ˘ ˇ ˆ ( ˙ ˘ ˝ ˛ ˚ ˜ ˜I ˜˜ # %& #y ˛ ! ’’( A note on the use of these ppt...
1
������������� ��� 1
����������������� ���
��� ������ �� ����������� ���� �� �������������������������������� ������ �! �� �"���#���"����$ �##����#��%& �#�����! �����''( �
A note on the use of these ppt slides:We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following:� If you use these slides (e.g., in a class) in substantially unaltered form, that you mention their source (after all, we’d like people to use our book!)� If you post any slides in substantially unaltered form on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2004J.F Kurose and K.W. Ross, All Rights Reserved
������������� ��� 2
�����������������������
❒ � )�*��������#��+���� ������������#
❒ � ��& �,����- � � *
❒ � ���� *�
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
2
������������� ��� 3
������������������� ���
1 ������#�
❒ ������������ ���� ������#���#��+���� ��������������������#
❍ ��#���%�����#��9����� ����#
❍ �����%#��9���������
❍ ����%�%�����������
❒ �����,����������#�,���:� ���������������������%��9����������#
❍ - � � *
❍ �� *
❍ 0 / � *�;�*1 *��;��/ �*
❍ � � 0
❒ ������ � ������� ������������#
❍ #������*�
������������� ��� 4
0 �� ����� ������#
❒ .%� ��
❒ & �,
❒ ��#��� �##����
❒ $ �� ��������
❒ *�*�+����#�����
❒ / ���%�#������ ������ �#
❒ 0 ��� ����#�����9���������#
❒ ���������������
❒ $ ��%�� ��9��������+������
❒ / ##�9������������ �����
3
������������� ��� 5
����������� ������
& ���������� #��❍ ���������++���������
#�#�� #���
❍ ��� � �������9������� ���
❍ � � ��& �,��& �,�#��9���#�+� ������ � �����#�� ���,��� #���#�+� ��
� ��#�+� ���� �����+�����9���#������� ��������
❍ � �� �����������9���#�������+���������������
❍ � ��#���#�������� #�+�������������9����� ��
����������#������ ������������#���
����������#������ ������������#���
����������#������ ������������#���
������������� ��� 6
�����������������������
❒ � )�*��������#��+���� ������������#
❒ � ��& �,����- � � *
❒ � ���� *�
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
4
������������� ��� 7
�������������������#
❒ �����%#��9��
❒ *���%�%�����<*�*=
❒ - �,�����+������%#��9������*�*
������������� ��� 8
�����%#��9�����������
#��9���❍ �� �#%�����#❍ ���� �����*�����##❍ #��9���+�� #�+���#�����
�����#�❍ ��� � ������� ���
#��9��❍ � ��,������� ������
��������❍ � ���9������ ����*�
����##�#❍ ��������� � ������
��������� �����������
5
������������� ��� 9
*����*�*����������
❒ ����� �#����#��9��
❒ �,���������#�#�� #������������ � �����
❒ ����#��������� �������������������������*�����##�#
❒ �:� �����> �����
- ������#��,��
8 ����++�������� ���
������������� ��� 10
- �,�����+������%#��9������*�*
� �#��❍ �������#+���*�*❍ �����#�����������?����
@ *���#�����#����������������#��9��@ *���#�A�����#� ��������#��9���������������
��#��� �##����❍ ������,�� ����� ���#��#��#�*�*❍ *��#������������;�������������?���
@ 6 #�������#��#��#��*�����##�� ���������#��9���� ��������� �#�������
@ 6 #�������#�������#��9�����+�����*�����##�#��+�,�����#
6
������������� ��� 11
*����##�#���� � �������
*����##� ������ ���������� ��������#
❒ � �����#� ����#��� �������##�#���� � �������#���������%�����##���� � ������� <��+�����,��1 0 =
❒ �����##�#������++�������##���� � ������,���:��������� �##��#
�����������##� �����##��������#���� � �������
0 ��9��������##� �����##���� �#���,��������
❒ � ������������#�� ���*�*����������#��9�������������##�#�B �#��9��������##�#
������������� ��� 12
0 ����#
❒ �����##�#���#;�����9�#�� �##��#��;+��� ��#�#����
❒ #�����������#�������❍ #������������##�#��9�#�
� �##����������
❍ #������������##������#������#������+�#���������������#�����+������� �����,����#�� �##�����#�����������9���������##
process
TCP withbuffers,variables
socket
host orserver
process
TCP withbuffers,variables
socket
host orserver
Internet
controlledby OS
controlled byapp developer
❒ �*���<)=���������+���#�����������C�<�=�,�������+�:��+�� ���� ���#�<��#�� ����������#����=
7
������������� ��� 13
�����##���������##�#
❒ ����������##��������9��� �##��#����� �#��9���������+���
❒ ����#��#�����A����%,���*�����##
❒ D � ���#�����*�����##��+������#����� ��������������##����#�#�++����+��������+�������������##E
❒ ��#� ��� � ���� ��������##�#����,�������������#� ����#
❒ �����+�����������#�,�������*�����##����������� ,��###������� �����������##���������#
❒ .:� ����������� ,��#�❍ - � � *�#��9����5'
❍ / ���#��9�����2
❒ / ���������#����
������������� ��� 14
���%���������������+���#
❒ � ���#��+�� �##��#��:��������������A��#�B ���#���#��� �##��#
❒ 0 ��:��+�� �##������#��� ��+����#����� �##��#�B ���� �+����#������������
❒ 0 �� ���#��+����+����#������� �������+���+��� �������+����#
❒ $ ���#�+���� ���������� ������##�#�#����B ���#�������� �##��#
*�,���%��� ����������#�
❒ ��+��������$ ��#
❒ ���� #�+�����������,����
❒ ����- � � *��0 / � *
*����������������#�
❒ ����"F �
8
������������� ��� 15
& ����#����#��9�������#����������E
� ���##❒ #�� ����#�<� � ������=����
������#�� ����##❒ �������#�<� � ��+����
��#+��������=���A�����)''G �����,�������#+��
� �� ���❒ #�� ����#�<� � ��
�����������������������9���� �#=���A�������� ��������,��H�++���9�I
8 ��� ���
❒ #�� ����#�<� � ��� ���� ���=���A������ ���� �� �� �����+�,��� ������,��H�++���9�I
❒ �������#�<H��#�����#I=�� ����#���+�� ��9���,��� �����������
������������� ��� 16
� ��#����#��9������A����� ��#��+���� � �����#
Application
file transfere-mail
Web documentsreal-time audio/video
stored audio/videointeractive gamesinstant messaging
Data loss
no lossno lossno lossloss-tolerant
loss-tolerantloss-tolerantno loss
Bandwidth
elasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelastic
Time Sensitive
nononoyes, 100’s msec
yes, few secsyes, 100’s msecyes and no
9
������������� ��� 17
���������#�����������#�#��9���#
� �*�#��9����❒ ���������%�������� #����
��A������,�� �������������#��9��������##�#
❒ ����,�����#����,�� ����#���������������9���������##
❒ +��� �������� #������� ��J��9��� ���� ������9���
❒ �����#����������� ������#������� ������� �����9�������
❒ ���#�������9���� �� ������ ���� �� �,��� ����������#
6 � *�#��9����❒ ������,�������#+���
,�� ����#���������������9���������##
❒ ���#�������9���������������#���������,������+��� ��������������#�������������� ��������,��� �����������
D � � ���,����E��& ����#�������6 � *E
������������� ��� 18
���������#���������������#�����������#
Application
e-mailremote terminal access
Web file transfer
streaming multimedia
Internet telephony
Applicationlayer protocol
SMTP [RFC 2821]Telnet [RFC 854]HTTP [RFC 2616]FTP [RFC 959]proprietary(e.g. RealNetworks)proprietary(e.g., Dialpad)
Underlyingtransport protocol
TCPTCPTCPTCPTCP or UDP
typically UDP
10
������������� ��� 19
�����������������������
❒ � )�*��������#��+���� ������������#�
❍ ������������#
❍ �����A����� ��#
❒ � ��& �,����- � � *
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
������������� ��� 20
& �,����- � � *
���#�#�� ��K����
❒ & �,���� ���#�##��+��,K��#
❒ 1 ,K������,��- � / �+�����! *.> ��� ����! 9������������+����L
❒ & �,��������#�##��+�,#��- � / %+��� � ������������#�#�9������+���������,K��#
❒ .����,K����#�����##,���,���6 $
❒ .:� ����6 $ �
www.someschool.edu/someDept/pic.gif
��#��� � ����� �
11
������������� ��� 21
- � � *��9��9���
- � � *��������:���#+����������
❒ & �,J#����������������������
❒ �����;#��9���� ����
❍ ������ ,��� #�������A��##�������9�#��H��#���#I�& �,��,K��#
❍ #��9��� & �,�#��9���#���#��,K��#������#���#������A��##
❒ - � � *�) ' ��$ ���)7(2
❒ - � � *�) )��$ ����'35
*���������.:������
0 ��9����������
������& �,#��9��
/ ���������� 9����
- � � *���A��#
- � � *���A��#
- � � *���#���#�
- � � *���#���#�
������������� ��� 22
- � � *��9��9��� �<��������=
6 #�#�� �*�❒ �����������#�� �*�
����������<����#�#����=���#��9��������5'
❒ #��9�������#�� �*�����������+��� ������
❒ - � � *�� �##��#�<��������%�������������� �##��#=��:�������,�� ����,��� #���<- � � *������=����& �,�#��9���<- � � *�#��9��=
❒ � �*��������������#��
- � � *��#�H#���##I❒ #��9���� ����#����
��+��� ����,����#���������A��##
*������#���� �����H#�I������� ���:M
❒ �#���#����<#�=�� �#�,��� ������
❒ �+�#��9��;��������#��#�������9��� #��+�H#�I�� ��,�������#�#����� �#�,������������
#���
12
������������� ��� 23
- � � *����������#
� �����#�#���- � � *
❒ ��� �#������,K����#�#����9����� �*����������
❒ - � � *;) ' ��#�#�������#�#���- � � *
*��#�#���- � � *
❒ / ��������,K��#����,��#����9���#������� �*�����������,�� �������������#��9��
❒ - � � *;) )��#�#����#�#������������#������+���� ���
������������� ��� 24
� �����#�#���- � � *0 ����#���#�������#�6 $ �
www.someSchool.edu/someDepartment/home.index
) - � � *������������#�� �*�������������- � � *�#��9���<�����##=��www.someSchool.edu on port 5'
� - � � * ������#���#�- � � *���A��#�� �##�� <���������6 $ =������ �*�����������#���� �/ �##���������#���������� �#��,K���someDepartment/home.index
), - � � * #��9������#�www.someSchool.edu � �����+���� �*����������������5 ' ��H����#I���������������+����������
� - � � * #��9��������9�#���A��#�� �##����+��� #���#���#��� �##�� �����������A��#����,K�������#���#�� �##��������#�#����
�� �
(contains text, references to 10
jpeg images)
13
������������� ��� 25
� �����#�#���- � � *�<��� =
2 - � � *������������9�#���#���#��� �##�������������� ��+�������#���#��� � ��*�#������ ��+�����+���#�)'���+��������K������,K��#
3 0 ��#�)%2��������+��������+�)'�K�����,K��#
( - � � * #��9������#�#�� �*���������� �
�� �
������������� ��� 26
$ �#���#���� ��� �������
� �+��������+�$ $ � � �� ����#�����#� �����������9���+��� ���������#��9������,��
$ �#���#���� ��
❒ ����$ � � ���������� �*����������
❒ ����$ � � �+���- � � *���A��#����+��#�+�� �,��#��+�- � � *���#���#���������
❒ +������#� �##������ �
���N��$ � � O��#� ���� �
time to transmit file
initiate TCPconnection
RTT
requestfile
RTT
filereceived
time time
14
������������� ��� 27
*��#�#���- � � *
� �����#�#���- � � *��##��#�
❒ ��A����#���$ � � # �����,K��
❒ 1 0 �� �#�� ���������������#���#�����#�+�������� �*����������
❒ ,��,��� #��#��+���������������� �*����������#���+������+���������,K��#
*��#�#����- � � *
❒ #��9�����9�#����������������+���#���������#���#�
❒ #�,#�A����- � � *�� �##��#��,�� ����#� �������;#��9������#����9������������
*��#�#���� ����������������
❒ �������##��#���� ���A��#������� �������9���#���#���#���#�,���������9��
❒ ����$ � � �+���������+���������,K��
*��#�#���� ��������������
❒ ��+������- � � *;) )
❒ ������#���#���A��##�#�#����#�����������#����+���������,K��
❒ #������#�����$ � � �+�����������+���������,K��#
������������� ��� 28
- � � *���A��#�� �##��
❒ � �����#��+�- � � *�� �##��#����A��#����#���#�❒ - � � *���A��#�� �##���
❍ �0 ����<��� �%���,���+��� =
GET / somedi r / page. ht ml HTTP/ 1. 1Host : www. someschool . eduUser - agent : Mozi l l a/ 4. 0Connect i on: c l ose Accept - l anguage: f r
(extra carriage return, line feed)
��A��#�����<> .� ��*1 0 � ��
- .�� ���� � ��#=
���������#
�������������������+����
������#������+�� �##��
15
������������� ��� 29
- � � *���A��#�� �##�����������+���
������������� ��� 30
6 ��������+��� �����
*�#�� �����
❒ & �,������+����������#�+��� �����
❒ ������#�����������#��9�����������,���
6 $ �� �����
❒ 6 #�#�> .� �� ����
❒ ������#������������6 $ �+������+���A��#������
www.somesite.com/animalsearch?monkeys&banana
16
������������� ��� 31
/ ��������#
- � � *;) '
❒ > .�
❒ *1 0 �
❒ - .��❍ #�#�#��9�������9��
��A��#����,K�������+���#���#�
- � � *;) )
❒ > .� ��*1 0 � ��- .��
❒ *6 �❍ �����#�+������������
,���������#����+�������6 $ �+����
❒ � . .� .❍ �����#�+����#����+�������
���6 $ �+����
������������� ��� 32
- � � *���#���#��� �##��
HTTP/ 1. 1 200 OK Connect i on c l oseDat e: Thu, 06 Aug 1998 12: 00: 15 GMT Ser ver : Apache/ 1. 3. 0 ( Uni x) Last - Modi f i ed: Mon, 22 Jun 1998 …. . . Cont ent - Lengt h: 6821 Cont ent - Type: t ext / ht ml
dat a dat a dat a dat a dat a . . .
#�#�����<�������
#�#�����#�#����#�=
���������#
���� � ����A��#��- � / �+���
17
������������� ��� 33
- � � *���#���#��#�#�����#
200 OK❍ ��A��#�#������������A��#����,K������������#�� �##��
301 Moved Per manent l y❍ ��A��#����,K���� �9������� ��������#����+�����������
��#�� �##���< ������=
400 Bad Request❍ ��A��#�� �##�����������#����,��#��9��
404 Not Found❍ ��A��#�������� ������+����������#�#��9��
505 HTTP Ver si on Not Suppor t ed
���+��#���������#��9��%P��������#���#��� �##��
��+�� �#� ��������#�
������������� ��� 34
� ���������- � � *�<������#���=�+�������#��+
) �� ������������+9�����& �,�#��9���
1 ���#�� �*�����������������5'<��+���- � � *�#��9������=����# ���� ��� ����������������#���������5'����# ���� ���
t el net c i s. pol y. edu 80
� �� ��������> .� �- � � *���A��#�
GET / ~r oss/ HTTP/ 1. 1Host : c i s. pol y . edu
8 ����������#����<���������������� ���=������#�����#�� ���� ��<,����� ����=�> .� ���A��#���- � � *�#��9��
� � �������#���#��� �##���#���,��- � � *�#��9��M
18
������������� ��� 35
6 #��%#��9���#���������#
/ ���� K���& �,�#��#��#��������#
�������� �����#�)=����������������������
���- � � *���#���#��� �##��
�=����������������������- � � *���A��#�� �##��
�=��������+������������#��J#���#����� �����,���#��J#�,��� #��
(=�,��%�����,#���& �,�#��
.:� ����❍ 0 �#�����##��������
�� �#�+��� �#� ��*�
❍ 0 ���9�#�#��#����+����%��� � �����#���+���+��#��� �
❍ & ����������- � � *���A��##����9�#��#����#�������#�����A����� ��������#�����������,�������,#��+�����
������������� ��� 36
������#����������H#�I�<��� =
����� #��9��
�#��������A��#�� #�
�#��������#���#��OSet - cooki e: 1678
�#��������A��#�� #�cooki e: 1678
�#��������#���#��� #�
�#��������A��#�� #�cooki e: 1678
�#��������#���#��� #�
������%#����+������
������%#����+��
����
#��9������#���
)345�+����#��
entry in backend
database
access
acce
ss
Cookie file
amazon: 1678ebay: 8734
Cookie file
ebay: 8734
Cookie file
amazon: 1678ebay: 8734
����� ��������
19
������������� ��� 37
������#�<��������=
& ��������#����,�����
❒ �����?���
❒ #����������#
❒ ����� � ������#
❒ �#���#�##����#��<& �,��%� ��=
������#�������9���
❒ ������#����� ��#��#������������,������
❒ ����� ��#�������� ������%� �����#��#
❒ #�����������#��#��������������B �������#������������ ���
❒ �9���#�������� ����#���,�����+�����##�#��#
#���
������������� ��� 38
& �,�����#�<���:��#��9��=
❒ �#���#�#�,��� #����& �,����##�#�9�������
❒ ,��� #���#���#����- � � *���A��##��������
❍ �,K����������������������#��,K���
❍ ��#���������A��##��,K���+��� ��������#��9�������������#��,K����������
> ��� #�#+����������A��#�� �������9��9�����������#��9��
�����
*��:�#��9��
�����
- � � *���A��#
- � � *���A��#
- � � *���#���#�
- � � *���#���#�
- � � *���A��#
- � � *���#���#�
�������#��9��
�������#��9��
20
������������� ��� 39
/ ����,���& �,�������
❒ ������#�#�,������������#��9��
❒ � ��������������#���#�����,���0 *�<���9��#������� �������#��������0 *=
& ���& �,�������E❒ $ ��������#���#���� ��+���
��������A��#
❒ $ �������++����������#�����J#����##�����
❒ ����������#��� �������#���,��#�H����I����������9����#����++���9��������9���������<,��#�����#�*�*�+����#�����=
������������� ��� 40
��������:� ����
�##�� ����#
❒ 9������,K���#�?��N�)''�'''�,�#
❒ 9� ���A��#����+��� ���#�����J#�,��� #��#����������#��9��#�N�)2;#��
❒ �����+��� ���#�������������������������#��9������,������������N���#��
���#�A�����#❒ ����?������� �� �N�)2G
❒ ����?����������##������N�)''G
❒ ����������N�������������O����##������O� �� �����
N����#���O�� ����#�O�� ����#�����#
������#��9��#
��,���������
��#��������� ��� )'�/ ,�#� ��
) 2�/ ,�#����##�����
��#����������
21
������������� ��� 41
��������:� ����<���=
*�##�,���#������
❒ �����#��,��� �����+����##���������#���)' �/ ,�#
���#�A�����#❒ ����?������� �� �N�)2G
❒ ����?����������##������N�)2G
❒ � ����������N�������������O����##������O� �� �����
N����#���O�� #��# O�� #��#
❒ �+������#���������
������#��9��#
��,���������
��#��������� ��� )'�/ ,�#� ��
)'�/ ,�#����##�����
��#����������
������������� ��� 42
��������:� ����<���=
��#�������❒ #����#���������#� (
���#�A�����❒ ('G ���A��##�� ����,��
#�#+������ �#��� � ������❒ 3'G ���A��##�#�#+����,��
�������#��9��❒ ����?�����+����##������
����������3'G ����#����������������,��������#�<#��)' �� #��=
❒ ���9� �������N�������������O����##������O� �� ��������N�� 3Q<� ' )=�#��# O�� ����#�����#�R�) (�#��#
������#��9��#
��,���������
��#��������� ��� )'�/ ,�#� ��
) 2�/ ,�#����##�����
��#����������
22
������������� ��� 43
����������> .�
❒ > ��� ���J�#�����,K����+�������#���%�%���������9��#���
❒ ������#����+������+���������������- � � *���A��#I f - modi f i ed- si nce:
<dat e>
❒ #��9������#���#�������#�����,K����+�������������#���%�%����HTTP/ 1. 0 304 Not
Modi f i ed
���� #��9��
- � � *���A��#�� #�I f - modi f i ed- si nce:
<dat e>
- � � *���#���#�HTTP/ 1. 0
304 Not Modi f i ed
�,K������
� ���+���
- � � *���A��#�� #�I f - modi f i ed- si nce:
<dat e>
- � � *���#���#�HTTP/ 1. 0 200 OK
<dat a>
�,K���� ���+���
������������� ��� 44
�����������������������
❒ � )�*��������#��+���� ������������#
❒ � ��& �,����- � � *
❒ � ���� *
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
23
������������� ��� 45
�� *�����+������#+����������
❒ ��#+���+�����;+��� ���� �����#
❒ �����;#��9���� ����
❍ ������ #�����������#���#+���<�������;+��� ���� ��=
❍ #��9��� ��� �����#
❒ +���$ ���727
❒ +��#��9���������)
+������#+���� *
#��9��
�� *�#��
����+��
�� *�����
�����+���#�#��
��� ���+���#�#��
�#������#
������������� ��� 46
�� *��#������������������������#
❒ �� *�����������#��� *�#��9���������)��#����+������ �*�#���#�����������
❒ �������,��#������?�����9�������������������
❒ ������,��� #�#���� ������������,��#���������� � ��#��9�������������������
❒ & ����#��9��������9�#����� � ���+����+������#+�������#��9�������#��� �*��������������������
❒ �+�����#+�����������+�����#��9������#�#����������
�� *�����
�� *#��9��
� �*����������������������)
� �*�����������������'
❒ 0 ��9�������#��#������� �*�����������������#+���������+���
❒ ������������������H����+�,��I
❒ �� *�#��9���� ����#�H#�I�����������������������������������
24
������������� ��� 47
�� *���� � ��#����#���#�#
0 � ������� � ��#�❒ #���#��0 �����:��9���
�������������
❒ USER username
❒ PASS password
❒ LI ST ��������#��+�+����������������������
❒ RETR f i l ename �����9�#�<��#=�+���
❒ STOR f i l ename #���#�<��#=�+����������� �����#
0 � ��������������#❒ #�#������������#��<#�
���- � � *=❒ 331 User name OK,
passwor d r equi r ed
❒ 125 dat a connect i on al r eady open; t r ansf er st ar t i ng
❒ 425 Can’ t open dat a connect i on
❒ 452 Er r or wr i t i ng f i l e
������������� ��� 48
�����������������������
❒ � )�*��������#��+���� ������������#
❒ � ��& �,����- � � *
❒ � ���� *�
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
25
������������� ��� 49
.���������/ ��
� ������ K������ �����#�❒ �#������#�
❒ � ���#��9��#�
❒ #�� ����� �����#+������������0 / � *
6 #�������
❒ � �H� ��������I
❒ ��� ��#��������������������� ���� �##��#
❒ � � ��.������1 ���������� ��� �#����/ �##�����
❒ �������������� ����� �##��#�#��������#��9��
�#���� ��,�:
��������� �##���A����
� ��#��9��
�#�����
�#�����
�#�����
� ��#��9��
�#�����
�#�����
� ��#��9��
�#�����
0 / � *
0 / � *
0 / � *
������������� ��� 50
.���������/ ����� ���#��9��#
/ ���0 ��9��#❒ � ��,�: �����#������ ����
� �##��#�+����#��
❒ � �##�� A���� �+���������<��,��#��=�� ���� �##��#
❒ 0 / � *�������� ,�� ����� ���#��9��#���#������ ���� �##��#
❍ �������#�������� ���#��9��
❍ H#��9��I�������9����� ���#��9��
� ��#��9��
�#�����
�#�����
�#�����
� ��#��9��
�#�����
�#�����
� ��#��9��
�#�����
0 / � *
0 / � *
0 / � *
26
������������� ��� 51
.���������/ ����0 / � *�S$ ����5�)T
❒ �#�#�� �*�������,�����#+����� ���� �##���+��� ���������#��9���������2
❒ ��������#+����#�������#��9����������9����#��9��
❒ �������#�#��+���#+��
❍ ���#������<�������=
❍ ��#+����+�� �##��#
❍ ���#���
❒ ��� � ��;��#���#����������
❍ ��� � ��#� �0 �����:
❍ ��#���#�� #�#������������#�
❒ � �##��#�� �#�,�����4%,���0 ���
������������� ��� 52
0 ��������������#���#�� �##�����8 �,
)=��������#�#�6 ������� ��#��� �##������H�I�[email protected]
�=������J#�6 ��#���#�� �##���������� ���#��9��C�� �##������������� �##���A����
�=�������#�����+�0 / � *�����#�� �*������������ ���8 �,J#�� ���#��9��
(=�0 / � *�������#���#������J#�� �##����9������� �*����������
2=�8 �,J#�� ���#��9�������#����� �##������8 �,J#�� ��,�:
3=�8 �,���9���#���#��#�������������� �##��
�#�����
� ��#��9��
� ��#��9�� �#��
���
)
� � ( 23
27
������������� ��� 53
0 � ����0 / � *���������S: 220 hambur ger . eduC: HELO cr epes. f rS: 250 Hel l o cr epes. f r , pl eased t o meet you C: MAI L FROM: <al i ce@cr epes. f r > S: 250 al i ce@cr epes. f r . . . Sender ok C: RCPT TO: <bob@hambur ger . edu> S: 250 bob@hambur ger . edu . . . Reci pi ent ok C: DATA S: 354 Ent er mai l , end wi t h " . " on a l i ne by i t sel f C: Do you l i ke ket chup? C: How about pi ck l es? C: . S: 250 Message accept ed f or del i ver y C: QUI T S: 221 hambur ger . edu cl osi ng connect i on
������������� ��� 54
� ���0 / � *����������+�������#��+�
❒ t el net ser ver name 25
❒ #�����'�������+��� �#��9��
❒ �����- . 1 ��/ �� ��$ 1 / ��$ �*� �� 1 ��� �� ���D 6 �� �
��� � ��#
,�9����#�����#������ ���� ������#������ ���������<�����=
28
������������� ��� 55
0 / � *��+����� ���#
❒ 0 / � *��#�#����#�#������������#
❒ 0 / � *���A����#�� �##���<������B �,���=���,�����4 %,���0 ���
❒ 0 / � *�#��9����#�#�CRLF.CRLF ������� ���������+�� �##��
��� ���#���� ���- � � *�
❒ - � � *������
❒ 0 / � *����#�
❒ ,����9���0 ������� � ��;��#���#������������#�#�����#
❒ - � � *�������,K�������#���������#��� ����#���#��� #�
❒ 0 / � *��� ��������,K��#�#������� ������� #�
������������� ��� 56
/ ���� �##���+���
0 / � *����������+����:���������� ���� #�#
$ ���5����#�����+����:�� �##���+��� �
❒ ����������#��� � �❍ � ��
❍ ���� �
❍ 0 �,K���
��++���� +��� �0 / � *���� � ��#M
❒ ,���❍ ���H� �##��I���0 ����
������#�����
�����
,���
,�������
29
������������� ��� 57
/ �##���+��� ��� ���� �����:��#���#
❒ / �/ .��� ���� ����� ����:��#�����$ ����'(2���'23
❒ ������������#����� #� �������������/ �/ .����������
Fr om: al i ce@cr epes. f rTo: bob@hambur ger . eduSubj ect : Pi ct ur e of yummy cr epe. MI ME- Ver si on: 1. 0 Cont ent - Tr ansf er - Encodi ng: base64 Cont ent - Type: i mage/ j peg
base64 encoded dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . base64 encoded dat a
� ���� ����������#�,�����
��� ������������
� ������#������������
/ �/ .�9��#���
���������
������������� ��� 58
/ ������##��������#
❒ 0 / � *������9���;#������������9��J#�#��9��
❒ / ������##���������������9��+��� �#��9��
❍ *1 *��*�#�1 ++����*�������S$ ���)7�7T
@ �����?����<����R%%P#��9��=������� �����
❍ �/ �*���������/ �������##�*�������S$ ���)4�'T
@ � ����+����#�<� ������� ���:=
@ � ����������+�#������ #�# ���#��9��
❍ - � � *��- �� �����U ���M�/ ������
�#�����
#�����J#�� ���#��9��
�#�����
0 / � * 0 / � * ���##�������
�����9��J#�� ���#��9��
30
������������� ��� 59
*1 *���������
�����?������#�❒ ��������� � ��#��
❍ user : ��������#���� �
❍ pass: �##� ���
❒ #��9�����#���#�#
❍ +OK
❍ - ERR
��#�������#���������
❒ l i s t : ��#�� �##������ ,��#
❒ r et r : �����9��� �##���,����� ,��
❒ del e: �����
❒ qui t
C: l i s t S: 1 498 S: 2 912 S: . C: r et r 1 S: <message 1 cont ent s>S: . C: del e 1 C: r et r 2 S: <message 1 cont ent s>S: . C: del e 2 C: qui t S: +OK POP3 ser ver si gni ng of f
S: +OK POP3 ser ver r eady C: user bob S: +OK C: pass hungr y S: +OK user successf ul l y l ogged on
������������� ��� 60
*1 *��<� ���=�����/ �*
/ ����,���*1 *�
❒ *��9���#��:� �����#�#�H��� �������������I�� ���
❒ 8 �,��������%�����%� ����+���������#������
❒ H� �� ����%��%����I�������#��+�� �##��#������++����������#
❒ *1 *���#�#���##����##�#�##���#
�/ �*
❒ "�������� �##��#�����������������#��9��
❒ ����� #��#����������?��� �##��#����+�����#
❒ �/ �*�����#��#���#�����##�#�##���#�
❍ �� �#��+�+�����#����� �����#�,�� ����� �##����� #����+�������� �
31
������������� ��� 61
�����������������������
❒ � )�*��������#��+���� ������������#
❒ � ��& �,����- � � *
❒ � ���� *�
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
������������� ��� 62
� � 0 ��� �� ���� � ��0 �#��
*������ � ��������+���#�❍ 0 0 � ���� ����##����V
���������##�������#�❍ �*�����##�<���,�=�%
�#���+�������##�������� #
❍ H�� �I��� � ��� � ���� ��� % �#���,����� �#
D � � ��,�� �����*�����##�#������ ��E
� �� ���� � ��0 �#�� �❒ ��#��,�����,#�
�� ���� ������������������+�� ����� ��#��9��#
❒ ��������%��������������#�������#���� ��#��9��#������ � ����������#��9� �� �#�<����##;�� ����#����=
❍ �����������������+���������� ���� �����#���������%������������
❍ ��� ���:������� ���J#�H����I
32
������������� ��� 63
� � 0 �
& ������������?��� � 0 E
❒ #������������+�+�����
❒ �++���9���� �
❒ ��#��������?����,#�
❒ � �������
���#�J�#���M
� � 0 �#��9���#
❒ - �#�� �����*�����##���#����
❒ - �#���#���❍ �������������#�
�� �#
❒ / ���#��9�����#���
❒ �����#��,����❍ $ ��������& �,�
#��9��#��#���+��*�����##�#�+����������������� �
������������� ��� 64
Root DNS Servers
com DNS servers org DNS servers edu DNS servers
poly.eduDNS servers
umass.eduDNS servers
yahoo.comDNS servers
amazon.comDNS servers
pbs.orgDNS servers
� �#��,�����- ����������� ,#�
������� �#��*�+���� � � � ?�� ��� C�)# ����:�❒ ������A�����#������#��9�����+������� �� � 0 �
#��9��❒ ������A�����#���� �� � 0 �#��9��������� ?�� ���
� � 0 �#��9��❒ ������A�����#�� ?�� ��� � � 0 �#��9����������*�
����##�+���� � � � ?�� ���
33
������������� ��� 65
� � 0 ��$ ����� ��#��9��#
❒ �������,��������� ��#��9�������������#��9���� �
❒ ������ ��#��9���
❍ ����#�������9���� ��#��9����+��� ��� ������������� �
❍ ��#�� �����
❍ �����#�� ��������������� ��#��9��
)�������� ��#��9��#�� ����� ���
b USC-ISI Marina del Rey, CAl ICANN Los Angeles, CA
e NASA Mt View, CAf Internet Software C. Palo Alto, CA (and 17 other locations)
i Autonomica, Stockholm (plus 3 other locations)
k RIPE London (also Amsterdam, Frankfurt)
m WIDE Tokyo
a Verisign, Dulles, VAc Cogent, Herndon, VA (also Los Angeles)d U Maryland College Park, MDg US DoD Vienna, VAh ARL Aberdeen, MDj Verisign, ( 11 locations)
������������� ��� 66
� � �����������9��0 ��9��#
❒ � ��%��9������ ���<� � =�#��9��#� ��#���#�,���+������ ����������������������������%��9������������� ��#�����+������K� ❍ � �� ����#������#�� ����#�#��9��#�+������ �� �❍ .����#� +������ � �
❒ �������9��� � 0 �#��9��#� �����?���J#�� � 0 �#��9��#�����9������������9����#�� �����*�� �����#�+��������?���J#�#��9��#�<� � ��& �,����� ��= ❍ ���,��� �������,�������?�������#��9����
���9����
34
������������� ��� 67
����� � ��0 ��9��
❒ � ��#����#������,����������������
❒ .����0 *�<��#��������0 *����� ��������9��#��=��#���� ❍ ��#��������H��+����� ��#��9��I
❒ & �������#�� ��#��� � 0 �A������A������#�#������#������� � 0 �#��9��❍ ��#�#�����:���+��� ��#�A�����������������
������������� ��� 68
��A��#������#ci s. pol y. edu
gai a. cs. umass. edu
����� � 0 �#��9��
������ � 0 �#��9��dns. pol y. edu
1
23
4
5
6
������9��� � 0 �#��9��dns. cs. umass. edu
78
� � �� � 0 �#��9��
.:� ���
❒ - �#����# ���� ���� �#��*�����##�+����� �# �� ## ���
35
������������� ��� 69
��A��#������#ci s. pol y. edu
gai a. cs. umass. edu
����� � 0 �#��9��
������ � 0 �#��9��dns. pol y. edu
1
2
45
6
������9��� � 0 �#��9��dns. cs. umass. edu
7
8
� � �� � 0 �#��9��
3
$ ����#�9��A�����#
�����#�9��A�����❒ ��#�,�������+��� ��
��#������������������� ��#��9��
❒ ��9�����E
������A�����❒ �������#��9���
������#�� ����� ���+�#��9���������
❒ H�����J����� ���#��� ���,��#����#�#��9��I
������������� ��� 70
� � 0 �������������������������#
❒ �����<��=��� ��#��9�������#�� �������������#� �����
❍ ����������#��� ����<��#����=�+���#�� ���� �
❍ � � �#��9��#������������������������� ��#��9��#
@ � ��#������� ��#��9��#�����+���9�#���
❒ ����;���+��� �����#� #���������#����,���.� �❍ $ ����)�3❍ ���;;� � � ��+ ���;�� � �����#;��#���%����� �� �
36
������������� ��� 71
� � 0 �������#
� � 0 � ��#��,�����,�#��������#������������#�<$ $ =
❒ � ���N� 0❍ name �#���� ���<� � �
+�� ��� =
❍ val ue �#��*�����##��+�������9���� ��#��9���+�����#���� ��
$ $ �+��� ��( name, val ue, t ype, t t l )
❒ � ���N�❍ name �#���#�� �
❍ val ue �#��*�����##
❒ � ���N�� �/ .❍ name �#���#��� ��+���#�� ��
H��������I�<������=��� �
www.ibm.com �#������servereast.backup2.ibm.com
❍ val ue �#��������� �� �
❒ � ���N/ W❍ val ue �#��� ���+�� ��#��9��
##������� ���name
������������� ��� 72
� � 0 ����������� �##��#
� � 0 ���������� A���� �������� � �##��#��,���� ���#� ��� �##���+���
� #� �����❒ �����+������ )3�,��V �
+���A��������������A������#�#�#� ��V
❒ +��#�
❍ A�������������
❍ �����#������#�����
❍ �����#����9��,��
❍ �������#�������9�
37
������������� ��� 73
� � 0 ����������� �##��#
� � �������+����#+����A����
$ $ #���������#���A����
������#�+��������9��#��9��#
��������H����+��I��+����� ��,���#��
������������� ��� 74
��#������������#������ � 0
❒ .:� �����K�#�������#����H� �� ����6 ���I❒ $ ���#����� ����� �������� ��� ������#��
<� � ��� �� ����0 ������#=❍ � ���������9��������#���� ����� �#�����*�����##�#��+�
�����������9���� ��#��9���<���� ������#�������=❍ $ ���#�����#��#�� ��$ $ #����������� �� � �#��9���
(networkutopia.com, dns1.networkutopia.com, NS)(dns1.networkutopia.com, 212.212.212.1, A)
❒ *�����������9��#��9���� �������������+���� � � ��� �������� ��� ���� ����/ W ��������+������ ������� ���
❒ - �� ������������������*�����##��+������& �,�#��E
38
������������� ��� 75
�����������������������
❒ � )�*��������#��+���� ������������#�
❍ ������������#
❍ �����A����� ��#
❒ � ��& �,����- � � *
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
������������� ��� 76
*�*�+����#�����
.:� ���
❒ ���������#�*�*��������������������������,������� ����
❒ ����� ������������#���������C���#���� ��*�����##�+����������������
❒ �#�#�+���H- ���! ���I
❒ ������������#���#����������#����9��������+�- ���! ���
❒ ����������#�#������+��������#��8�,
❒ ������#��������+��� �8 �,J#�*���������J#����,�����- � � *
❒ & �������������� ����#��������#��#����������+��� ������
❒ �����J#�������#�,����& �,�������������#����& �,�#��9��
��������#����#��9��#�N��������#��,��M
39
������������� ��� 77
*�*��������?�����������
��������H� �#��I���#���
)=�� ���������������#������+��� #�������#��9���
❍ �*�����##
❍ �����
�=�������A�����#�+���H- ���! ���I
�=���������A��##�+����+��� �8 �,
������?�����������#��9��
����#
�����
8 �,
)
)
)
)�
�
������������� ��� 78
*�*�����,��� #�� ���������?�����������
❒ 0 ������������+�+�����
❒ *��+��� ����,�������
❒ �����������+������ ��
+������#+����#���������?����,����������������#�����������������?��
40
������������� ��� 79
D �����+���������> �����
❒ +�������#��,���❍ ���������#��9��
❒ ��,������� ����������❒ � ���> �����������#�
�� ���� �������������
�9�������� ���������❒ �����,�� ���������W �
���U ��+�����J#��� �*����������
❒ �����9������#��������#��#��9�������
❒ .�����#��������#��������
❒ > �9��������� ������������,������������ ���R�)'��9����������,��#
������������� ��� 80
> ��������������
Query
QueryHit
Query
Query
QueryHit
Query
Query
QueryHit
�������#+���
- � � *❒ D ������ �##��#����9����:�#����� �*���������#
❒ ����#�+��� ��D ������ �##��
❒ D ����- ��#����9�����9��#���
0 ��,�����
��� ����#����+�������
41
������������� ��� 81
> �������*����K������
) ! ������������W �� �#�+����#�� ���������������> ��������� ������#����#��+������������#
� W �#�A���������� �#���� ���� �*�� �������#������#����������������#����� ���U
� W �#���#�*����� �##�����U C�U �+��� ��#�*����� �##�� �
( ��������#������9����*����� �##�����#������ ���*����� �##��
2 W ������9�#�� ���*����� �##��# ����������#������������� �*����������#
*������9�����#������ �� �������,��� M
������������� ��� 82
.:���������������������"F �
❒ .���������#�����������������������##��������������������
❍ � �*�����������,�� �������������#������������
❍ � �*����������#�,�� ����#�� �����#��+������������#
❒ > ��������������#������������������#���������
ordinary peer
group-leader peer
neighoring relationshipsin overlay network
42
������������� ��� 83
"F ���D �������
❒ .���+�����#���#��������#������❒ ������#���#����� ����A��������#�������
�����❒ > �������������#����#�� ���� ���#��
❍ ��������� ����� �����#����*�����##
❒ �+�������������+��� ��#�A�����������������������#��������#������ ���� ���#
❒ ����������#����#�+���#�+������ �������❍ - � � *���A��##��#�����#��#������+����#�����
����#�����������#�����+���
������������� ��� 84
"? ����#
❒ �� ����#����#�� ������#������#
❒ $ �A��#�A������
❒ ������9����������#
❒ *��������� �������
43
������������� ��� 85
�����������������������
❒ � )�*��������#��+���� ������������#
❒ � ��& �,����- � � *
❒ � ���� *�
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
������������� ��� 86
0 ����������� � ���
0 ������*�❒ �������������8 0 � ( )�6 � �W ��
)75)
❒ �:����������������#��������#���,����#�
❒ �����;#��9��������� �
❒ � �����#��+���#����#��9����9��#������*���
❍ ������,������� �
❍ ����,����,���#��� %��������
���#%��������������%�������
1 0 %��������� ����+���<�H����I=������ ����
��������������##����,���#�������
�����9� � �##��#��;+��� ����������������
�����##
#����
> ��� �������� ���,����������;#��9����������������� � �������#����#����#
44
������������� ��� 87
0 ����%������ � �����#����� �*
0 ����� ������,�� ������������������##�������%���%��#������������<6 �*����� �*=
� �*�#��9���� ����,�����#+����+������ +��� ����������##��������
�����##
� �*�� ��,�++��#�9��,��#
#����
����������,�����������9������
����������,��������
#�#��
��#���#��9��
�����##
� �*�� ��,�++��#�9��,��#
#����
����������,�����������9������
����������,��������#�#��
��#���#��9��
������
������������� ��� 88
0 ����������� � ����� ���� �*
������� �#������#��9��
❒ #��9��������##�� �#�+��#�,���������
❒ #��9���� �#��9��������#�����<����=���� ����� �#������J#�����
����������#�#��9���,��
❒ ������������%������ �*�#����
❒ #����+������*�����##��������� ,����+�#��9��������##
❒ & ��������������#�#������������� �*��#,��#��#�������������#��9���� �*
❒ & �����������,���������#��9���� �*�����#���� �#���� +���#��9��������##������ � ������� ��������
❍ ���� #�#��9��������� ���� ������������#
❍ #������������� ,��#��#�������#�����#�������#�<� ������������=
� �*����9���#�����,������%�������#+����+�,��#�<H����I=�,�� �������������#��9��
���������9��� ����
45
������������� ��� 89
0 ��� �K����
❒ ��#��� �#��#�A�������+�������#���+��� ������������+�������##
❒ ��������#��� �#��������#�� �������#������+�����������##���������,�������#����
❒ ��������#��� �#���������������#������������ ���������#����
������������� ��� 90
0 ����������� � ����� ���� �*
.:� ���������%#��9������)=����������#������+��� �
#����������<i nFr omUser#��� =���#���#���#��9���9��#�����<out ToSer ver#��� =
�=�#��9������#������+��� �#����
�=�#��9������9��#��������������#���#���#�,����������
(=����������#������#��� ���+���������+��� �#�����<i nFr omSer ver #��� =
outT
oSer
ver
to network from network
inF
rom
Ser
ver
inF
rom
Use
r
keyboard monitor
Process
clientSocket
inputstream
inputstream
outputstream
TCPsocket
�����
�����##
������� �*�#����
46
������������� ��� 91
�����;#��9���#���������������� �*
wait for incomingconnection requestconnectionSocket =welcomeSocket.accept()
create socket,port=x , forincoming request:welcomeSocket =
ServerSocket()
create socket,connect to host i d, port=xclientSocket =
Socket()
closeconnectionSocket
read reply fromclientSocket
closeclientSocket
0 ��9���<�����������host i d= �����
send request usingclientSocketread request from
connectionSocket
write reply toconnectionSocket
� �*�����������#���
������������� ��� 92
.:� �����! 9�������<� �*=
import java.io.*; import java.net.*; class TCPClient {
public static void main(String argv[]) throws Exception {
String sentence; String modifiedSentence;
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
Socket clientSocket = new Socket("hostname", 6789);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
���������#���
�����������#������
���������#��9��
���������#���
�������#����
47
������������� ��� 93
.:� �����! 9�������<� �*=�����
BufferedReader inFromServer = new BufferedReader(newInputStreamReader(clientSocket.getInputStream()));
sentence = inFromUser.readLine();
outToServer.writeBytes(sentence + '\n');
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
clientSocket.close();
} }
���������#���
�������#����
0 ����������#��9��
$ �������+��� �#��9��
������������� ��� 94
.:� �����! 9�#��9���<� �*=import java.io.*; import java.net.*;
class TCPServer {
public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence;
ServerSocket welcomeSocket = new ServerSocket(6789);
while(true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(newInputStreamReader(connectionSocket.getInputStream()));
����� ����� ����#����
�����3457
& ������� ����� ���#�����+�������
,�������
���������#��� �������
��#����
48
������������� ��� 95
.:� �����! 9�#��9���<� �*=�����
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
clientSentence = inFromClient.readLine();
capitalizedSentence = clientSentence.toUpperCase() + '\n';
outToClient.writeBytes(capitalizedSentence); }
} }
$ �����������+��� �#����
���������#��� �������
��#����
& �������������#����
.����+�� ���������������,������� ��+�����������������������
������������� ��� 96
�����������������������
❒ � )�*��������#��+���� ������������#
❒ � ��& �,����- � � *
❒ � ���� *�
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
49
������������� ��� 97
0 ����������� � ����� ���6 � *
6 � *�����H���������I�,�� �������������#��9��
❒ ������#�����
❒ #�������:�����������#��*�����##���������+���#����������������
❒ #��9���� �#��:����*�����##�������+�#������+��� ������9�������
6 � *����#� ������� ��,�������9�������+�������������#
���������9��� ����
6 � *����9���#�������,�� ��#+���+������#��+�,��#�<H���� #I=
,�� �������������#��9��
������������� ��� 98
�����;#��9���#���������������6 � *
closeclientSocket
0 ��9���<�����������host i d=
read reply fromclientSocket
create socket,clientSocket = DatagramSocket()
�����
Create, address (host i d, por t =x,send datagram request using clientSocket
create socket,port=x , forincoming request:serverSocket = DatagramSocket()
read request fromserverSocket
write reply toserverSocketspecifying clienthost address,port number
50
������������� ��� 99
.:� �����! 9�������<6 � *=
send
Pac
ket
to network from network
rece
iveP
acke
t
inF
rom
Use
r
keyboard monitor
Process
clientSocket
UDPpacket
inputstream
UDPpacket
UDPsocket
1 �����#���#������<� �*�#���H,���#��� I=
�����������9�#������<� �*������9���H,���#��� I=
�����
�����##
������6 � *�#����
������������� ��� 100
.:� �����! 9�������<6 � *=
import java.io.*; import java.net.*;
class UDPClient { public static void main(String args[]) throws Exception {
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
DatagramSocket clientSocket = new DatagramSocket();
InetAddress IPAddress = InetAddress.getByName("hostname");
byte[] sendData = new byte[1024]; byte[] receiveData = new byte[1024];
String sentence = inFromUser.readLine();
sendData = sentence.getBytes();
���������#���
�����������#����
� ��#����#�� �����*�
����##��#����� � 0
51
������������� ��� 101
.:� �����! 9�������<6 � *=�����
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876);
clientSocket.send(sendPacket);
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
clientSocket.receive(receivePacket);
String modifiedSentence = new String(receivePacket.getData());
System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); }
}
��������� �� ����%�%#����
��������*���������
0 ����������#��9��
$ �������+��� �#��9��
������������� ��� 102
.:� �����! 9�#��9���<6 � *=
import java.io.*; import java.net.*;
class UDPServer { public static void main(String args[]) throws Exception
{
DatagramSocket serverSocket = new DatagramSocket(9876);
byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024];
while(true) {
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
serverSocket.receive(receivePacket);
�������� �#����
�����7543
�����#����+�������9�������
$ ����9�����
52
������������� ��� 103
.:� �����! 9�#��9���<6 � *=�����
String sentence = new String(receivePacket.getData());
InetAddress IPAddress = receivePacket.getAddress();
int port = receivePacket.getPort();
String capitalizedSentence = sentence.toUpperCase();
sendData = capitalizedSentence.getBytes();
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress,
port);
serverSocket.send(sendPacket); }
}
}
> ���*��������V ���+
#�����
& �������������#����
.����+�� ���������������,������� ��+������������
�����������#�����������
������������� ��� 104
�����������������������
❒ � )�*��������#��+���� ������������#�
❍ ������������#
❍ �����A����� ��#
❒ � ��& �,����- � � *
❒ � (�.���������/ ��❍ 0 / � *��*1 *����/ �*
❒ � 2�� � 0
❒ � 3�*�*�+����#�����
❒ � 4�0 ����������� � ����� ���� �*
❒ � 5�0 ����������� � ����� ���6 � *
❒ � 7�8 ���������& �,�#��9��
53
������������� ��� 105
8 ���������#�� ����& �,�#��9��
❒ �����#�����- � � *���A��#
❒ ����#������A��#
❒ ��#�#������
❒ �,��#���A��#���+����+��� �#��9��J#�+����#�#��
❒ ����#�- � � *���#���#��� �##���
❍ ����������#�O�+���
❒ #���#���#���#���������
❒ +����������#��9�������������A��#�+�����#�����,��� #���<�� �.��:������=
❒ #�����:�+�������#
������������� ��� 106
���������0 �� � ��
❒ �������������������#❍ �����%#��9��
❍ *�*
❍ ��,���
❒ ���������#��9������A����� ��#�
❍ ����,������,��� ���������
❒ ���������#����#��9����� ����
❍ ���������%�������������,����� �*
❍ ������,�������� #��6 � *
1 ���#�����+���� ������#���� ���� ����M
❒ #����+����������#�❍ - � � *
❍ �� *
❍ 0 / � *��*1 *���/ �*
❍ � � 0
❒ #����������� � ���
54
������������� ��� 107
���������0 �� � ��
❒ ��������A��#;������� �##����:������
❍ ��������A��##���+�����#��9���
❍ #��9�����#����#�� ������#�#�����
❒ � �##���+��� #�❍ �����#��+����#���9����
��+��,����
❍ �����+��,�������� � ������
/ �#��� ������� �������,����������#
❒ �������9# ���� #�#
❍ ��%,������%�+%,��
❒ ������?���9# ���������?���
❒ #���##�9# �#�+��
❒ ����,���9# �������,���� #���#+���
❒ H��� ���:������� ��������I