程序代写代做代考 database algorithm Transport Layer & TCP vs UDP Lecture 7

Transport Layer & TCP vs UDP Lecture 7
Dr John C. Murray Senior Lecturer

About me
• Bachelors in Electrical Engineering, CIIT Pakistan (2003)
• Master in Information Engineering, University of Liver pool, UK (2007)
• Dphil (PhD) in Biomedical Engineering, University of Oxford, UK (2014)
• Faraz Janan

Pre PhD
About me.. Cont
• Worked in teaching and industry in various capacities (2003 – 2010)
Post-PhD
• Worked as a Medical Imaging Scientist at Volpara Solutions Ltd. (Nov 2013-Dec 2015)
• Worked in ASSURE Project ( Jan 2014 – Jan 2016)
• Lecturer in Medical Imaging at the University of Lincoln
• Research Associate at the Department of Genetics, and a visiting researcher at the Department of Pharmacology, University of Cambridge.

About me.. Research
• Work on breast density assessment, x-ray images, Digital Breast Tomosynthisis (DBT) and lung Computed Tomography (CT)
• Image analysis, segmentation , shape and texture analysis and machine vision

Quantifying Change
in Mammographic
Regions
Shape – 1
2: 39 % > R- 2 in S2
Shape – 2
2: 39 % < R-2 in S1 3: 40 % > R-3 in S1
190 200 210 220 230 240 250 260 270 280
1: 36 % > R- 1 in S2
7: 5 % < R-8 in S2 260 270 280 3: 40 % < R-3 in S2 290 300 310 4: 1 % < R-4 in S2 320 1: 36 % < R-1 in S1 8: 5 % > R-7 in S1 7: 69 % < R-6 in S1 4: 1 % > R-4 in S1
6: 69 % > R- 7 in S2
5: 58 % > R- 5 in S2
170 180 190 200 210 220
330
340
5: 58 % < R-5 in S1  New Growth-6 160 170 180 190 200 210 220 230 240 F. Janan, Sir M. Brady FRS, Shape Localization, Quantification and Correspondence using Region Matching Algorithm (RMA), "Journal of Graphics and Computing" 2016 a1 b1 Shape 1 100 90 b1 80 70 60 50 40 30 20 10 0 180 160 140 120 a2 80 60 40 20 180 a2 Shape 2 a1 100 b2 60 40 20 b2 Shape S1 Shape S2 a 120 100 80 160 140 100 150 200 250 300 350 400 450 500 2.5 2 1.5 1 0.5 00 50 Integral invarinat with Ecc Integal invariant without Ecc b F. Janan, Sir Michael Brady FRS, Shape Description and Matching Using Integral Invariants on Eccentricity Transformed Images. International Journal of Computer Vision (IJCV) 113(2): 92-112 (2015) 4 100 460 200 300 400 500 600 700 800 500 550 600 650 220 440 420 400 380 360 340 410 r=1 r=1 r=8 r=15 r=22 r=29 r=36 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 100 200 300 400 500 3 600 700 800 405 400 395 390 385 380 375 370 365 r=8 r=15 r=22 r=29 r=36 240 260 280 300 320 340 360 380 400 420 20 40 60 80 100 120 140 160 180 200 F. Janan, M. Brady, and R. Highnam, “False Positive Reduction in CADe Using Diffusing Scale Space,” Breast Imaging. Springer, pp. 597–605, 2014. Twin Peak Software - Finding Masking Patent: Method for Ascertaining the Vertical Position of Tissue Structures, United Kingdom GB1505487.7 About me • Cytoskeleton of Stem Cells, cell morphology, cycle and polarity detection • Cell lineage tracking, editing and validation https://www.youtube.com/watch?v=abtqqtLT_a4 http://www.bbc.com/pashto/multimedia/2016/02/160202_dna_mo dification_dr_janan_iy OSI vs TCP Model OSI model TCP/IP model Application Application Presentation Session Transport Network Transport Internet Data Link Network Access Physical TCP/IP • TCP – Transmission control protocol • IP – Internet Protocol • TCP/IP is universal – runs on all computers that connect over the internet – TCP operates at the Transport layer of the OSI model – IP operates at the Network layer of the OSI model TCP/IP Application Presentation Session Transport Network Data Link Physical Application Transport Network Network Interface Messaging IP Addressing TCP • TCP/IP moves messages through virtually any network technology • TCP/IP closely mapped to ‘Data Link’ and ‘Physical’ layers. – Therefore allows comms with ‘any’ network technology TCP/IP • Internet Protocol • Main functions are: • Route data packets / datagrams • Datagram and data packet are different – Data Packet – contains acknowledgement header, has structure and order, has error checking – Datagram – does not contain an acknowledgement header, no arrival order, no error checking – TCP vs UDP TCP and UDP • TCP (transmission control protocol): when the TCP protocol is used there is a guaranteed delivery. This is due largely in part to a method called “flow control.” – Flow control ensures delivery of data. – Detects error in data transmission. – Retransmits data to ensure successful delivery. • UDP (User Datagram Protocol): commonly used protocol on the Internet. – Not used to send important data such as webpages, database information, etc. – Commonly used for streaming audio and video. – Offers speed! – No form of flow control or error correction. TCP/IP • Transport layer: – Segments and reassembles data into a data stream. It is also responsible for connection synchronisation, flow control and error recovery. • Network layer: – Determines the best route for the data to take from one place to another. Routers operate at this layer. TCP/IP • IP protocol – Internet datagram format and contents Version Header length Type of service Total length Identification O D M Fragment offset Time-to-live Protocol Header checksum Source IP address Destination IP address Options http://www.tcpipguide.com/free/t_IPDatagramGeneralFormat.htm further reading TCP/IP • The datagram can contain up to 65536 bytes (64kb) of data. – If the data to be transmitted is less than, or equal to, 64kb, then it is sent as one datagram. • If it is more than this then the sender splits the data into fragments and sends multiple datagrams. • When transmitted from the source each datagram is routed separately through the internet and the received fragments are finally reassembled at the destination. Sequencing and Reliability IP Protocol Suite • TCP and the provision of Transport Mechanisms – Connection Orientated – Reliability – Flow Control • UDP and the lack of provision of Transport Mechanisms – Connectionless – At the mercy of the network and its effectiveness to provide reliable communications – Assume the “application” builds a level of error detection and correction • Application Level Multiplexing – The use of Port Numbers to differentiate between individual applications utilising the Network Protocol Stack simultaneously TCP Reliability • DefineReliabilityandTCP – An application should be able to send data and expect it to arrive without error • Sometimes an error is absolute; there can be no recovery – Complete failure of network (links and routers) – Complete failure of transmitting device – Complete failure of application (they do sometimes crash) • An error in transmission needs to have a supportive repair mechanism that is “hidden” from the application – Bi-directional communication • Each node can receive or transmit • It is reasonable to assume “mirroring” of the mechanism at both ends of the network! TCP Sequencing • Sequencing – re-ordering data – Data may arrive out of sequence, and where this occurs the data needs to be “reorganised” into the correct sequence – Each transmitted datagram has a Sequence Number • It is not sequential however • It represents the relative offset of “this packet” in the total stream that is the TCP communication – On arrival the receiver re-sequences them according to their relative offset in a local buffer • We call this buffer the Receiving Window • There is a corresponding Transmitting Window that holds the data! TCP Sequencing • Resequence of Arriving Data in the Window Receiving Window Offset=0 Offset=20 Offset=40 Offset=60 Offset=80 Offset=0 Length=20 Offset=20 Length=20 Offset=40 Length=20 Offset=60 Length=20 Offset=80 Length=20 Transmitting Window Offset=0 Offset=20 Offset=40 Offset=60 Offset=80 TCP Sequencing • Data Arrival Confirmation – As data arrives at the receiver it confirms the receipt of that data to the transmitter • The next data transmitted to the sender contains a flag suggesting this confirmation, together with a note of the sequence number that is being confirmed – As data is confirmed at the sender end, that data can be removed from the senders Transmission Window • After confirmation we know that the data arrived and so we can forget at the transmitting end about this data (because there is no need to resend it) • After removal we have spare space, so more “new” application data can be inserted into the window for later transmission TCP Sequencing • Data Arrival Confirmation • The Transmission window effectively “slides” along the transmission buffer • We call it a “sliding window” and the “window” is effectively duplicated at each end ACKNOWLEDGE ACKNOWLEDGE Transmitting Window Transmission Buffer OOfffsfeste=t1=00 Length=20 Offfsseett==1220 Length=20 Offset=40 Length=20 Offset=60 Length=20 Offset=80 Length=20 TCP Sequencing • Sliding Window • Enables both ends to “share” a single view of exchanged data • Allows confirmation of a “slide” along the transmission buffer as data is acknowledged • Allows the receiver to “sort” received packets into the correct order – But what if something goes missing? TCP Sequencing • PositiveAcknowledgement – Because the receiver does not know in advance what is to be transmitted, we cannot use a negative acknowledgement mechanism • I was expecting something and it did not arrive so please send it again – We can use Positive Acknowledgements upon receipt of data to message when we have received data • The transmitter can “infer” when data has been lost, because an acknowledgement was not returned • And in response it can re-transmit the data (because it is still in the transmitters local “sliding window”!) TCP Sequencing • PositiveAcknowledgement – We use a Timer at both the receiver and transmitter • If we have “timed out” at the receiver end we send an acknowledgement of “this is what I currently have” • The transmitter can then resume transmitting from the point (the offset) immediately after that acknowledge – If the transmitter “times out” before any acknowledgement is received then this infers • The data never arrived in the first place (so no acknowledgement was sent) OR • That the acknowledgement was not received • In either case re-transmitting the data should provoke a (later) (re)transmission of the acknowledgement TCP Reliability TX packet 1 TX packet 2 SENDER NETWORK RECEIVER TX ACK 1 TX ACK 2 TX packet 3 TIME TX ACK 3 Packet Sequencing with a 1-1 acknowledgement TCP Reliability SENDER TX datagram 1 NETWORK RECEIVER TX ACK 1 Timeout period for acknowledgement TX datagram 1 (assume the first time it got lost in the network) TIME TX ACK 1 Lost ACK! TCP Reliability • How long do you wait for an acknowledgement ? – This can be pre-agreed when the link is established by defining a timeout, usually by the application initiating the TCP link • Yes ? But how long ? – And also.... How long does it take to receive an acknowledgement after a datagram has been transmitted under nominal ideal conditions • This cannot be determined – nor controlled! • It depends on how “busy” or “loaded” the receiver is • So is this simple model appropriate? – No – it would be inefficient especially if the network had a high latency • May have 10 Mbps throughput, but if it takes 2 seconds for data to arrive after it is sent and each datagram is only 1000 octets in size? TCP Reliability • 10,000,000 data octets to transmit in chunks of 1,000 octets infers 10,000 chunks • If each chunk takes 2 seconds to arrive, and the corresponding acknowledgement takes 2 seconds to be returned then; – Each chunk and acknowledgement will take 4 seconds – And there are 10,000 of them; approximately 40,000 seconds • That’sapprox11hours! – We can expect to wait a long time for the file to transfer across the network! TCP Sequencing • A second use for that Sliding Window? – Instead of transmitting an acknowledgement after EVERY received packet, wait until the sliding window is FULL and then send one acknowledgement • Or where data stops arriving, and we timeout, send an acknowledgement that points to the end of the current whole data we have received • That distinction is important, because of one “chunk” is missing because it was lost, we acknowledge to the last point of continuous data before the missing part, and not to the point ahead where we may have received data! P1+P2+P3+ P4+P5 represents the current window size in Octets that the transmitter can send TCP Reliability P1 P2 P3 P4 P5 Single Acknowledgement to say that I expect P6 next (i.e. I have received up to and including P5 Network The Acknowledge implies that the next transmission should be P6, and that the receivers window is now empty Acknowledgement & re-transmission TCP Reliability • Performance Improvements • Assuming that the receiver is using a large window, then performance of transmission rate will be significantly improved • The higher the latency of the network, the larger the window will need to be to maintain performance • With each acknowledgement sent by the receiver, the “window” field can be modified to indicate the current best window size at the receiver – This allows tuning at either end to account for changes in available resources and to take into account any changes in network latency • This allows for basic flow control between the receiver and the sender. As more resources become available for holding a larger window, the receiver acknowledges receipt of data and advertises a new window size • The reverse is of course also true; window sizes can be reduced! TCP Reliability • So how long will it take to transmit 10,000,000 data octets? • Transmit in chunks of 1,000 octets infers 10,000 chunks • Assume a large Sliding Window size of 10,000 Octets • This allows for 10 transmissions before we expect an acknowledgement – That means 1,000 separate transmissions and 1,000 acknowledgements – 4s (2rx + 2tx) x 1000 seconds compared with 40,000s – Approximately 1 Hour • If we allow a sliding window of 100,000 octets – Then we have only 100 sets of transmissions and acknowledgments – That equates to some 400 Seconds in time What about UDP • UDP is used when reliability isn’t an issue or factor • UDP is used when ordering isn’t important • UDP is very lightweight UDP Header Offset Octet 0 1 2 3 Octet Bit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 Source port Destination Port 4 32 Length Checksum UDP Transmission SENDER NETWORK RECEIVER TX packet 1 TX packet 2 TX packet 3 TIME Comparison TCP and UDP • TCP • Reliable – manages acknowledgment, retransmission and timeout. In TCP, there's either no missing data – in case of multiple timeouts, the connection is dropped. • Ordered – When data segments arrive in the wrong order, TCP buffers delay the out-of-order data until all data can be properly re-ordered and delivered to the application. • Heavyweight – TCP requires three packets to set up a socket connection, before any user data can be sent. – TCP handles reliability and congestion control. • UDP • Unreliable – When a message is sent, it cannot be known if it will reach its destination. – There is no concept of acknowledgment, retransmission, or timeout. • Not ordered – If two messages are sent to the same recipient, the order in which they arrive cannot be predicted. • Lightweight – There is no ordering of messages, no tracking connections, etc. • Datagrams – Packets are sent individually and are checked for integrity only if they arrive. • No congestion control – UDP itself does not avoid congestion – must implement congestion control measures at the application level. Port Numbers • List of UDP and TCP port numbers – http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers