ICT role in 21st century education and it's challenges.
Computer network (8)
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. Outline
● Lab 1 theory
● Lab 1 practice
● GDB
● Questions
5. Theory + Preview
Network
pkt
Sender Receiver
What are all the terrible things that can happen to this
data packet in the network?
6. Things that can happen to a packet
● Corrupted
● Dropped
● Delayed
● Duplicated
What are some primitives used to address these
problems?
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
10. Receiver's view
● Data packet with sequence #1 arrives
● Packet's checksum, etc. are correct
11. Receiver's view
● Data packet with sequence #1 arrives
● Packet's checksum, etc. are correct
● Send ack for #1
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. 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. 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. ● Edge cases matter
● Think through all states system can be in
16. Outline
● Lab 1 theory
● Lab 1 practice
● GDB
● Questions
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. 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. 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. 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. 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. 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. 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. 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. 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. 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
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. Timer expires
for conn in openConnections:
if ((conn.hasUnackedPkt) and
(conn.timeSinceSentPkt > THRESHOLD))
{
resend(conn.unackedPkt);
}
30. Timer expires
for conn in openConnections:
if ((conn.hasUnackedPkt) and
(conn.timeSinceSentPkt > THRESHOLD))
{
resend(conn.unackedPkt);
}
“Style” grade is 25% of lab score.
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. 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. Gotchas
● htons, htonl, ntohs, ntohl
● cksum
● When to call conn_input
36. htons & ntohs
● How do I write the number 512?
Hint: 512 = 2^9.
37. htons & ntohs
● How do I write the number 512?
Hint: 512 = 2^9.
Binary: 1000000000
Hex: 200
38. htons & ntohs
● How do I write the number 512?
Hint: 512 = 2^9.
Binary: 1000000000
Hex: 200
MSB LSB
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. 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. htons & ntohs
● If your host is little-endian:
ntohs( )
htons( )
● If your host is big-endian:
ntohs( )
htons( )
42. htonl & ntohl
● If your host is little-endian:
ntohl( )
htonl( )
● If your host is big-endian:
ntohl( )
htonl( )
43. Outline
● Lab 1 theory
● Lab 1 practice
● GDB
● Questions