Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Recitation 6 Midterm 1’s solution Project 2 IP Forwarding CIDR.

Similar presentations

Presentation on theme: "1 Recitation 6 Midterm 1’s solution Project 2 IP Forwarding CIDR."— Presentation transcript:

1 1 Recitation 6 Midterm 1’s solution Project 2 IP Forwarding CIDR

2 Project 2 Environment –1 tracker, 2 seeds and 2 leeches Expand your project 1 –Download from multiple peers. –Be able to upload. –Be able to accept incoming connections. –Connect to 2 leeches and upload your available pieces to leeches. 2

3 Protocol State machine: –am_choking: this client is choking the peer –am_interested: this client is interested in the peer –peer_choking: peer is choking this client –peer_interested: peer is interested in this client bitfield: SEND+RECV keep-alive: is 0 choke: unchoke: interested: not interested: have: request: SEND+RECV piece: SEND+RECV 3

4 Notes After handshake, seeds should send the bitfield with “all of bit 1s”. Leeches may not send “bitfields” or bitfield with “all of bit 0s” After downloading & verifying a piece, your program should advertise the piece by sending a “have” to peers. Don’t send a “have” to peers having it already. 4

5 5 Sample Question: Subnetting Consider a conventional class B network. A network administrator decides to give all subnets in the class B network a sub-net mask of (5 points) How many sub-nets can the administrator use if all sub-nets use this mask? (5 points) How many hosts are possible on each sub-net? (5 points) The administrator just heard that she only needs 16 sub-nets for the class B address. What sub-net mask maximizes the number of hosts on each sub-net?

6 6 ARP (from IP add. to MAC add.) Application doesn’t know MAC address !!! –Application works with IP address: ssh ping Recall: Ethernet Frame Structure “A” knows IP X of “C”, how can A send an ethernet frame to C? How does A know MAC of C?? HUB BACD Send broadcast MAC A -> FF: …FF, Type=ARPWho has IP X ???? MAC C -> MAC A, type=ARPHey guy, I have IP X !!! MAC A-> MAC C, type=IPIP packet MAC Dest. addressMAC Source address TypeDATA ….CRC

7 7 Multi-Hop Forwarding Example N2N3 X sends an IP packet to Y?? N1 R1R2 x Y 1.X-> R1a a a bb 1. X sends to its gateway (IP of R1a) MAC X -> MAC R1aIP X -> IP YDATA 2. R1 forwards the packet to R2 MAC R1b -> MAC R2aIP X -> IP YDATA 3. R2 forwards the packet to Y MAC R2b -> MAC YIP X -> IP YDATA 2. R1b->R2a 3. R2b->Y

8 8 Multi-Hop Forwarding Example N2N3N4 Actual routing table contains IP addresses, Flags indicating type of entries, net mask etc. Routing table @ R2 N1 R1R2R3 N1 N2 N3 N4 R1 Deliver directly (ARP) R3 DestNext hop

9 9 IP forwarding ROUTING TABLE AT A ROUTER: Destination Gateway Genmask Flags Metric Ref Use Iface A255.255.255.128 U 0 0 0 eth0 B U 0 0 0 eth1 U 0 0 0 lo UG 0 0 0 eth0 (default) UG 0 0 0 eth0 Question1: Packet with dest IP =, what is the next-hop (gateway)? For each entry: if ( AND == ) { choose the next hop = the corresponding gateway; break; } Question2: How many networks does the router connect to?

10 10 Network programming in Java TCP/IP stack Application Protocol Transport Protocols (UDP and TCP) Application Layer Transport Layer Network Layer Host-to- Net Layer Host AHost B Application Layer Transport Layer Network Layer Host-to- Net Layer Network Layer Host-to- Net Layer Network Layer Host-to- Net Layer IP Data TCP/UDP header Data TCP/UDP header IP header

11 11 Sample Question: IP Forwarding The following table is a routing table using CIDR. Address bytes are in hexadecimal. The notation “/12” defines the length of the mask in bits. For example, for C4.50.0.0/12, the mask is 12 bits, or FF.F0.0.0 in hexadecimal notation. For each of the following destination IP addresses (in hexadecimal), state what the next hop will be by using the routing table above (2 points each): 1.C4.4B.31.2E : 2.C4.5E.05.09 : 3.C4.4D.31.2E : 4.C4.5E.03.87 : 5.C4.5E.7E.12 : 6.C4.5E.D1.02 : Dest.Next Hop C4.5E.2.0/23A C4.5E.4.0/22B C4.5E.C0.0/19C C4.5E.40.0/18D C4.4C.0.0/14E C0.0.0.0/2F defaultH

12 12 Reducing Routing Table Size service provider ….. ….. Routing table Without CIDR : service provider ….. Routing table With CIDR:

13 13 The company X has 4 offices, each office has one subnet. All subnets connect to a router (Router 1 in the figure). This router connects to the ISP router. The subnets are described in the figure. Sample Question: CIDR

14 14 Sample Question: CIDR (cont.) A. Fill out the routing table for the router 1: DestinationNetmaskNexthopInterface Eth1 Eth2 Eth3 Eth4

15 15 Sample Question: CIDR (cont.) B. Assume that the ISP router forwards to the router 1 an IP packet that has the destination address Which subnet will the packet be forwarded to? Based on the routing table in (1), what is the interface that the router 1 will forward the packet through? C. Assume that the ISP router implement CIDR. What is the routing entry for all subnets of the company X in the routing table of the ISP router? DestinationNetmaskNexthopInterface Eth1

Download ppt "1 Recitation 6 Midterm 1’s solution Project 2 IP Forwarding CIDR."

Similar presentations

Ads by Google