question
stringclasses
1 value
answer
stringlengths
585
1.52k
source
stringclasses
1 value
No question: Moodle
b non encrypted macsec header ( sectag ) fcs encrypted 4 b 16 b campus network with access control servers wifi base station with access control functions bridge lisa bart bart, an epfl student, connects his pc to epfl wifi, which uses per - user access control, authentication and encryption. bart configures his pc to be a bridge between ethernet and wifi and allows lisa, who is not allowed to access epfl, to connect to his ethernet port. will lisa be able to connect to the internet in this way? a. yes, provided that lisa can configure an ip address on the same subnet as bart b. yes, it will work in all cases c. no, it will not work in any case d. i don ’ t know go to web. speakup. info or download speakup app join room 46045 solution answer c lisa will not be able to connect to campus network in this way. access control accepts bart ’ s mac address ; mac frames at ( 1 ) are authenticated to verify that the source mac address is indeed bart ’ s mac address on wifi ( m1 ). wifi base stations accept only authenticated mac frames. lisa ’ s data will appear at ( 1 ) with source address = m3 m1 ). even if bart ’ s pc authenticates lisa ’ s mac frames, m3 is not the mac address that the base station has related to bart ’ s
EPFL COM 407 Moodle
No question: Moodle
authentication data / key. so, when trying to verify the authenticity of lisa ’ s frames, the base station will see this mismatch, and it will discard the frames. ( = campus network with access control servers wifi base station with access control functions bridge lisa bart m1 m2 m3 1 bart, an epfl student, connects his pc to epfl wifi, which uses per - user access control, authentication and encryption. bart configures his pc to be a nat between ethernet and wifi and allows lisa, who is not allowed to access epfl, to connect to his ethernet port. will lisa be able to connect to the internet in this way? a. yes, unless bart himself is behind a nat b. yes c. no, it will not work in any case d. i don ’ t know campus network with access control servers wifi base station with access control functions nat lisa bart go to web. speakup. info or download speakup app join room 46045 solution answer b, it will work. there are 2 layer - 2 domains separated by the nat, which is layer - 3 device. the wifi frames seen by the wifi base station belong to the wifi domain i. e. they are seen as originated by bart, and thus they are accepted as legitimate. lisa can access the campus network without being a legitimate user! answer a is incorrect : it will still work if bart is behind a nat. in this case, it
EPFL COM 407 Moodle
No question: Moodle
is the nat that must connect to the epfl wifi network. since we assume that bart could connect to epfl, it means that the nat box succeeded to connect to epfl. in this case, bart can connect and lisa also. the epfl network sees bart's nat and thinks that bart and lisa are programs on bart's nat. an example where this occurs is when bart connects its laptop to epfl, so that it is authenticated, and then he uses a guest os in virtual box ( that has its own nat ). campus network with access control servers wifi base station with access control functions nat lisa bart conclusion 1 • the mac layer for wireless medium ( wifi ) takes care of sharing the radio waves in a local environment. • the mac layer for wired medium ( ethernet ) was originally designed for sharing a cable ; so it used a protocol, called csma / cd very similar to wifi. • now, the mac layer for wired medium ( ethernet ) does not need any such protocol, because it uses full - duplex cables and interconnected switches., it forms an interconnection layer of local scope. conclusion 2 we saw 2 mechanisms to interconnect devices : - the network layer ( with ip routers ), and - the mac layer ( with switches ). what are the differences? • switches use forwarding tables that are not structured. • for every received frame, a switch must search the entire table, because
EPFL COM 407 Moodle
No question: Moodle
of the exact match. • the table size and lookup time are prohibitive, if network becomes very large. • so, we prefer routers for large networks. • switches are plug - and - play devices, independent from ip numbering plans and whether ipv4 or ipv6 is used ( as opposed to routers ). • historically, routers were in software and switches in hardware ; nowadays, every combination exists. how do you find the content of the lectures so far? a. not interesting at all ( i know all this stuff from my undergrad ) b. somewhat interesting ( there are few things i missed from my undergrad and i am happy to learn them now ) c. interesting ( i thought i knew much about networks, but i now realize that there are a lot more things to learn ) d. other how do you find the way of lecturing so far? a. very slow pace, i am bored. b. rather slow, many times i feel that time is spent on useless stuff. i want a faster pace. c. engaging, it helps me catch up with all concepts. d. very fast pace, i do not understand critical ideas. e. other how do you find the content of the labs so far? a. not interesting at all. ( i know all this stuff from my undergrad ) b. somewhat interesting. ( there are few things i missed from my undergrad and i am happy to have a hands - on experience
EPFL COM 407 Moodle
No question: Moodle
about them now ) c. interesting. ( i had limited hands - on experience with networks and i am happy to dive into these details ) d. other how do you find the labs so far? a. completely useless, i am losing my time b. somewhat useful, they help me catch up with things i already knew c. useful, they help me understand in detail what is taught in the lectures and all new things i learn d. other transport network ( ip ) mac ( ethernet ) physical application send ( s2, datablock ) 1 2 3 1 2 3 1 2 3 network ( ip ) mac physical 1 2 3 1 2 3 transport application read ( s1, datablock ) 1 2 3 network ( ip ) mac ( wifi ) physical 1 2 3 1 2 3 router 1 2 3 mac ( ethernet ) physical 1 2 3 switch web server eliane ( client ) mac ( wifi ) midterm recap : basic network operation how do hosts exchange tcp segments or udp datagrams using sockets how we configure hosts and how we send / receive / forward ip packets how we manage medium access and how we send / receive / forward frames in the lan next : how to address practical issues … same layers, but more complicated / interesting concepts : • how to do “ live tv broadcasting ” by also reducing the stress at the source use a special case of ip forwarding — > multicast • how do ip routers populate their
EPFL COM 407 Moodle
No question: Moodle
forwarding tables? - do they all use the same routing protocol / policies, even if they belong to different operators? igp, bgp • can we avoid congestion? - can tcp sources use all the available capacity, without suffering significant losses? - also, can we ensure that all sources take a “ fair share ” of the available capacity? ip multicast la duree d'ecoute est desormais limitee : sans action de votre part ( un simple clic ), la diffusion s'arrete au bout d'un temps determine selon les stations. en effet, pour nous, diffuseurs, les technologies actuelles imposent un cout dependant de la duree et du nombre d'auditeurs. plusieurs elements nous indiquent que les internautes ayant acces a l'internet illimite ne coupent pas l'ecoute, lorsqu'ils quittent leur ordinateur allume. radio france ne peut continuer a financer pour celui qui n'ecoute pas. c'est pourquoi nous avons mis en place ce systeme de confirmation, un peu contraignant, mais qui nous permet de mieux controler les couts de diffusion. http : / / viphttp. yacast. net / v4 / radiofrance / fip _ b
EPFL COM 407 Moodle
No question: Moodle
##d. m3u ip multicast • recall : - unicast = source sends data to a unicast ip address, and a single destination receives it - multicast = source sends data to a multicast ip address, but multiple destinations receive it • multicast delivers packets to multiple recipients without sending multiple copies from the source • traffic is replicated at the network layer • used only : - within a single domain ( = big network under a single administrative entity, composed of multiple subnets ) - with udp ( cannot be done with tcp! ) source destinations destinations destinations intermediate router applying pkt replication source ’ s router edge routers typical process • destinations subscribe to a multicast group by sending join messages to their routers - igmp ( internet group management protocol, in ipv4 ) or - mld ( multicast listener discovery, in ipv6 ) • routers either build distribution tree via a reverse path forwarding ( pim ) or use a source - routing approach ( bier ) [ see next slides ] • source simply sends udp packets to multicast address • intermediate ip routers between source and destinations replicate traffic source destinations destinations destinations intermediate router applying pkt replication source ’ s router edge routers 2 multicast addresses and groups • reserved ip address spaces : - ipv4 : 224. 0. 0. 0 / 4 ( i. e. 224. 0. 0. 0 to 239. 255. 255.
EPFL COM 407 Moodle
No question: Moodle
255 ) - ipv6 : ff00 : : / 8, bits 13 - 16 determine the “ scope ” : ff02 / 16 = same subnet, ff05 / 16 = same domain • any source multicast ( asm ) group : - the group is identified by the multicast address ; - any source can send to this group • source specific multicast ( ssm ) group : - the group is identified by ( s, m ) where m is a multicast address and s is a ( unicast ) source ip address ; - οnly s can send to this group - default ssm addresses : 232. 0. 0. 0 / 8 and ff3x : : / 96 ( x = scope bits ; e. g. ff35 : : / 96 = site - local ) [ rfc7371 for more details ] host 1 194. 199. 25. 100 source ( s ) host 3 destination 133. 121. 11. 22 host 2 destination 194. 199. 25. 101 multicast group ( m ) 225. 1. 2. 3 to m figure explanation : 1. if s sends packets to multicast address m and there are no subscribed destinations yet, the data is dropped at router r5. so, we use the following steps : 2. a joins the ssm group ( s, m ). 3. r1 informs the rest of the network that ( s, m ) has a member
EPFL COM 407 Moodle
No question: Moodle
at r1 by using e. g. the multicast routing protocol pim - sm ; this results in a tree being built. data sent by s now reach a. 4. b joins the multicast address m. 5. r4 informs the rest of the network that m has a member at r4 ; the multicast routing protocol adds branches to the tree. data sent by s now reach both a and b. r5 r1 r2 r4 a b s ( e. g. a video streaming server ) to m 1 igmp : join ( s, m ) 2 4 multicast routing ( pim ) 3 3 m - > p m - > p m - > p to m 5 m - > pd pim : protocol independent multicast ( typical example ) pim : protocol independent multicast supports asm and ssm exists in 2 versions • pim - dm ( dense mode ) makes heavy use of broadcast and can be used only in small, tightly controlled networks • pim - sm ( sparse mode ) is more reasonable and is used e. g. for tv distribution - when used with ssm, pim - sm uses reverse path forwarding ( rpf ) : when a router ( such as r1 ) needs to add a receiver, it sends a pim / join router message towards the source, using unicast routing - this creates the distribution tree on the fly - [ pim - sm for asm
EPFL COM 407 Moodle
No question: Moodle
is more complicated ; it uses one multicast router as rendez - vous point ( rp ) : destination routers create a tree from rp, using rpf ; router closest to source sends source packets to rp ; if there exists an interested receiver in the domain, rp creates a tree from source ( using rpf ) otherwise drops ; destinations create trees from sources, using rpf. ] pim - enabled routers must keep per - flow state information multicast state information is dynamically kept in router for every known multicast group : ( s, m ) or ( *, m ) / / id of group valid incoming interfaces / / for security outgoing interfaces / / this is the routing info other information required by multicast routing protocol this per - flow state information cannot be aggregated based on prefix : scalability issues in addition to longest prefix match, a multicast ip router does exact match for multicast groups bier ( bit index explicit replication ) why? multicast routing requires routers to keep per - flow state ( dynamic, depends on who listens to the group ) and apply exact match causes a stress to backbone routers ; so, we need an alternative that scales better how? bier uses a centralized entity and an extension header : • a multicast packet has a bier header that contains ( roughly speaking ) the list of destination bier routers ( bit - forwarding egress routers, bfers )
EPFL COM 407 Moodle
No question: Moodle
• bier routers rely on unicast routing in order to determine how to deliver a packet to the set of bfers indicated in the bier header - if several bfers are reached via different next - hops, bier routers replicate packet - then send only a single copy to each next hop for all bfers that are reached through this next hop - in this copy, the bier header is modified accordingly r7 r1 id = 1 other bit forwarding router bit forwarding egress router bier : example r1 id = 1 a igmp : join ( s, m ) r2 id = 2 r3 id = 3 r4 id = 4 r7 ip dest = m 1 r6 r8 b igmp : join ( s, m ) c igmp : join ( s, m ) multicast flow overlay — centralized ( e. g. video distribution control servers or multicast vpn or sdn controller ) join ( s, m ) who has ( s, m ) members? ( 1, 3, 4 ) 3a ip dest = m to { 1 } ip dest = m to { 3, 4 } 3b ip dest = m to { 3, 4 } 4b 4a ip dest = m to { 1 } ip dest = m to { 3 } 6 ip dest = m 7 5a ip dest = m ip dest = m 5b
EPFL COM 407 Moodle
No question: Moodle
r5 id = 5 ip dest = m to { 1, 3, 4 } 2 s ip header bier header ip dest = m to { bfers } group membership information is distributed by an external infrastructure called “ multicast flow overlay ”, for example : a special set of servers used to control the distribution of the video content, or a system to manage multicast virtual private networks using mpls and bgp ( see later in mpls lecture ) or a central network controller ( sdn ). all routers on the figure are bier routers ( bit forwarding routers, bfrs ). routers r1 - r5 are egress routers ( they need to forward multicast packets to the outside ) ; such routers have a bfr - id, for example r1 ’ s bier - id is 1. router r5 learns from the multicast flow overlay that the group ( s, m ) has members in routers with bfr - ids 1, 3 and 4. 1. router r5 has an ip multicast packet to send to m, from s. r5 knows that it should send the packet to r1, r3 and r4. from unicast routing ( classic ip forwarding table ), r5 finds that r1, r3 and r4 are reached via the same next - hop ( r7 ) therefore r5 sends one packet with bier header (
EPFL COM 407 Moodle
No question: Moodle
1, 3, 4 ) to r7. 2. from unicast routing, r7 finds that r3 and r4 are reached via the same next - hop ( r8 ) but r1 requires a different next - hop. therefore, r7 duplicates the packet and creates 2 packets, one with bier header ( 1 ), sent to r6, and one with bier header ( 3, 4 ), sent to r8. 3a. r6 forwards the packet to r1. 4a, 5a. r1 belongs to the destination list contained in the bier header, therefore r1 knows it should forward the packet using classic multicast. the bier header is removed and the packet is forwarded to the west lan interface where a can receive it. 3b. from its forwarding table, r8 finds that r3 and r4 are reached via the same next - hop ( r4 ). therefore, r8 sends the packet to r4. 4b, 5b. r4 belongs to the destination list contained in the bier header, therefore r4 knows it should forward the packet using native multicast. the bier header becomes ( 3 ). 5b. the bier header is removed and the packet is forwarded to r4 ’ s west lan interface where c can receive it. 6b. r4 sends one copy of the packet to r3. 7b. the bier header is removed and the
EPFL COM 407 Moodle
No question: Moodle
packet is forwarded to r3 ’ s west lan interface where b can receive it. bier : packet replication • for each destination bfer, bier router pre - computes ( based on the ip forwarding table ) a “ forwarding bit mask ” that indicates the set of destination bfers that are reached by the same next - hop. • to forward a packet, with destination set, bier router runs : 1. send a copy to 1st destination in with destination set =, where is the forwarding bit mask of 1st destination. 2. if, duplicate the packet but with destination and goto 1 ; else break. s s s ∩s1 s1 = ∅ dest. bfer forwarding bit mask next - hop 1 { 1, 2 } r6 2 { 1, 2 } r6 3 { 3, 4 } r8 4 { 3, 4 } r8 5 { 5 } r5 example at router r7 : r7 receives packet with destination set { 1, 3, 4 } : 1. first destination in is 1, r7 uses bier index forwarding table and finds that the forwarding bit mask for destination 1 is : sends a copy of packet to next - hop ( r6 ), with destination set 2. is not empty ; r7 duplicates packet with destination and applies the same : first destination is 3, so r7 sends a copy to next - hop ( r8 ) with
EPFL COM 407 Moodle
No question: Moodle
destination set. 3. now, so it breaks. s = s s1 = { 1, 2 } s ′ = s ∩s1 = { 1 } s ′ ′ = { 1, 2 } = { 3, 4 } s ′ ′ { 3, 4 } { 3, 4 } { 3, 4 } = ∅ r1 id = 1 r2 id = 2 r3 id = 3 r4 id = 4 r7 1 r6 r8 3a ip dest = m to { 1 } ip dest = m to { 3, 4 } ip dest = m to { 1, 3, 4 } 3b ip dest = m to { 3, 4 } 4b 4a ip dest = m to { 1 } ip dest = m to { 3 } 6b r5 id = 5 2 dest. ip addr next - hop r1 r6 r2 r6 r3 r8 r4 r8 r5 r5 bier index forwarding table at r7 ip forwarding table at r7 • for each destination bfer, bier router encodes the forwarding bit mask in a bitstring - example for 5 possible bfers : destination bfers = { 1, 3, 4 } — > bitstring = 01101 destination bfers = { 3, 4 } — > bitstring = 01100 destination bfers = { 1 } — > bits
EPFL COM 407 Moodle
No question: Moodle
##tring = 00001 • set intersection becomes a bitwise and with mask • set difference becomes a bitwise and with the bit - inverted mask • more complicated mechanisms exist, if the # of bfers is large [ rfc 8279 ] bier index forwarding table at r7 dest. bfer forwarding bit mask next - hop 1 0 0011 r6 2 0 0011 r6 3 0 1100 r8 4 0 1100 r8 5 1 0000 r5 example of bier forwarding at router r7 : r7 receives packet with ( bitstring ) bier header = 01101 1. least significant destination is 1. r7 looks into bier index forwarding table and finds the corresponding mask ; then applies an and of the bier header with the mask 00011 and sends a copy of packet to next - hop ( r6 ) with header bitstring = 00001 ; r7 computes the remaining bitstring ( by and - ing the bier header with inverse of mask ) as 01100. 2. the outcome is non - zero ; so r7 processes the remaining bistring = 01100 by applying the same : least significant destination is 3 ; so r7 sends a copy to next - hop ( r8 ) with header 01100. 3. now, the remaining bitstring is all - zeros ( 00000 ) ; so it breaks. how to optimize processing at bier routers
EPFL COM 407 Moodle
No question: Moodle
? r1 id = 1 r2 id = 2 r3 id = 3 r4 id = 4 r7 1 r6 r8 3a ip dest = m to { 1 } ip dest = m to { 3, 4 } ip dest = m to { 1, 3, 4 } 3b ip dest = m to { 3, 4 } 4b 4a ip dest = m to { 1 } ip dest = m to { 3 } 6b r5 id = 5 2 bier table contains static info, no per - flow state r1 id = 1 r2 id = 2 r3 id = 3 r4 id = 4 r7 1 r6 r8 3a ip dest = m to { 1 } ip dest = m to { 3, 4 } ip dest = m to { 1, 3, 4 } 3b ip dest = m to { 3, 4 } 4b 4a ip dest = m to { 1 } ip dest = m to { 3 } 6b r5 id = 5 2 bier routers — recap • in addition to ip unicast forwarding table ( longest prefix match ), a bier router does bitstring processing using a bit forwarding table • a bit forwarding ingress router ( bfir, such as r5 ) must map destination multicast address to a bier header - requires out of band mechanism - this is the only (
EPFL COM 407 Moodle
No question: Moodle
dynamic ) per - flow information cached by bier • bier forwarding table, called bit index forwarding table, is automatically derived from router ’ s unicast ip forwarding table. • inside a bier domain, multicast packets have an additional header and the ip destination address is not used ( tunneling ). multiple bier domains can be interconnected by bfir - bfer interconnection. bier index forwarding table at r7 dest. bfer forwarding bit mask next - hop 1 0 0011 r6 2 0 0011 r6 3 0 1100 r8 4 0 1100 r8 5 1 0000 r5 bier table contains static info, no per - flow state is there multicast arp ( address resolution protocol )? • no, multicast mac address is algorithmically derived from multicast ip address : - last 23 bits of ipv4 multicast address are used in mac address - last 32 bits of ipv6 multicast address are used in mac address • note : - multicast mac address depends only on multicast ip address m, not on source address s, even if m is an ssm address - several multicast ip addresses may yield the same mac address - packets received unnecessarily at the mac layer are removed by the os ; hopefully this happens rarely mac multicast addr. used for 01 - 00 - 5e - yx - xx - xx ipv4 multicast
EPFL COM 407 Moodle
No question: Moodle
33 - 33 - xx - xx - xx - xx ipv6 multicast ip dest address 229. 130. 54. 207 ip dest address ( hexa ) e5 - 82 - 36 - cf ip dest address ( bin ) … - 10000010 - … keep last 23 bits ( bin ) … - 00000010 - … keep last 23 bits ( hexa ) 02 - 36 - cf mac address 01 - 00 - 5e - 02 - 36 - cf 1st bit of hextet is 0 mac multicast : how do switches handle multicast frames? some ( non smart ) switches simply treat multicast frames as broadcast. some smarter switches : • listen to igmp / mld subscription messages and overhear who listens • deliver only to intended recipients ( igmp or mld snooping ) • but do not distinguish ssm from asm. b listens to 229. 130. 54. 207 non - smart switch c listens to 229. 130. 54. 207 d does not listen to 229. 130. 54. 207 mac dest addr = 01 : 00 : 5e : 02 : 36 : cf b listens to 229. 130. 54. 207 smart switch c listens to 229. 130. 54. 207 d does not listen to 229. 130. 54. 207 mac dest addr = 01 : 00 : 5e : 02 : 36 : cf security of ip multicast ip multicast w
EPFL COM 407 Moodle
No question: Moodle
/ or w / o bier makes attacks easier ( e. g. denial of service, witty worm ) mitigations : limit multicast rate and number of groups ; control which multicast group is allowed ( access lists ) ssm is safer as routers and destination can reject unwanted sources igmp / mld is not secure and has the same problems as arp / ndp mitigated by same mechanisms : sniffing switches observe all traffic and implement access control multicast - capable networks must deploy exhaustive filtering and monitoring tools to limit potential damage. multicast in practice • multicast is good for sources : one packet sent for n destinations - - replication is done o ( log ( n ) ) times • multicast is not supported everywhere, but is used in : - internet tv distribution ( pim - sm / bier ) - epfl and other academic networks ( pim - sm ) - data center virtualization services ( bier ) - some corporate networks for news, sensor streaming, time synchronization, large videoconferences etc … - industrial networks ( smart grids, factory automation ) • works only with udp, not with tcp ( not easy to handle tcp acks from multiple receivers? ) - need to handle errors, usually via redundancy ( extra traffic ) say what is true a. a b. b c. c d. a and b e. a and c f. b and c g. all h. none
EPFL COM 407 Moodle
No question: Moodle
i. i don ’ t know a. in order to send to a multicast group a system must first join the group with igmp or mld b. in order to receive from a multicast group a system must first join the group with igmp or mld c. a system can know whether a packet is multicast by analyzing the ip destination address. go to web. speakup. info or download speakup app join room 46045 solution f r is a backbone router used for multicast distribution. in which case must r keep per - flow information? a. if r uses pim - sm as multicast routing protocol b. if r uses bier as multicast routing protocol c. in both cases d. in neither case e. i don ’ t know go to web. speakup. info or download speakup app join room 46045 r is an ingress edge router used for multicast distribution. in which case must r cache per - flow information? a. if r uses pim - sm as multicast routing protocol b. if r uses bier as multicast routing protocol c. in both cases d. in neither case e. i don ’ t know go to web. speakup. info or download speakup app join room 46045 solution answer to first question : a answer to second question : c ( a and b ) with pim - sm, all routers keep per - flow information. with bier,
EPFL COM 407 Moodle
No question: Moodle
only ingress routers ( such as r5 on the figure ) need to cache per - flow information. the destination mac address is … a. a group address derived from the last 23 bits of the ipv6 target address b. a group address derived from the last 24 bits of the ipv6 target address c. a group address derived from the last 32 bits of the ipv6 target address d. a broadcast address e. the mac address of an arp server f. i don ’ t know solution answer c for multicast, the destination mac address is automatically derived from the ip destination mac address, by taking the last 32 bits ( ipv6 ) or the last 23 bits ( ipv4 ). the ipv6 destination address is ff02 : : 1 : ff01 : 1 the last 32 bits correspond to the last 8 hexadecimal symbols, i. e. ff01 : 1 ; in uncompressed form, the 8 hexadecimal symbols are ff01 : 0001. the mac destination address is therefore 33 : 33 : ff : 01 : 00 : 01 summary • ip multicast came as an after - thought and uses a different principle than ip unicast ( exact match versus longest prefix match ) — deployed only in specific network domains • ip multicast addresses cannot be aggregated • traditional multicast ( pim ) requires per - flow state in routers — > does not scale well • bier avoids this
EPFL COM 407 Moodle
No question: Moodle
problem • bier uses a different forwarding principle, based on bistrings ( which represent sets of destinations ). the transport layer : tcp and udp machine b application transport network data link physical machine a application network data link physical transport series of links, switches routers, lans, … contents 1. udp 2. tcp basics : sliding window and flow control 3. tcp connections and sockets 4. more tcp bells and whistles 5. secure transport 6. where should packet losses be repaired? textbook part 4 chapters 3 and 8. 6 reminder from 1st lecture : transport layer services • network + data link + physical layers carry packets end - to - end • packets may be lost because of : - errors at the physical layer - buffer overflow events at routers or switches • or reordered because they may follow different paths to destination • transport layer - makes network services available to programs - is in end - systems only, not in routers ’ data plane ( i. e. not at forwarding level ) - may handle packet loss / reordering or not : • udp ( user datagram protocol ) : not reliable transfer, takes no action • tcp ( transmission control protocol ) : reliable, in - order transfer by using sophisticated mechanisms what is the definition of a « server » in networks? a. a machine that hosts resources used in the web b. a computer with high cpu performance c. a computer with large data storage d
EPFL COM 407 Moodle
No question: Moodle
. the role of a program that waits for requests to come e. the role of a program that allows users to access large amounts of resources f. none of the above g. i don ’ t know go to web. speakup. info or download speakup app join room 46045 solution answer d formally, a server is a role at the transport layer, where the program waits for requests to come. in contrast, a client initiates communication to a server. reminder from 1st lecture : port numbers host ip addr = b host ip addr = a ip sa = a da = b prot = udp source port = 1267 destination port = 53 … data … process sa process ra udp process qa dns client tcp ip 1267 process sb process rb udp process qb dns server tcp ip 53 ip network udp source port udp dest port udp message length udp checksum udp payload ( data ) ip header udp datagram ip packet default port number for any dns server • assigned by os to identify processes within a host • servers ’ port numbers must be well - known to clients ( e. g. 53 for dns ) • src and dest port numbers are inside transport - layer header ephemeral port dynamically assigned by os the picture shows two processes ( = network application programs ) pa, and pb that are communicating. each of them is associated locally with a port, as shown in the figure
EPFL COM 407 Moodle
No question: Moodle
. the example shows a packet sent by the name resolver process at host a, to the domain name server ( dns ) process at host b. the udp header contains the source and destination ports. the destination port number is used to contact the name server process at b ; the source port is not used directly ; it will be used in the response from b to a. the udp header also contains a checksum of the udp data plus the ip addresses and packet length. checksum computation is not performed by all systems. ports are 16 bits unsigned integers. they are defined statically or dynamically. typically, a server uses a port number defined statically. standard services use well - known default port numbers ; e. g., all dns servers use port 53 ( look at / etc / services ). ports that are allocated dynamically are called ephemeral. they are usually above 1024. if you write your own client server application on a multiprogramming machine, you need to define your own server port number and code it into your application. 1. udp is message - oriented, and unreliable • udp delivers the exact message ( a. k. a. “ datagram ” ) or nothing • consecutive messages may arrive out of order • messages may be lost • one message, up to 65, 535 bytes • if udp message is too large to fit into a single ip packet ( i. e. larger than mtu )
EPFL COM 407 Moodle
No question: Moodle
, then ip layer fragments it - at the ip layer of the source, info about fragments added inside ip header - not visible to the transport layer - if a fragment / piece is lost then the entire message is considered lost application layer should handle these, if necessary how is udp implemented in practice? via a socket library = programming interface - sockets in unix are similar to files for read / write figure shows a client - server app using udp : client sends a char string to server, which receives ( and displays ) it • socket ( socket. af _ inet, … ) creates an ipv4 socket and returns a number ( = file descriptor ) if successful • socket ( socket. af _ inet6, … ) creates an ipv6 socket • bind ( ) associates an ip address and port number with the socket — can be skipped for a client socket. port = 0 means any available port, ip address = 0 ( 0. 0. 0. 0 or : : ) means all addresses of host • sendto ( ) specifies destination ip address, destination port number and the message to send • recvfrom ( ) blocks until a message is received for this port number ; it returns the source ip address and port number and the message. client s = socket. socket ( ) s. sendto ( ) s. close ( ) server s = socket. socket ( ) ; s. bind ( ) s. recvfrom ( ) %. /
EPFL COM 407 Moodle
No question: Moodle
udpclient < destaddr > bonjour les amis % %. / udpserv & % what socket to open? ipv4 or ipv6? • transport layer is not affected by the choice of ip ( no udpv6, nor tcpv6 ) • but, there are ipv4 and ipv6 sockets • an application program has to choose ipv4 or ipv6, or better support both how? use socket. getaddrinfo ( ) to let the dns give you whatever is available > python > > > import socket > > > socket. getaddrinfo ( " lca. epfl. ch ", none ) [ ( < addressfamily. af _ inet6 : 23 >, 0, 0,'', ('2001 : 620 : 618 : 521 : 1 : 80b3 : 2127 : 1 ', 0, 0, 0 ) ), ( < addressfamily. af _ inet : 2 >, 0, 0,'', ('128. 179. 33. 39 ', 0 ) ) ] what socket? socket ( af _ inet, … ) or socket ( af _ inet6, … ) s. sendto ( ) s. close ( ) s = socket. socket ( ) socket. getaddrinfo ( ) # select one ip version / # address of destination an ip
EPFL COM 407 Moodle
No question: Moodle
##v6 socket can be dual - stack • in some machines, ipv6 sockets can be bound to both ipv6 and ipv4 addresses of the local host • how? the correspondents ’ ipv4 addresses are mapped to ipv6 addresses - using the ipv4 - mapped ipv6 address format - i. e., by appending the ipv4 address to prefix : : ffff : 0 : 0 / 96 • such sockets can receive packets from ipv6 and from ipv4 correspondents. • default in linux, must be enabled for every socket ( with setsockopt ) in windows. • an ipv4 socket cannot be dual - stack. why? 2020 : baba : : b0b0 11. 22. 33. 44 ipv6 socket from 1. 2. 3. 4 from : : ffff : 0102 : 0304 from 2001 : face : b00c : : 1 from 2001 : face : b00c : : 1 solution it is possible to map ipv4 addresses to a subset of the ipv6 space because ipv6 addresses are much longer in bits. the converse is not possible : there are more ipv6 addresses than ipv4 addresses. an ipv4 socket cannot receive data from an ipv6 source address. how does the operating system view udp? udp datagrams are delivered to sockets based on dest ip address and port number :
EPFL COM 407 Moodle
No question: Moodle
• socket 5 is bound to local address 2001 : baba : : b0b0 and port 32456 ; receives all data to 2001 : baba : : b0b0 udp port 32456 • socket 3 is bound to local address 11. 22. 33. 44 and port 32456 ; receives all data to 11. 22. 33. 44 udp port 32456 • socket 4 is bound to local address 11. 22. 33. 44 and port 32654 ; receives all data to 11. 22. 33. 44 udp port 32654 id = 3 id = 4 send / receive buffers port = 32456 port = 32654 application program udp ip address = 11. 22. 33. 44 ipv4 socket ipv4 socket id = 5 ipv6 socket ipv6 packet ipv4 packets r port = 32456 udp datagrams address = 2001 : baba : : b0b0 s r s r s with a dual - stack ipv6 socket? socket 5 is bound to any local address, which includes ipv6 and ipv4 addresses, and to port 32456 ; receives all packets to 2001 : baba : : b0b0, udp port 32456 and to 11. 22. 33. 44 udp port 32456 socket 4 is bound to ipv4 address 11. 22. 33. 44 and port 32654 ; receives all packets to 11. 22. 33. 44 udp port 32654
EPFL COM 407 Moodle
No question: Moodle
id = 4 send / receive buffers port = 32456 port = 32654 application program udp ip ipv4 socket id = 5 ipv6 socket ipv6 packet ipv4 packets port = 32456 udp datagrams address = 11. 22. 33. 44 address = 2001 : baba : : b0b0 r s r s common send / receive buffers for 2 addresses recap - udp on the sending side : os sends the udp message asap, but also uses a buffer to store data if interface is busy os may also fragment the message if needed. on the receiving side : os re - assembles ip fragments of udp message ( if needed ) and keeps the message in receive buffer ready to be read. the message is • “ consumed ” when application reads • or “ dropped ” because of an overflow event a socket is bound to a single port and one or multiple ip addresses of the local host user ’ s browser sends dns query to dns server, over udp. what happens if query or answer is lost? a. name resolver in browser waits for timeout, if no answer received before timeout, sends again b. messages cannot be lost because udp assures message integrity c. udp detects the loss and retransmits d. je ne sais pas go to web. speakup. info or download speakup app join room 46045 solution answer a 2. tcp offers
EPFL COM 407 Moodle
No question: Moodle
reliable, in - order delivery what does this mean? tcp guarantees that all data is delivered in order and without loss, unless the connection is broken how does tcp achieve this? • uses sophisticated mechanisms to detect reordering and loss : - per - byte sequence numbers — > data is numbered - a connection - setup phase for the sender / receiver to synchronize their sequence nums - acknowledgements ; if loss is detected, tcp re - transmits • further optimizations, e. g. : - flow control avoids buffer overflow at the receiver - tcp knows the allowable maximum segment size ( mss ) and segments data accordingly — > avoids fragmentation at the ip layer tcp basic operation 1 : seq and ack seq 8001 : 8500 1 ack 8501 2 deliver bytes 8001 : 8500 a b 8 seq 8501 : 9000 timeout! 6 7 seq 8501 : 9000 seq 9001 : 9500 seq 9501 : 10000 ack 8501 3 4 5 ack 9001 seq 9001 : 9500 9 deliver bytes 8501 : 9000 deliver bytes 9001 : 10000 10 cumulative acks seq 9501 : 10001 has been received the previous slide shows a in the role of sender and b of receiver. • the application at a sends data in blocks of 500 bytes at a slow pace. so, tcp initially sends 500 - byte segments.
EPFL COM 407 Moodle
No question: Moodle
• however, the maximum segment size in this example is 1000 bytes. so, tcp may also merge 2 blocks of data in one segment if this data happens to be available at the send buffer of the socket. • packets 3, 4 and 7 are lost. • b returns an acknowledgement in the ack field. the ack field is cumulative, so ack 8501 means : b is acknowledging all bytes up to ( excluding ) number 8501. i. e. the ack field refers to the next byte expected from the other side. • at line 8, the timer that was set at line 3 expires ( a has not received any acknowledgement for the bytes in the packet sent at line 3 and experiences a timeout ). a re - sends data that is detected as lost, i. e. bytes 8501 : 9001. when receiving packet 8, b delivers all bytes from 8501 to 9000 in order. • when receiving packet 10, b can deliver bytes 9001 : 10000 because packet 5 was received and kept by b in the receive buffer. tcp basic operation 2 : sack and optimized segmentation ( if possible ) seq 8001 : 8500 ack 8501 seq 8501 : 9000 seq 9001 : 9500 seq 9501 : 10000 seq 8501 : 9500 ack 8501 sack ( 9501 : 10000 ) ack 10001 seq 10001 : 105
EPFL COM 407 Moodle
No question: Moodle
##00 1 2 3 4 5 6 7 8 9 deliver bytes 8001 : 8500 deliver bytes 8501 : 10000 deliver bytes 10001 : 10500 a b 10 tcpmaxdupacks set to 1 at a cumulative + selective ack 2 data blocks are merged, because here : mss = 1000 in addition to the ack field, most tcp implementations also use the sack field ( selective acknowledgement ). the previous slide shows the operation of tcp with sack. • the application at a sends data in blocks of 500 bytes. but, in this example, we assume that the maximum segment size is mss = 1000 bytes. • segments 3 and 4 are lost. • at line 6, b acknowledges all bytes up to ( excluding ) number 8501. • at line 7, b acknowledges all bytes up to 8501 and in the range 9501 : 10000. since the set of acknowledged bytes is not contiguous, the sack option is used. it contains up to 3 blocks that are acknowledged in addition to the range described by the ack field. • at line 8, a detects that the bytes 8501 : 9500 were lost and re - sends them asap without waiting for a timeout, because in this example host a uses tcpmaxdupacks = 1 ( we will discuss tcpmaxdupacks later ). what is important to notice is that at line 8, since the maximum segment size is 1000 bytes, only one packet
EPFL COM 407 Moodle
No question: Moodle
is sent. this is what the slide ’ s title means by “ optimized segmentation ”. • when receiving packet 8, b can deliver bytes 9001 : 10000 because packet 5 was received and kept in the receive buffer. tcp receiver uses a receive buffer = re - sequencing buffer to store incoming packets before delivering them to application why invented? • application may not be ready to consume / read data • packets may need re - sequencing ; out - of - order data is stored but is not visible to application 8001 : 8500 9501 : 10000 8001 : 10000 8001 : 8500 can be read ( received ) by app invisible to app ( cannot be read ) tcp uses a sliding window why? • the receive buffer may overflow if one piece of data “ hangs ” - multiple losses affect the same packet, - so, multiple out - of - order packets fill the buffer • the sliding window limits the number of data “ on the fly ” ( = not yet acknowledged ) p0 a1 p1 p2 a2 pn p0 again pn + 1 p1 p1 p2 p1 p2... pn p1 p2... pn + 1 receive buffer how does the sliding window work? • suppose : window size = 4000b ; each segment = 1000b • only seq numbers that are in the window can be sent ( if of course this data is in the socket waiting to be sent ) lower
EPFL COM 407 Moodle
No question: Moodle
window edge = smallest non - ack ’ ed sequence number upper window edge = lower _ edge window _ size + window usable part of the window, seq numbers that the sender can send note : here we assume that no more data exists in the socket ; so only segment 0 is sent, even though segments 0, 1, 2, 3 could be sent, too. window size = 4 ’ 000 bytes, one packet = 1 ’ 000 bytes at time, the usable part of the sliding window is 4000, and there is a lot of data in the socket to be sent. so, the sender sends 4 segments. at time, sender … a. … can send segment s = 4 b. … cannot send segment s = 4 c. it depends on whether data was consumed by application d. i do not know go to web. speakup. info or download speakup app join room 46045 solution answer b. the window size is 4 ’ 000 b, namely here 4 packets. at time packets - 1, 1, 2 and 3 are acked. the window is packets. packet 4 is outside the window and cannot be sent. it has to wait until the loss of packet 0 is repaired ( at time ) sender also needs a buffer ( “ retransmission buffer ” ) ; its size is the window size. segments are removed from the resequencing / receive buffer when they are finally in - order and application reads them
EPFL COM 407 Moodle
No question: Moodle
. [ 0 ; 3 ] s = 0 0 ; retransmission buffer s = 1 s = 2 s = 3 s = 0 s = 4 0 ; 1 0 ; 2 0 ; 2 ; 3 0 ; 0 ; resequencing buffer 1 1 ; 2 1 ; 2 ; 3 0 ; 1 ; 2 ; 3 deliver 0... 3 4 deliver 4 a = - 1, sack = 1 a = - 1, sack = 1 - 3 a = 3 a = - 1, sack = 1 - 2 4 ; a fixed - size ( static ) window cannot prevent receive - buffer overflow • in - order data remains in resequencing buffer, until it is consumed by application ( typically using a socket “ read ” or “ receive ” ) slowly reading receiver app could cause buffer overflow application reads receive buffer application reads window size = 4000 bytes one packet = = 1000 bytes flow control : an adaptive sliding window • what? constantly adapts the window size by leveraging advertizements from the other end - host : i. receiver advertizes a window size = available buffer size ii. if no space in buffer, receiver advertizes window = 0 iii. sender adapts its sliding window to the advertized value tcp adapts source ’ s sending rate to receiver ’ s consuming speed congestion control, which adapts source ’ s sending rate to network conditions [ we will see this in an on
EPFL COM 407 Moodle
No question: Moodle
##coming lecture ] = 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 s = 1 ack = - 1, window = 2 s = 0 s = 2 s = 3 s = 4 ack = 0, window = 2 s = 5 s = 6 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 ack = 2, window = 4 0 1 2 3 4 5 6 7 8 9 10 11 12 ack = 0, window = 4 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 ack = 4, window = 2 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 ack = 6, window = 0 0 1 2 3 4 5 6 7 8 9 10 11 12 ack = 6, window = 4 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9
EPFL COM 407 Moodle
No question: Moodle
10 11 12 s = 7 1 unit of data = 1000 bytes 1 packet = 1000 bytes receive buffer size = 4000 bytes 1 unit of data, 1 packet = 1000 bytes ack = 4, window = 2 s = 1 ack = - 1, window = 2 s = 0 s = 2 s = 3 s = 4 ack = 0, window = 2 s = 5 s = 6 ack = 2, window = 4 ack = 0, window = 4 ack = 6, window = 0 ack = 6, window = 4 s = 7 - 2 - 1 - 3 - 2 - 1 - 3 - 2 - 1 0 - 3 - 2 - 1 0 - 3 - 2 - 1 0 1 - 3 - 2 - 1 0 1 - 3 2 - 2 - 1 0 1 - 3 2 - 2 - 1 0 1 - 3 2 3 - 2 - 1 0 1 - 3 2 3 4 - 2 - 1 0 1 - 3 2 3 4 5 - 2 - 1 0 1 - 3 2 3 4 5 6 - 2 - 1 0 1 - 3 2 3 4 5 6 free spaces in the buffer data acked but not yet consumed s. read ( ) s. read ( ) s. read ( ) s. read ( ) 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2
EPFL COM 407 Moodle
No question: Moodle
3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 recap : tcp basic operation bytes 10001 : 10500 are available 8001 : 8500 ( 500 ) ack 101 win 6000 101 : 200 ( 100 ) ack 8501 win 4000 8501 : 9000 ( 500 ) ack 201 win 14247 9001 : 9500 ( 500 ) ack 201 win 14247 9501 : 10000 ( 500 ) ack 201 win 14247 ( 0 ) ack 8501 sack 9001 : 9501 win 3500 8501 : 9000 ( 500 ) ack 251 win 14247 201 : 250 ( 50 ) ack 850
EPFL COM 407 Moodle
No question: Moodle
##1 sack 9001 : 10001 win 3000 251 : 400 ( 150 ) ack 10001 win 2500 10001 : 10500 ( 500 ) ack 401 win 14247 1 2 3 4 5 6 7 8 9 10 bytes... : 8500 are available and consumed bytes 8501 : 10000 are available a b app consumes bytes 8501 : 10000 ( 0 ) ack 10001 win 4000 11 retransmission after timeout the picture shows a sample exchange of messages. every packet carries the sequence number for the bytes in the packet ; in the reverse direction, packets contain the acknowledgements for the bytes already received in sequence. the connection is bidirectional, with acknowledgements and sequence numbers for each direction. so here a and b are both senders and receivers. acknowledgements are not sent in separate packets, but are in the tcp header ( “ piggybacking ” ). every segment thus contains a sequence number ( for itself ), plus an ack number ( for the reverse direction ). the following notation is used : “ firstbyte ” : ” lastbyte ” ( lastbyte - ( firstbyte - 1 ) is equal to the “ segmentdatalength ” ) “ ack ” = acknumber + 1 “ win ” = offered windowsize. at line 8, a retransmits the lost data. when packet 8 is received, the application is not yet ready
EPFL COM 407 Moodle
No question: Moodle
to read the data. later, the application reads ( and consumes ) the data 8501 : 10000. this frees some buffer space on the receiving side of b ; the window can now be increased to 4000. at line 10, b sends an empty tcp segment with the new value of the window. note that numbers on the figure are rounded for simplicity. in real examples we are more likely to see non - round numbers ( between 0 and 2 ^ 32 - 1 ). also, the initial sequence number is not 0, but is chosen at random. if there ’ s no loss or reordering, and on a link with capacity bytes / second, the min window size required for sending at the capacity is … a. b. c. d. none of the above e. i do not know = = = time go to web. speakup. info or download speakup app join room 46045 solution if the window size is small, the sender is blocked after sending a full window. the sending rate in this case is. this case occurs when < answer a if the window size is large enough, the window is never fully used and the sender can send at rate. this case occurs when the total amount of data in flight,, is not larger than, i. e. when ( i. e. window bandwidth - delay product ) c ×
EPFL COM 407 Moodle
No question: Moodle
≥ sender side : • data accumulates in send buffer until tcp decides to create a segment receiver side : • data accumulates in receive buffer until potential losses are repaired and data is put in order, so that application can consume it no boundaries between bytes : • several small messages written by a ’ s app may be received by b as a single segment • and conversely, a single message written by a ’ s app may be received by b as multiple segments ; so, apps need to group bytes to messages ( if needed ) side effect is head of the line blocking : if a packet is lost, all data following this packet is not read by application, until loss is repaired recap : tcp is a reliable, byte - oriented, streaming service for which types of apps may tcp ’ s streaming service be an issue? ( multiple answers are fine ) a. an app using http / 1, where we have one tcp connection per object b. an app using http / 2, where we have one tcp connection per webpage c. a real time video streaming application that sends a new packet every msec d. none e. i do not know go to web. speakup. info or download speakup app join room 46045 solution answer f : ( b and c ) for http / 2 with one single connection, head - of - the line blocking can occur : if one packet is lost in the transfer of one object of the page, the entire
EPFL COM 407 Moodle
No question: Moodle
page download is delayed until the loss is repaired. head - of - the line blocking may also occur for a real - time streaming app and is probably even worse : with tcp, the loss of one packet delays all subsequent packets until the loss is repaired, whereas the live application might prefer to skip the lost packet and receive the most recent one. such an app should use udp. mss and segmentation tcp, not the application, chooses how to segment data tcp segments should not be fragmented at source tcp segments have a maximum size ( called mss ) : • default values are : 536 bytes for ipv4 operation ( 576 bytes ipv4 packet ), 1220 bytes for ipv6 operation ( 1280 bytes ipv6 packets ) • otherwise negotiated in options header field during connection setup : hosts set it to the smallest value that both declare modern oss use tcp segmentation offloading ( tso ) : • segmentation is done at the network interface card ( nic ) with hardware assistance • cpu load of tcp is reduced 3. tcp connection phases syn, seq = x syn _ sent syn ack, seq = y, ack = x + 1 ack, ack = y + 1 established established snc _ rcvd listen fin, seq = u ack = v + 1 ack = u + 1 fin seq = v fin _ wait _ 2 time _ wait close _ wait last _
EPFL COM 407 Moodle
No question: Moodle
ack closed application active open passive open application close : active close fin _ wait _ 1 connection setup data transfer connection release recall : tcp connections involve only two hosts ( routers in between are not involved ) before transmitting useful data, tcp requires a connection setup phase : - used to agree on seq numbers and make sure buffers and windows are initially empty the previous slide shows all phases of a tcp connection : - before data transfer takes place, the tcp connection is opened using syn packets. the effect is to synchronize the counters at both sides. - the initial sequence number is a random number. - then the data transfer begins and works as described earlier. - finally the connection closes. this can be done in a number of ways. the picture shows a graceful release where both sides of the connection are closed in turn. there are many more subtleties ( e. g. how to handle connection termination, lost or duplicated packets during connection setup, etc. [ see textbook computer networking principles protocols and practice : sections 4. 3. 1 and 4. 3. 2 ] flags meaning ns used for explicit congestion notification cwr used for explicit congestion notification ecn used for explicit congestion notification urg urgent ptr is valid ack ack field is valid psh this seg requests a push ( creating a segment immediately ) rst reset the connection syn connection setup fin sender has reached end of byte stream padding options ( sack, mss, … )
EPFL COM 407 Moodle
No question: Moodle
src port dest port sequence number ack number hlen window flags rsvd urgent pointer checksum segment data ( if any ) tcp header ( 20 bytes + options ) ip header ( 20 or 40 b + options ) < = mss bytes 32 bits indicates the next expected seq num from the other host tcp data tcp hdr ip data = tcp segment ip hdr prot = tcp tcp segment format the previous slide shows the tcp segment format. • syn and fin are used to indicate connection setup and close. each one uses one sequence number. • the sequence number is that of the first byte in the data. • the ack number is the next expected sequence number. • options may include the selective ack ( sack ) field, or the maximum segment size ( mss ), which is negotiated during syn - synack phase — the negotiation of the maximum size for the connection results in the smallest value to be selected. • the checksum is mandatory. • the ns, crw and ecn bits are used for congestion control [ see lecture on congestion control ]. • the push bit can be used by the upper layer using tcp ; it forces tcp on the sending side to create a segment immediately. if it is not set, tcp may pack together several sdus ( = data passed to tcp by the upper layer ) into one pdu ( = segment ). on the receiving side, the push bit forces
EPFL COM 407 Moodle
No question: Moodle
tcp to deliver the data immediately. if it is not set, tcp may pack together several pdus into one sdu. this is because of the streaming service of tcp : tcp accepts and delivers contiguous sets of bytes, without any “ message ”. the push bit is used by telnet after every end of line. • the urgent bit indicates that there is urgent data, pointed to by the urgent pointer ( the urgent data need not be in the segment ). the receiving tcp must inform the application that there is urgent data. otherwise, the segments do not receive any special treatment. this is used by telnet to send interrupt type commands. • rst is used to indicate a reset command. its reception causes the connection to be aborted. client s = socket. socket ( ) server s s1 = socket. socket ( ) s. connect ( s, 5003 ) s1. bind ( 5003 ) s1. listen ( ) conn = s1. accept ( ) syn syn ack ack 1 2 tcp sockets ( simplified scenario ) more complicated than udp because we need to open / close a connection a tcp connection requires : • one side ( “ server ” ) to listen and • the other side ( “ client ” ) to connect steps : • at t = 1, at client side, connection setup has finished and client uses the socket to send / receive data • at t = 2, at server side, a new
EPFL COM 407 Moodle
No question: Moodle
socket ( conn ) is created ; this will be used by the server to send / receive data. this example is simplistic : - client sends one message to server and quits ; - server responds to this single client - reality is different, see next slide 1 2 client s = socket. socket ( ) ; server s s1 = socket. socket ( ) s. connect ( s, 5003 ) s. send ( … ) s. close ( ) s1. bind ( 5003 ) s1. listen ( ) conn = s1. accept ( ) conn. recv ( ) conn. close ( ) syn syn ack ack tcp sockets ( simplified scenario ) the figure of the previous 2 slides shows toy client and servers. the client sends a string of chars to the server which reads and displays it. • socket ( af _ inet, … ) creates an ipv4 socket and returns a socket object if successful socket ( af _ inet6, … ) creates an ipv6 socket • bind ( 5003 ) associates the local port number 5003 with the socket ; the server must bind, the client need not bind, a temporary port number is allocated by the os • connect ( s, 5003 ) associates the remote ip address of s and its port number with the socket and sends a syn packet • send ( ) sends a block of data to the remote destination • listen ( ) declares the size of the buffer
EPFL COM 407 Moodle
No question: Moodle
used for storing incoming syn packets ; • accept ( ) blocks until a syn packet is received for this local port number. it creates a new socket ( in pink ) and returns the file descriptor ( conn ) to be used to interact with this new socket • recv ( ) blocks until one block of data is ready to be consumed on this port number. you must tell in the argument how many bytes at most you want to read. it returns a block of bytes or raises an exception when the connection was closed by the other end. • server creates a new socket per connection • uses parallel - execution threads - to handle several tcp connections - to listen to incoming connections • 2 types of sockets - “ conn ” - type are connected sockets ( pink ), - “ s1 ” - type is a non - connected socket ( blue ) • a tcp connection is identified by : src ip addr + src port + dest ip addr + dest port client s = socket. socket ( ) server s s1 = socket. socket ( ) s. connect ( s, 5003 ) s. send ( … ) s. close ( ) s1. bind ( 5003 ) s1. listen ( ) conn = s1. accept ( ) conn. recv ( ) conn. close ( ) ; conn. recv ( ) conn. close ( ) ; conn. recv ( ) conn. close
EPFL COM 407 Moodle
No question: Moodle
( ) ; conn. recv ( ) conn. close ( ) ; conn. recv ( ) conn. close ( ) ; conn. recv ( ) conn. close ( ) ; conn. recv ( ) conn. close ( ) ; conn. recv ( ) conn. close ( ) ; tcp sockets ( practical scenario ) how the operating system views tcp sockets? tcp ip r id = 3 id = 4 port = 32456 address = 128. 178. 151. 84 r id = 5 re - sequencing buffers ipv4 socket ipv4 socket ipv4 socket application program r id = 6 port = 32456 ipv6 socket ipv6 socket address = 2001 : 620 : 618 : 1a6 : 3 : 80b2 : 9754 : 1 id = 7 ipv6 packets ipv4 packets connection requests app data app data app data connection requests r r s s s s s re - sequencing buffers why both tcp and udp? most applications use tcp rather than udp, as this avoids re - inventing error recovery in every application but some applications do not need error recovery in the way tcp does it ( i. e. by packet retransmission ) for example : voice applications / sensor data streaming q. why? for example : an application that sends just one message, like name resolution ( dns ). q. why? for
EPFL COM 407 Moodle
No question: Moodle
example : multicast ( tcp does not support multicast ip addresses ) why both tcp and udp? most applications use tcp rather than udp, as this avoids re - inventing error recovery in every application but some applications do not need error recovery in the way tcp does it ( i. e. by packet retransmission ) for example : voice applications / sensor data streaming q. why? a. delay is important for interactive voice, while packet retransmission may introduce too much delay in some cases. sensor data streaming may send a new packet every few msecs, better to receive latest packet than to repeat a lost one. for example : an application that sends just one message, like name resolution ( dns ). q. why? a. tcp sends several packets of overhead before one single useful data message. such an application is better served by a stop and go protocol at the application layer. for example : multicast ( tcp does not support multicast ip addresses ) 4. more tcp bells and whistles • what to do with corner cases? - application writes 1 byte into the socket ; should tcp send a packet or wait for more bytes to be written? = > nagle ’ s algorithm prevents sending many small packets - how to handle silly window - increase advertizements by 1 byte? • window field is 16bits, so the max throughput when rtt = 1msec is ≈524
EPFL COM 407 Moodle
No question: Moodle
##mbps ; can we increase this? = > negotiate a scaling factor of the window during connection setup ( rfc1323 ) • how to detect packet loss? • how to avoid syn flooding ( denial of service attack )? • how to avoid the delay of the 3 - way handshake? [ we will see only the last three in detail ; see textbook section 4. 3. 3 for the ones we don ’ t see here. ] how to detect packet loss? via timers and duplicate acks the main timers are called retransmission timeouts ( rto ) • set for every packet transmission • when a timer expires ( = timeout ) - this is interpreted as severe loss in the channel - all timers are reset - all un - acknowledged data is marked as needing retransmission a duplicate ack = a tcp segment where the cumulative ack value repeats a previously received ack value - this is interpreted as not - so - severe loss in the channel ( the channel can still deliver some packets but out of order ) timers use an estimate of round trip time ( rtt ) why? rto timer must be set at a value larger than rtt, but not too much what? rtt estimation gives an upper bound on the round trip time, which we use to set the rto how? ( similar to a moving average metric ) ( similar to a variability metric ), where rtt : last measured rtt srtt
EPFL COM 407 Moodle
No question: Moodle
: smoothed rtt rttvar : ℓ1 −error bound srtt = ( 1 −α ) ⋅srtt + α ⋅rtt rttvar = ( 1 −β ) ⋅rttvar + β ⋅ | srtt −rtt | rto = srtt + η ⋅rttvar α = 1 / 8, β = 1 / 4, η = 4 example 0 2 4 6 8 10 12 14 1 11 21 31 41 51 61 71 81 91 101 111 121 131 141 seconds seconds rto sampledrtt • initial value is at 6 ( default for linux ), but converges quickly • rto increases when there is variability in the rtt • rto may be significantly larger until it converges back after a sharp discontinuity idea : “ instead of waiting for a timeout, tcp can determine that a packet is lost just after a single duplicate ack is received with a sack field, and it and can quickly retransmit. ” is it a good idea? a. yes because it is likely that there is some missing data b. no as it may cause superfluous retransmissions ( some data could simply be late - - out of order ) c. no because an ack also could be lost d. i do not know solution there is no “ good ” answer. both a and b can be argued. this is why “ fast retransmit ” was invented. fast retrans
EPFL COM 407 Moodle
No question: Moodle
##mit principle : when duplicate acks are received, declare a loss ( recall : duplicate ack = a tcp segment where the ack value repeats a previously received ack value ) • tcpmaxdupacks is set by the operating system ( default value is 3 ) • which data is lost is inferred from the sack blocks n = p1 p2 p3 p4 ack = 1000ack = 2000 p5 p6 retransmit p3 p7 ack = 2000 sack = 3000 : 4000 ack = 2000 sack = 3000 : 5000 ack = 2000 sack = 3000 : 6000 1 2 3 4 5 ack =? 6 all segments are 1000 bytes ; tcpmaxdupacks = 3 when does fast retransmit fail to detect loss via duplicate acks? a. almost never, it is quasi - optimal b. it fails to detect the loss extremely rarely, but it may often take a long time to detect. c. when one of the last segments of an application layer block is lost, fast retransmit does not detect it. d. it may often fail due to packet re - ordering e. i do not know go to web. speakup. info or download speakup app join room 46045 solution answer c ( and probably d ). see next slides. most losses are detected via fast retransmit ( duplicate acks ), but few go undetected : • bursts of loss are
EPFL COM 407 Moodle
No question: Moodle
not detected, if ( forward or reverse ) channel is broken • isolated / single packets, that are lost, are not detected • last / trailing packets ( of a block of application data ), that are lost, may not be detected loss probe avoids the latter issue : when the probe timeout pto = min { rto, max { 2 * smoothedrtt, 10msecs } } expires, a " probe " is sent ( i. e. we retransmit a non ack ’ ed packet ) to trigger new acks and fast retransmit of course, undetected losses will be eventually detected via rto timer, but this may take a long ( er ) time fast retransmit may be inefficient if packets are just reordered • the sender retransmits packets that weren ’ t lost — they were just reordered • 2 counter measures : [ at network layer : ] per - flow load balancing avoids sending packets of the same tcp connection over different paths [ at transport layer : ] instead of duplicate ack, use rack ( recent ack ), which bases retransmissions on time, not sequence numbers : - [ alg. : ] determine that packet p is lost, if : • another out - of - order packet is ack ’ ed and • p has not been acked after time = the latest rtt measurement + a
EPFL COM 407 Moodle
No question: Moodle
configurable “ reordering ( time ) window ” syn cookies ( = specific initial seq numbers ) why? mitigate impact of syn flood attack : lots of bogus syn packets from ( spoofed ) source addresses sent to a server in detail : whenever a tcp server receives a syn packet, it keeps state about this connection ( source ip address, port, seq number, etc. ) in kernel. if many syn packets are bogus and remain stored in memory until timeouts occur, the server may run out of memory — hence legitimate syn packets may be dropped. this is a denial - of - service attack! how? with syn cookies : • server does not keep state information after receiving a syn packet • state is encoded in the seq number field, using a cryptographic function and sent to client ( as a “ cookie ” ) through synack • if syn is not bogus, 3rd handshake ack contains the state in the ack field syn cookies encode state in seq of syn ack • after receiving a syn packet, server does not keep any state and sends y = syn cookie in syn - ack • y = { ( 5 bit ) t mod 32 | | ( 3 bits ) mss encoded in syn | | ( 24 bits ) cryptographic hash of : secret server key, t ( timestamp ) and client ip address and port number, the server ip address and port number } • client sends ack
EPFL COM 407 Moodle
No question: Moodle
= y + 1 • server verifies that hash is valid ; if so creates socket, using the mss recovered from cookie • if syn was bogus, no ack follows and damage is reduced to the time for computing the hash, but server is always up ( syn flood is avoided! ) server does not implement syn cookies. if ack ( 3 ) is lost, server will : 1 ) retransmit syn ack 2 ) keep state information until timeout occurs a. 1 b. 2 c. 1 and 2 d. none e. i do not know go to web. speakup. info or download speakup app join room 46045 solution answer c. server that does not implement syn cookies : when the server sends the syn - ack packet, it does all the usual stuff done by tcp to test whether a packet containing some data is lost. note that this packet contains no data but it is treated as if it would ( this is why ack ( 3 ) number is y + 1 and not y ). if syn - ack is lost, server receives no ack and retransmits the syn - ack. if the server implements syn cookies, then we risk a deadlock. • the server keeps no state information after sending the syn - ack ; therefore, if the syn - ack is lost or if the ack ( 3 ) is lost, the server does not retransmit. • in most
EPFL COM 407 Moodle
No question: Moodle
cases, the client application sends data when the syn ack is received. so even if ack ( 3 ) is lost, the next segment of data serves as an ack and the client will detect this loss. - some applications that do not have this property, e. g. ssh or mysql. - such applications would hang on the client side if ack ( 3 ) is lost. hopefully such apps implement a timeout at the application layer to avoid such deadlocks. with syn cookies, the response time of syn - ack is … a. larger than without syn cookies b. smaller than without syn cookies c. the same d. i do not know go to web. speakup. info or download speakup app join room 46045 solution answer a. the syn - cookie - enabled server must perform a verification of the cryptographic hash and create the state, which is more time consuming than without syn cookies. tcp fast open ( tfo ) why? avoid latency of 3 - way handshake when opening repeated connections. how? in first syn _ ack, tcp client receives inside tcp options and caches a cookie that contains a message authentication code t = mac ( k, c ) computed by server with secret key k ( unknown to client ) and client ip address c. when opening the next connection : • client sends back the mac t in syn packet • when receiving syn and t, server knows that this client is
EPFL COM 407 Moodle
No question: Moodle
someone that has connected before • server can send data already in syn - ack tfo tcp client tfo tcp server syn mac in tcp option get / hello. htm syn ack server data ack ack more data 5. secure transport • tcp has no security • needs to be complemented with a security layer such as transport layer security ( tls ) ( tls is in application layer ) • tls adds to tcp : • confidentiality : data is encrypted with symmetric encryption ; using secret keys created on the fly for this session • authentication : data is protected against forgery + identity of end - system is authenticated http used over tls and port 443 = https tls tcp http tls tcp http ip background in cryptography symmetric ( or shared - key ) cryptography ( e. g. aes ) uses a secret key, shared only by sender and receiver. messages are encrypted using the shared secret key and can ( only ) be decrypted using the same secret key ; this provides confidentiality. it can also be used to authenticate a message by adding a message authentication code ( mac ) computed with the secret key, which can be verified using the same secret key. it is very fast but has the problem of key distribution. asymmetric ( or public - key ) cryptography ( e. g. rsa ) uses two different keys : one can be used
EPFL COM 407 Moodle
No question: Moodle
for encryption, the other for decryption. one of the keys must be secret ( private ), the other one is public. the private key cannot be computed from the public key other than by brute - force ( in principle ). this eases the problem of key distribution but encryption / decryption is computationally intensive. in all cases, keys must be long enough to resist brute - force attacks today ( e. g. 256 bits for aes, 2000 bits for rsa ). tls uses asymmetric + symmetric keys + certificates simplified version of key exchange protocol ( rsa ), used before tls 1. 3 : 1. server sends a certificate, which contains its public key signed by certification authority ( ca ) 2. client verifies that is indeed the key of the server by verifying the signature using ca ’ s public key, pre - installed in client ’ s web browser. 3. client uses public key to share secret session keys used to encrypt and authenticate the e - banking transaction. 4. two - way communication uses shared secret keys public key in a certificate ( ’ tsfr 2m to bo ’ ), = = ( ) verify using ca ’ s public key sample session keys ℓ1, ℓ2 = ( ℓ1, ℓ2 ) ( ℓ1, ℓ2 ) = ( ) encrypted message authentication / verification
EPFL COM 407 Moodle
No question: Moodle
tag a digital certificate for bekb contains … a. the public key of bekb b. the identity of bekb ( official name as of registre du commerce ) c. the public key of the issuing ca d. a and b e. a and c f. b and c g. all h. none i. i do not know go to web. speakup. info or download speakup app join room 46045 solution answer d, in principle. the certificate binds the identity to a public key, so it must contain a and b. however, the ca ’ s public key must be pre - installed using some secure procedure ( such as the original system installation ). even if it is present in the certificate, only the pre - installed ca public key should be used. tls 1. 3 • does not support rsa key exchange • communicating parties : - agree on cryptographic suites - exchange cryptographic parameters ( in " key share ” field ), to compute session keys ( ~ “ diffie - hellman ” approach ) • ( in principle ) needs 1 - rtt handshake before sending data • many old cipher suites are no longer secure – important to keep tls software up - to - date tls 1. 3 client tls 1. 3 server clienthello cipher suite, key share serverhello cipherspec, server certify, key share, finished application data tls sockets tls sockets ( also called ssl
EPFL COM 407 Moodle
No question: Moodle
sockets ) are transformed / “ wrapped ” sockets. 1 2 client s = socket. socket ( ) ; server s ss. connect ( s, 5003 ) ss. send ( … ) ss. close ( ) s1. listen ( ) ss = ssl. wrap _ socket ( s, ca _ cert ) create context object with certificate and keys s1 = socket. socket ( ) s1. bind ( 5003 ) sconn = context. wrap _ sockets ( conn ) sconn. close ( ) ; conn = s1. accept ( ) syn server hello client hello syn ack ack sconn. recv ( ) 3 on the client side, the socket s is transformed into a tls socket using ssl. wrap _ socket. this returns an ssl socket that is tied to the context, its settings and certificates.. the connect ( ) method does two things at a time : open the tcp connection and start the tls handshake. on the server side, things are different as the tcp socket used for communication is created only after accept ( ). at point 1, the client has opened the tcp connection and sent the tls client hello but not yet received the tls server hello. at point 2, the server has accepted the tcp connection but not yet started the tls handshake. it can continue with the tls handshake only after wrapping the new socket conn into
EPFL COM 407 Moodle
No question: Moodle
a tls socket sconn. this requires the server to provide its pair of keys and its certificate. the client can send data only when the handshake is completed ( at point 3 ). with https / tls1. 3, how many rtts are required before data transfer can occur? a. 1 b. 2 c. 3 d. 4 e. 0 f. i do not know go to web. speakup. info or download speakup app join room 46045 solution answer b 1 rtt for opening the tcp connection 1 rtts ( at least ) for establishing the tls session • tls 1. 3 needs at least 2 rtts before initial communication starts ( assuming no packet loss! ) • can achieve 0 - rtt when resuming a previous connection, if tcp fast - open is also used, but at the cost of certain security properties ( rfc 8446 ) tls 1. 3 client tls 1. 3 server clienthello cipher suite, key share serverhello cipherspec, server certify, key share, finished application data syn tag in tcp option get / hello. htm syn ack server data ack many thanks for your feedback! things to fix in lectures • “ everything is nice and the labs are interesting, but i find the order of the topics in the course to be quite strange ; first something general about all layers, then ip, then mac, then i guess we return to
EPFL COM 407 Moodle
No question: Moodle
higher layers? ” • “ and also, the structure of the course is very messy. goes from ip layer to mac layer to ipv4 to ipv6 to ip layer again like uehh ” • “ i think that the course material lack of structure, informations is thrown in a sense i don't understand. ” • “ quizzes don't explain the solutions or no hint, i don't understand the point of this. ” • “ one concern that i have : the first slide of " the mac layer " lecture has a political message, which, i think, is not good for a safe learning environment. ” things to fix in labs • “ lab1 felt significantly longer & more challenging than lab0, was a bit of a headache. ” • “ labs are a bit long ”, • “ labs are okay, even tho they are a bit long ” count for ~ 50 % of the grade and the course has 8 credits start doing the labs early! • “ … sometimes some lab questions can be confusing ” • good course, the lab questions can be ambiguous at time will do our best to fix this do not hesitate to ask for clarifications
EPFL COM 407 Moodle