Advanced UNIX programming Fall 2002 Instructor: Ashok Srinivasan Lecture 27

advertisement
Advanced UNIX programming
Fall 2002
Instructor: Ashok Srinivasan
Lecture 27
Acknowledgements: The syllabus and power point presentations are modified versions of those by
T. Baker and X. Yuan
Announcements
• Reading assignment
– Chapter 20
• Sections 20.4 and 20.5
– Chapter 14
Week 10 Topics
• Advanced UDP sockets
– Reliable communication over UDP
• Time out
• Sequence numbers
• Unix domain protocols
– Address structure
– Client-server
– socketpair
Reliable communication over UDP
• Flow control
• Error control
Flow control
• Control the speed of the sender
– If the receiver does not have enough
buffer, stop sending
– How do we accomplish this?
• example1.c and example2.c are primitive UDP
sender and receiver
• How can we slow down the sender?
– Add delay (sleep)
» example1a.c and example2.c
– Perform handshaking
» example1b.c and example2a.c
Time out
• example1b.c and example2a.c resolve
the flow control problem
– What will happen if some packet gets lost?
• example1b.c and example2b.c
– Solution
• Add timeout to the sender
• If a packet gets lost, the sender should timeout
and resend the packet
• How can we implement a timeout?
– See example1c.c and example2b.c
Sequence numbers
• Problems with example1c.c and
example2b.c
– Some packets get duplicated
– How can we resolve this problem?
• The receiver must be able to recognize whether
it has received a packet
– It should discard the duplicate
• How can we accomplish this?
– Add an identifier to each packet sent – a sequence
number
– The receiver should record sequence numbers that
is has received
» example1d.c and example2c.c implement this
A reliable protocol
• Positive Acknowledgement with
Retransmission (PAR) protocol
– The protocol implemented in
example1d.c and example2c.c is PAR
– A reliable transmission protocol
– But not the most efficient
• The network and end hosts are idle
sometimes
• Sliding window protocols improve the
performance of PAR
Download