Design - PowerPoint PPT Presentation

About This Presentation
Title:

Design

Description:

malloc() and free() or new() and delete() can write a simple memory ... Linux Kernel Source Code 2.4.18. Lecture Notes from T. Sridhar. ( Available on Internet) ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 21
Provided by: ccd62
Category:
Tags: code | design | free | source

less

Transcript and Presenter's Notes

Title: Design


1
Design Development of Protocol Stack with Linux
  • Bharat Joshi
  • Infosys Technologies Ltd
  • (bharat_joshi_at_infosys.com)

2
Agenda
  • Protocol Protocol Stack.
  • Why Design?
  • Designing a Protocol Stack.
  • Development with Linux.
  • References

3
Protocol Protocol Stack
  • A Protocol is an agreement between communicating
    parties on how communication is to proceed.
  • A list of protocols used by a certain system ,one
    protocol per layer is called Protocol Stack such
    as TCP/IP, OSI etc.
  • Source Computer Networks by Tanenbaum.

4
Why Design?
  • Simplicity
  • Easy to understand and code.
  • Maintainability
  • Easy to maintain after the development.
  • Portability
  • Easily portable to other Platforms
  • Can choose the most optimized and efficient design

5
Design
  • Pre-requisites for Designing
  • Protocol Usage.
  • Where, why and how??
  • Thorough understanding of the Protocol
    functioning.
  • Must understand the RFCs, drafts or other
    available standards for this protocol stack.
  • Need to take care about the lower versions
    compatibility.
  • Identify interfaces to Layers and Modules.

6
Design Cont..
  • Task and module decomposition.
  • Protocol Functionality.
  • Configuration/Management Interface.
  • Interface to Memory Manager.
  • Interface to Timer Module.
  • Interface to Logging Mechanism.
  • Network Buffer Management.
  • Network I/O Management

7
Development
  • Protocol Functionality
  • Divide requirements into functions modules.
  • Identify the data structures.
  • Identify the Logic.
  • Implement the Logic.
  • Finite State Machine (FSM)
  • A two dimensional Matrix
  • State and Event represents the rows and columns.
  • The cell has the action to perform and the next
    state.

8
Development
  • Protocol Implementation with Linux
  • Two ways to do it.
  • Kernel Space
  • Special Memory Area reserved only for kernel is
    called Kernel Space.
  • Processes in Kernel can access Kernel User
    addresses.
  • User Space
  • Rest of the memory area is called User Space.
  • Process in User Space can access only their
    instructions and data.

9
Advantage of User Space
  • Malfunctioning of any module would not crash the
    OS.
  • Higher Portability.
  • It is easier to debug the implementation using
    normal user level debugger.
  • It is easier to distribute and install the
    modified daemons.
  • Scope for faster development.

10
Advantage of Kernel Space
  • Better access to all resources.
  • No need to copy buffer/data from Kernel Space to
    User Space or vice versa.
  • Context switches between processes in User Space
    are very expensive.

11
Development Modules
  • Configuration/Management interface
  • To configure and manage the protocol.
  • User Space
  • A Configuration file
  • A Generic CLI implementation
  • Kernel Space
  • Can use proc file system for the configuration,
    status data related to protocol. Like
    /proc/sys/net/ipv4/conf/ and /proc/net/igmp

12
Modules Cont..
  • Interface to Memory Manager
  • To allocate,free and manage the memory.
  • User Space
  • malloc() and free() or new() and delete()
  • can write a simple memory pools scheme
  • Pools based on modules/structures etc..
  • Can track the memory usage per pool/structure
    type.
  • Kernel Space
  • __get_free_pages() in mm/page_alloc.c
  • Kmalloc() kfree() in mm/slab.c
  • vmalloc()/vfree() in mm/vmalloc.c

13
Modules Cont..
  • Interface to Timer Module
  • User Space
  • Need to write a timer management module
  • Can use select(),hardware interrupt alarm() and
    OS dependent timer like setitimer() for linux.
  • Kernel Space
  • Kernel timer management is available for use.
  • add_timer(), del_timer(), mod_timer() in
    kernel/timer.c

14
Modules Cont..
  • Interface to Logging Mechanism
  • User Space
  • Can write your own logging implementation.
  • Must define the priority or levels.
  • Can use syslog() function provided by Linux.
  • Own implementation can be used for debugging
    during development.
  • Kernel Space
  • printk() is used to do logging in the kernel.
  • Excessive logging may slow down the kernel.
  • kernel/printk.c

15
Modules Cont..
  • Network buffer management
  • Copying of data must be minimized.
  • User Space
  • Copy the data from one layer to the other.
  • Can allocate memory for the whole packet and than
    keep inserting data on different layers.
  • Can write a buffer management scheme.
  • Kernel Space
  • Linux provide sk_buff network buffers to carry
    data from one layer to the other.
    net/core/skbuff.c

16
Modules Cont..
  • Network I/O Management
  • To receive packets from the network.
  • User Space
  • Can use raw/packet socket or libpcap library.
  • Kernel Space
  • Subscribe to Lower and Higher layers.
  • inet_add_protocol() can be used to add a
    protocol.
  • Need to write receive handler and other
    supporting functions.
  • Refer to PIM implementation. net/ipv4/ipmr.c

17
Development
  • OS independent Code
  • Define interfaces between protocol and different
    modules.
  • Just need to change the code in modules.
  • Have OS specific code into one module.
  • Use Platform Flags (if) in the code.
  • User Space code into Kernel-Space
  • User-Space Module interfaces APIs similar to
    kernel space function calls.

18
References
  • Linux Kernel Source Code 2.4.18
  • Lecture Notes from T. Sridhar.
    (Available on Internet)
  • IGMP Implementation.
  • www.google.com

19
Thank You!
  • bharat_joshi_at_infosys.com

20
Finite State Machine
  • Example of a Finite State Machine
Write a Comment
User Comments (0)
About PowerShow.com