Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Announcements 
● Lab 1: Due Monday 12.49pm 
Late (capped at 90%) due Wed at 8.59pm 
● BUG: make submit does not include RE...
Outline 
● Lab 1 theory 
● Lab 1 practice 
● GDB 
● Questions
Theory + Preview 
Network 
Sender Receiver
Theory + Preview 
Network 
pkt 
Sender Receiver
Theory + Preview 
Network 
pkt 
Sender Receiver 
What are all the terrible things that can happen to this 
data packet in ...
Things that can happen to a packet 
● Corrupted 
● Dropped 
● Delayed 
● Duplicated 
What are some primitives used to addr...
Things that can happen to a packet 
● Corrupted 
● Dropped 
● Delayed 
● Duplicated 
What are some primitives used to addr...
Original example 
Sender Receiver
Receiver's view 
● Data packet with sequence #1 arrives
Receiver's view 
● Data packet with sequence #1 arrives 
● Packet's checksum, etc. are correct
Receiver's view 
● Data packet with sequence #1 arrives 
● Packet's checksum, etc. are correct 
● Send ack for #1
Receiver's view 
● Data packet with sequence #1 arrives 
● Packet's checksum, etc. are correct 
● Send ack for #1 
● Data ...
Receiver's view 
● Data packet with sequence #1 arrives 
● Packet's checksum, etc. are correct 
● Send ack for #1 
● Data ...
Don't Send Ack 
SeqNo: #1 
X 
SeqNo: #1 
SSeeqqNNoo:: ##11 
Sender Receiver 
... 
If we do not re-send ack, can get into a...
● Edge cases matter 
● Think through all states system can be in
Outline 
● Lab 1 theory 
● Lab 1 practice 
● GDB 
● Questions
A Quote 
“A professor once told me that the secret to 
teaching is that students aren't going to learn 
what you tell them...
A Quote 
“A professor once told me that the secret to 
teaching is that students aren't going to learn 
what you tell them...
A Quote 
“A professor once told me that the secret to 
teaching is that students aren't going to learn 
what you tell them...
Goals of Labs 1 & 2 
● Understand edge cases for reliable transport 
and techniques for accomplishing it. 
● Get experienc...
Event-based structure 
● What are events that system needs to handle? 
● What parts of the given code map to these events?...
Events 
● Receive data packet 
● Receive ack packet 
● Input goes from empty to having data 
● Output goes from full to ha...
Event-based structure 
X 
● What are events that system needs to handle? 
● What parts of the given code map to these even...
Events 
● Create a new connection 
rel_create 
● Receive data packet 
● Receive ack packet 
rel_recvpkt 
● Input goes from...
Event-based structure 
X 
X 
● What are events that system needs to handle? 
● What parts of the given code map to these e...
Events 
● Create a new connection 
rel_create 
● Receive data packet 
● Receive ack packet 
rel_recvpkt 
● Input goes from...
Timer expires
Timer expires 
● Timer expiration maps to retransmits. 
● When do we retransmit? 
– Have an unacknowledged packet in fligh...
Timer expires 
for conn in openConnections: 
if ((conn.hasUnackedPkt) and 
(conn.timeSinceSentPkt > THRESHOLD)) 
{ 
resend...
Timer expires 
for conn in openConnections: 
if ((conn.hasUnackedPkt) and 
(conn.timeSinceSentPkt > THRESHOLD)) 
{ 
resend...
Receive data packet
Receive data packet 
● Sanity checks 
● Is it the right length? 
● Does its checksum match? 
● Has the other end already s...
Receive data packet 
● Sanity checks 
● Is it the right length? 
● Does its checksum match? 
● Has the other end already s...
Gotchas 
● htons, htonl, ntohs, ntohl 
● cksum 
● When to call conn_input
htons & ntohs 
● How do I write the number 512?
htons & ntohs 
● How do I write the number 512? 
Hint: 512 = 2^9.
htons & ntohs 
● How do I write the number 512? 
Hint: 512 = 2^9. 
Binary: 1000000000 
Hex: 200
htons & ntohs 
● How do I write the number 512? 
Hint: 512 = 2^9. 
Binary: 1000000000 
Hex: 200 
MSB LSB
htons & ntohs 
● How do I write the number 512? 
Hint: 512 = 2^9. 
Binary: 1000000000 
Hex: 200 
MSB LSB 
Should a machine...
htons & ntohs 
● How do I write the number 512? 
Hint: 512 = 2^9. 
Binary: 1000000000 
Hex: 200 
MSB LSB 
Big-endian 
Netw...
htons & ntohs 
● If your host is little-endian: 
ntohs( ) 
htons( ) 
● If your host is big-endian: 
ntohs( ) 
htons( )
htonl & ntohl 
● If your host is little-endian: 
ntohl( ) 
htonl( ) 
● If your host is big-endian: 
ntohl( ) 
htonl( )
Outline 
● Lab 1 theory 
● Lab 1 practice 
● GDB 
● Questions
Upcoming SlideShare
Loading in …5
×

Computer network (8)

327 views

Published on

a

Published in: Education
  • Be the first to comment

  • Be the first to like this

Computer network (8)

  1. 1. Announcements ● Lab 1: Due Monday 12.49pm Late (capped at 90%) due Wed at 8.59pm ● BUG: make submit does not include README file. See piazza for workaround. ● Writing assignment: Due Sunday at 5.59pm. (8 writing assignments total; choose 2.)
  2. 2. Outline ● Lab 1 theory ● Lab 1 practice ● GDB ● Questions
  3. 3. Theory + Preview Network Sender Receiver
  4. 4. Theory + Preview Network pkt Sender Receiver
  5. 5. Theory + Preview Network pkt Sender Receiver What are all the terrible things that can happen to this data packet in the network?
  6. 6. Things that can happen to a packet ● Corrupted ● Dropped ● Delayed ● Duplicated What are some primitives used to address these problems?
  7. 7. Things that can happen to a packet ● Corrupted ● Dropped ● Delayed ● Duplicated What are some primitives used to address these problems? -Acknowledgments/retransmissions -Sequence numbers -Checksums
  8. 8. Original example Sender Receiver
  9. 9. Receiver's view ● Data packet with sequence #1 arrives
  10. 10. Receiver's view ● Data packet with sequence #1 arrives ● Packet's checksum, etc. are correct
  11. 11. Receiver's view ● Data packet with sequence #1 arrives ● Packet's checksum, etc. are correct ● Send ack for #1
  12. 12. Receiver's view ● Data packet with sequence #1 arrives ● Packet's checksum, etc. are correct ● Send ack for #1 ● Data packet with sequence #1 arrives
  13. 13. Receiver's view ● Data packet with sequence #1 arrives ● Packet's checksum, etc. are correct ● Send ack for #1 ● Data packet with sequence #1 arrives Send ack or do nothing?
  14. 14. Don't Send Ack SeqNo: #1 X SeqNo: #1 SSeeqqNNoo:: ##11 Sender Receiver ... If we do not re-send ack, can get into a case where we have infinite retransmissions. (Bad) Therefore, we should re-send the ack.
  15. 15. ● Edge cases matter ● Think through all states system can be in
  16. 16. Outline ● Lab 1 theory ● Lab 1 practice ● GDB ● Questions
  17. 17. A Quote “A professor once told me that the secret to teaching is that students aren't going to learn what you tell them during lecture. What they're going to learn is what you make them build themselves.” -????
  18. 18. A Quote “A professor once told me that the secret to teaching is that students aren't going to learn what you tell them during lecture. What they're going to learn is what you make them build themselves.” -Phil Levis
  19. 19. A Quote “A professor once told me that the secret to teaching is that students aren't going to learn what you tell them during lecture. What they're going to learn is what you make them build themselves.” -Phil Levis ● Labs are a lot of work. ● You'll get something out of them. ● Start them early. ● Think about them while you're working on them.
  20. 20. Goals of Labs 1 & 2 ● Understand edge cases for reliable transport and techniques for accomplishing it. ● Get experience working with and using others' code.
  21. 21. Event-based structure ● What are events that system needs to handle? ● What parts of the given code map to these events? ● How should you respond to each? (Generally it will depend on the “state” that you are in.) ● How do you track what state you are in? How do you change states?
  22. 22. Events ● Receive data packet ● Receive ack packet ● Input goes from empty to having data ● Output goes from full to having room ● Timer expires ● Create a new connection ------ ● Receive shutdown from opposite end ● Receive shutdown from input
  23. 23. Event-based structure X ● What are events that system needs to handle? ● What parts of the given code map to these events? ● How should you respond to each? (Generally it will depend on the “state” that you are in.) ● How do you track what state you are in? How do you change states?
  24. 24. Events ● Create a new connection rel_create ● Receive data packet ● Receive ack packet rel_recvpkt ● Input goes from empty to having data rel_read ● Output goes from full to having room rel_output ● Timer expires rel_timer
  25. 25. Event-based structure X X ● What are events that system needs to handle? ● What parts of the given code map to these events? ● How should you respond to each? (Generally it will depend on the “state” that you are in.) ● How do you track what state you are in? How do you change states?
  26. 26. Events ● Create a new connection rel_create ● Receive data packet ● Receive ack packet rel_recvpkt ● Input goes from empty to having data rel_read ● Output goes from full to having room rel_output ● Timer expires rel_timer
  27. 27. Timer expires
  28. 28. Timer expires ● Timer expiration maps to retransmits. ● When do we retransmit? – Have an unacknowledged packet in flight and – We sent it more than cc­> timeout milliseconds ago. (Where cc is of type config_common* .)
  29. 29. Timer expires for conn in openConnections: if ((conn.hasUnackedPkt) and (conn.timeSinceSentPkt > THRESHOLD)) { resend(conn.unackedPkt); }
  30. 30. Timer expires for conn in openConnections: if ((conn.hasUnackedPkt) and (conn.timeSinceSentPkt > THRESHOLD)) { resend(conn.unackedPkt); } “Style” grade is 25% of lab score.
  31. 31. Receive data packet
  32. 32. Receive data packet ● Sanity checks ● Is it the right length? ● Does its checksum match? ● Has the other end already sent a stream close packet? ● Are you expecting the sequence number?
  33. 33. Receive data packet ● Sanity checks ● Is it the right length? ● Does its checksum match? ● Has the other end already sent a stream close packet? ● Are you expecting the sequence number? ----------- ● Should you send an ack? ● Should you output to client?
  34. 34. Gotchas ● htons, htonl, ntohs, ntohl ● cksum ● When to call conn_input
  35. 35. htons & ntohs ● How do I write the number 512?
  36. 36. htons & ntohs ● How do I write the number 512? Hint: 512 = 2^9.
  37. 37. htons & ntohs ● How do I write the number 512? Hint: 512 = 2^9. Binary: 1000000000 Hex: 200
  38. 38. htons & ntohs ● How do I write the number 512? Hint: 512 = 2^9. Binary: 1000000000 Hex: 200 MSB LSB
  39. 39. htons & ntohs ● How do I write the number 512? Hint: 512 = 2^9. Binary: 1000000000 Hex: 200 MSB LSB Should a machine store this as or ?
  40. 40. htons & ntohs ● How do I write the number 512? Hint: 512 = 2^9. Binary: 1000000000 Hex: 200 MSB LSB Big-endian Network byte order Little-endian Should a machine store this as or ?
  41. 41. htons & ntohs ● If your host is little-endian: ntohs( ) htons( ) ● If your host is big-endian: ntohs( ) htons( )
  42. 42. htonl & ntohl ● If your host is little-endian: ntohl( ) htonl( ) ● If your host is big-endian: ntohl( ) htonl( )
  43. 43. Outline ● Lab 1 theory ● Lab 1 practice ● GDB ● Questions

×