15-441 Spring 06 Project 2: Network Layer Mike Cui.

Slides:



Advertisements
Similar presentations
CST Computer Networks NAT CST 415 4/10/2017 CST Computer Networks.
Advertisements

CPSC Network Layer4-1 IP addresses: how to get one? Q: How does a host get IP address? r hard-coded by system admin in a file m Windows: control-panel->network->configuration-
CMPE 150- Introduction to Computer Networks 1 CMPE 150 Fall 2005 Lecture 25 Introduction to Computer Networks.
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
CP476 Internet Computing TCP/IP 1 Lecture 3. TCP / IP Objective: A in-step look at TCP/IP Purposes and operations Header specifications Implementations.
Chapter 20 Network Layer: Internet Protocol Stephen Kim 20.1.
Network Layer Packet Forwarding IS250 Spring 2010
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
11- IP Network Layer4-1. Network Layer4-2 The Internet Network layer forwarding table Host, router network layer functions: Routing protocols path selection.
Transition Mechanisms for Ipv6 Hosts and Routers RFC2893 By Michael Pfeiffer.
Internet Networking Spring 2003
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Oct 19, 2004CS573: Network Protocols and Standards1 IP: Datagram and Addressing Network Protocols and Standards Autumn
1 Chapter 4 Threads Threads: Resource ownership and execution.
IP Routing: an Introduction. Quiz
Network Layer4-1 Network layer r transport segment from sending to receiving host r on sending side encapsulates segments into datagrams r on rcving side,
Network Layer4-1 Network layer r transport segment from sending to receiving host r on sending side encapsulates segments into datagrams r on rcving side,
IP-UDP-RTP Computer Networking (In Chap 3, 4, 7) 건국대학교 인터넷미디어공학부 임 창 훈.
Gursharan Singh Tatla Transport Layer 16-May
The Transport Layer.
Network Layer4-1 NAT: Network Address Translation local network (e.g., home network) /24 rest of.
The Network Layer. Network Projects Must utilize sockets programming –Client and Server –Any platform Please submit one page proposal Can work individually.
LWIP TCP/IP Stack 김백규.
LWIP TCP/IP Stack 김백규.
1 Internet Protocol. 2 Connectionless Network Layers Destination, source, hop count Maybe other stuff –fragmentation –options (e.g., source routing) –error.
CMPT 471 Networking II Address Resolution IPv4 ARP RARP 1© Janice Regan, 2012.
TCOM 509 – Internet Protocols (TCP/IP) Lecture 04_a Transport Protocols - UDP Instructor: Dr. Li-Chuan Chen Date: 09/22/2003 Based in part upon slides.
Transport Layer: TCP and UDP. Overview of TCP/IP protocols Comparing TCP and UDP TCP connection: establishment, data transfer, and termination Allocation.
Chapter 22 Q and A Victor Norman CS 332 Spring 2014.
Chapter 4 Network Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 A note on the use of these.
1 IP : Internet Protocol Computer Network System Sirak Kaewjamnong.
Chapter 81 Internet Protocol (IP) Our greatest glory is not in never failing, but in rising up every time we fail. - Ralph Waldo Emerson.
Networks and Protocols CE Week 7b. Routing an Overview.
An initial study on Multi Path Routing Over Multiple Devices in Linux 2.4.x kernel Towards CS522 term project By Syama Sundar Kosuri.
Network Layer4-1 The Internet Network layer forwarding table Host, router network layer functions: Routing protocols path selection RIP, OSPF, BGP IP protocol.
Transport Layer3-1 Chapter 4: Network Layer r 4. 1 Introduction r 4.2 Virtual circuit and datagram networks r 4.3 What’s inside a router r 4.4 IP: Internet.
Network Layer4-1 Datagram networks r no call setup at network layer r routers: no state about end-to-end connections m no network-level concept of “connection”
CSC 600 Internetworking with TCP/IP Unit 5: IP, IP Routing, and ICMP (ch. 7, ch. 8, ch. 9, ch. 10) Dr. Cheer-Sun Yang Spring 2001.
TCP/IP Networking (2:1) Joy Kuri, Haresh Dagale, T.V.Prabhakar.
1 Requirements for Internet Routers (Gateways) and Hosts Relates to Lab 3. (Supplement) Covers the compliance requirements of Internet routers and hosts.
Department of Computer Science and Software Engineering
1 Computer Communication & Networks Lecture 19 Network Layer: IP and Address Mapping Waleed Ejaz.
1 CSE 5346 Spring Network Simulator Project.
The Internet Network layer
Data Communications and Computer Networks Chapter 4 CS 3830 Lecture 19 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 Internetworking: IP Packet Switching Reading: (except Implementation; pp )
Computer Networking Project II question/answer session October 18, 2001.
1 COMP 431 Internet Services & Protocols The IP Internet Protocol Jasleen Kaur April 21, 2016.
IP Internet Protocol. IP TCP UDP ICMPIGMP ARP PPP Ethernet.
Ch. 23, 25 Q and A (NAT and UDP) Victor Norman IS333 Spring 2015.
Packet Switch Network Server client IP Ether IPTCPData.
1 K. Salah Application Layer Module K. Salah Network layer duties.
Graciela Perera Department of Computer Science and Information Systems Slide 1 of 18 INTRODUCTION NETWORKING CONCEPTS AND ADMINISTRATION CSIS 3723 Graciela.
Introduction to Networks
The Transport Layer Implementation Services Functions Protocols
LWIP TCP/IP Stack 김백규.
IP (slides derived from past EE122 sections)
Magda El Zarki Professor, ICS UC, Irvine
Internet Control Message Protocol (ICMP)
CS 457 – Lecture 10 Internetworking and IP
Internet Control Message Protocol (ICMP)
Internet Control Message Protocol (ICMP)
IP : Internet Protocol Surasak Sanguanpong
Wide Area Networks and Internet CT1403
Issues in Client/Server Programming
Project 2 Fall 04
Chapter 4 Network Layer Computer Networking: A Top Down Approach 5th edition. Jim Kurose, Keith Ross Addison-Wesley, April Network Layer.
Review of Internet Protocols Network Layer
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
Internet Protocol version 6 (IPv6)
Presentation transcript:

Spring 06 Project 2: Network Layer Mike Cui

1 Network Layer Gets data from host A to host B –Global addressing uniquely identifies A and B –Data finds its way to host B, directly or indirectly –Don’t care how how they are connected, as long as they are. Where is host B, and how to get there?

2 Forwarding Finds host B by looking up in a forwarding table DestIF DestIF DestIF Who makes these forwarding tables?

3 Routing Finds the paths to host B Fills in forwarding tables with the “best” path How? –Static Manually set it (part 1) –Dynamic Use a routing algorithm (part 2)

4 Your Mission Implement the network layer for a simulated operating system kernel –IPv4 (RFC 791) –Relay bytes between transport and physical layers –Forward packets between hosts –Not required: fragmentation and reassembly Implement a simple routing daemon –Using OSPF protocol

5 IPv4 You must handle –Checksum –Header length –Packet length –Source and destination address –Protocol number –TTL –IP version number Your implementation need not handle –Fragmentation –Options –Multicast/broadcast –ToS

6 When You Are All Done Host routed App routed Socket Transport Network Link Physical Socket Transport Network Link Physical Socket Transport Network Link Physical

7

8 Simulator: Logical View Host App Socket Transport Network Link Physical Socket Transport Network Link Physical Socket Transport Network Link Physical

9 Simulator: Implementation Simulator Kernel App Legend (Shapes) Unix Process Unix IPC App

10 Simulator: Full Picture Socket Transport Network Link Physical Socket Transport Network Link Physical Socket Transport Network Link Physical Legend (Shapes) Unix Process Unix IPC Legend (Colors) User Kernel Network Stack

11 Link Sending a Packet Transport ip_output() Forwarding Table Interface List IP_NOROUTE ifp->if_start() Add IP header !IP_NOROUTE

12 Receiving a Packet Transport Forwarding Table Link ip_input() Interface List For me? Yes! ip_forward() No… ifp->if_start() Strip IP header Modify IP header (TTL, checksum) udp_receive()

13 Linked list of fixed-size (512 byte) buffers Why? –Dynamic, variable-sized memory allocation is expensive Takes time, function of size of heap Wastes space due to fragmentation pbuf 512

14 Inside a pbuf p_next p_nextpkt p_data p_len p_type p_flags …. Next pbuf of this packet Next packet in list of packets First byte of data in this pbuf Length of data in this pbuf There’s room to grow! User-defined p_dat

15 pbuf Chain Packet 1 Packet 2 p_len is the length of a pbuf p_pktlen() is total length of data in the packet sizeof(struct pbuf) p_nextpkt p_next

16 IP Interface When ip_input() is called… –p_data points to beginning of IP header –Strip off IP header before passing onto transport layer When ip_output() is called… –p_data points be beginning of IP payload –Prepend an IP header before handing to link layer –Can assume there’s enough room to prepend a IP header Should not need to allocate more pbufs Helper functions in pbuf.h –p_prepend, p_strip

17 Connecting to the Simulator #include Use Socket-API functions with first letter capitalized –Socket(), Bind(), Connect() … Make sure to Close() –Simulator isn’t an operating system, it doesn’t clean up after you

18 Testing Your Network Layer Use fdconfig to set up static routes Try UDP applications –unreliable-server, unreliable-client –Your P1 TFTP server (single client)

19 Simulator Internals Multithreaded implementation –System call interface User processes must register with simulator One thread to handle registration requests One thread per process to handle system calls –Network devices One thread per network device Wakes up when packet arrives What does this mean for you? –Your code will be executed by multiple threads.. –Your code must be re-entrant!

20 Concurrency Reminder What you think ticket = next_ticket++; /* 0  1 */ What really happens (in general) ticket = temp = next_ticket; /* 0 */ ++temp; /* invisible to other threads */ next_ticket = temp; /* 1 is visible */

21 Murphy's Law (Of Threading) The world may arbitrarily interleave execution –Multiprocessor N threads executing instructions at the same time Of course effects are interleaved! –Uniprocessor Only one thread running at a time... But N threads runnable, timer counting down toward zero... The world will choose the most painful interleaving –“Once chance in a million” happens every minute

22 Your Hope T0T1 tkt = tmp =n_tkt;0 ++tmp;1 n_tkt = tmp;1 tkt = tmp =n_tkt;1 ++tmp;2 n_tkt = tmp2 Final Value12

23 Your Bad Luck T0T1 tkt = tmp =n_tkt;0 0 ++tmp;1 1 n_tkt = tmp;1 n_tkt = tmp1 Final Value11 Two threads have the same “ticket” !

24 What To Do What you think MUTEX_LOCK(m); ticket = next_ticket++; MUTEX_UNLOCK(m); Now no other thread's execution of the “critical section” can be interleaved with yours

25 IP Dataflow Revisited Transport ip_output() Link ifp->if_start() ip_input()ip_forward() Two threads of execution! Problem! Link layer can only send out one packet at a time.

26 One at a Time Only one thread can send through a particular device at a time –Otherwise the device will fail and cause kernel to panic. Need mutual exclusion –Use a mutex (pthread_mutex_t) for each device –Declared in if.h, Mutex wrappers in systm.h MUTEX_LOCK(&ifp->if_mutex); ifp->start(ippkt); … MUTEX_UNLOCK(&ifp->if_mutex); Critical section! Mutex ensures that only one thread can enter at a time.

27 IP Dataflow Revisited (again) Transport Link ifp->if_start() Transport Socket Link ifp->if_start() App ip_output() Two threads can call ip_output() concurrently, that should work! Make sure it does!

28 Many at a Time More than one thread could invoke an IP layer function at the same time –Each invocation has to be independent of one another –Each invocation needs to have its own state Stack variables are independent, global variables are shared –Shared state needs to be protected

29 Debugging Multiple Threads Using gdb –info thread lists all running threads –thread n switches to a specific thread –bt to get stack trace for the current thread –Look for the function thread_name in stack trace, name of thread is in the argument “link n:i to k:j” device thread for interface i on node n to interface j on node k “user_pid” system call handling thread for user process pid.