packetC Programming

Book description

This book introduces the tools you'll need to program with the packetC language

packetC speeds the development of applications that live within computer networks, the kind of programs that provide network functionality for connecting "clients" and "servers" and "clouds." The simplest examples provide packet switching and routing while more complex examples implement cyber security, broadband policies or cloud-based network infrastructure.

Network applications, such as those processing digital voice and video, must be highly scalable, secure and maintainable. Such application requirements translate to requirements for a network programming language that leverages massively-parallel systems and ensures a high level of security, while representing networking protocols and transactions in the simplest way possible.

packetC meets these requirements with an intuitive approach to coarse-grained parallelism, with strong-typing and controlled memory access for security and with new data types and operators that express the classic operations of the network-oriented world in familiar programming terms.

No other language has addressed the full breadth of requirements for tractable parallelism, secure processing and usable constructs. The packetC language is growing in adoption and has been used to develop solutions operating in some of the world's largest networks.

This important new language, packetC, has now been successfully documented in this book, in which the language's authors provide the materials and tools you'll need in a readable and accessible form.

What you'll learn

This book is the primary document specifying the language from a developer's point of view and act as the formal language user's guide. It covers:

  • How to program applications in packetC.

  • The parallel programming model of packetC

  • Deviations from C99 and the unique aspects of packetC

  • How to leverage existing C code and the applicability of the C standard libraries

Who this book is for

packetC Programming is written for a wide variety of potential programmers. Most importantly, it's for people who need to use packetC to program for the Internet backbone. Still, knowledge of the packetC language will help a much wider array of programmers who need to write effective code that will be optimized for the cloud and work effectively and efficiently through complex network structures. Finally, readers will learn about how and why packetC is needed, and to better understand the technologies, standards and issues surrounding the 'net. If you really want to understand this level of programming, this book is a must-have!

Table of contents

  1. Title
  2. Contents at a Glance
  3. Contents
  4. About the Authors
  5. Acknowledgments
  6. Introduction
    1. Scope
    2. Organization
  7. Part I: packetC Background
    1. Chapter 1: Origins of packetC
      1. Tenets of packetC
    2. Chapter 2: Introduction to the packetC Language
      1. packetC Language Design Considerations
      2. packetC Language Similarities
      3. Virtual Machine—packetC Behavior
      4. Digging a Little Deeper into packetC vs. C
      5. Case Sensitivity and Identifiers
      6. Object Orientation and Control Flow
      7. Memory Layout
      8. Summary
    3. Chapter 3: Style Guidelines for packetC Program
      1. Introduction to packetC Style Guidelines
      2. Naming Conventions for Variables, Types, and Functions
      3. Source Code Presentation, Indentation, and Form
      4. General Commentary on Comments
      5. File Naming and Construction Conventions
      6. Broader Coding Style Guideline Tips and Techniques
    4. Chapter 4: Construction of a packetC Program
      1. packetC and Parallelism
      2. packetC Modules: Three Kinds of Compilation Units
      3. Three Kinds of Scope
      4. Module Structure and Scopes
      5. Graphical Representation of Scope Linkage
      6. Run time Environment Data and Predefined Types
    5. Chapter 5: Variables: Identifiers, Basic Scalar Data Types, and Literals
      1. Classic Data Types
      2. Identifiers and a Few Fundamentals
      3. Basic Scalar Types
      4. Literals
      5. Integral Type Literals
      6. Network Literals
      7. String Literals
      8. Character Literals
      9. Network Byte Order
      10. Unsupported Types
  8. Part II: Language Reference
    1. Chapter 6: Data Initialization and Mathematical Expressions
      1. Data Initialization, Expressions, and Operators
      2. Variable and Constant Declarations
      3. Variable and Constant Initialization
      4. Classic C Expressions and Operators
      5. Operators
      6. Associativity
      7. Multiplicative Operators
      8. Additive Operators
      9. Relational Operators
      10. Equality Operators
      11. Assignment Operators
      12. Logical AND Operator
      13. Logical OR Operator
      14. Bitwise AND Operator
      15. Bitwise Exclusive OR (XOR) Operator
      16. Bitwise Inclusive OR Operator
      17. Bitwise Shift Operator
      18. Unsupported Operators
    2. Chapter 7: Functions
      1. Function Constructs
      2. Parameter Passing Modes
      3. Inlining
      4. Function Parameter and Return Types
      5. Function Return Statements
    3. Chapter 8: packetC Data Type Fundamentals
      1. Data Type Fundamentals
      2. Type Compatibility, Conversions, and Casts
      3. Type Promotions, Conversions, and Implicit Casting
    4. Chapter 9: C-Style Data Types
      1. Enumeration Types
      2. Arrays
      3. Structures and Unions
      4. A Discussion on Container-Based Bit fields
    5. Chapter 10: Basic Packet Interaction and Operations
      1. Interaction with the Packet through Unique-to-packetC Capabilities
      2. Packet Operators
    6. Chapter 11: Selection Statements
      1. Covering packetC Basic Control Statements
      2. Compound Statement
      3. Conditional Expressions
      4. Chapter 12: Loops and Flow Control
        1. Control Statements
      5. Chapter 13: Exception Handling
        1. Exception Handling in packetC
        2. Try-Catch-Throw Statements (Error Handling)
        3. System-Defined Response
        4. Errors Section from cloudshield.ph
        5. Simple Program Flow with Try-Catch-Throw Implemented
      6. Chapter 14: packetC Database Types and Operations
        1. Database Declarations
        2. Databases and Masking
        3. Database Limitations and Padding
        4. Database Records and Elements
        5. Masks
        6. Database Subscripting Operator
        7. Database Delete
        8. Database Insert
        9. Database Match
        10. Operator Invocations
        11. Example Database Application
        12. Example Database Application (ACL)
      7. Chapter 15: packetC Search Set Types and Operations
        1. Searchsets in packetC for Unstructured Content Analysis
        2. Searchsets
        3. Searchset Declarations
        4. Constant Searchsets and Sizes
        5. Null Termination Issues
        6. Match Operator
        7. Find Operator
        8. Regex Specifier
        9. Interaction of packetC Pre-Processor with Regular Expressions
        10. General Search Set Usage, Operation, and Mechanics
        11. Searchset Example Application
      8. Chapter 16: Reference Type and Operation
        1. References in packetC
        2. References
        3. Reference Operators
      9. Chapter 17: Semaphores in packetC
        1. Locking and Unlocking
        2. Lock and Unlock Operators
        3. Using Lock and Unlock to Perform a Global Malloc() and Free()
      10. Chapter 18: Packet Information Block and System Packet Operations
        1. Shared Definitions
        2. Packet ($PACKET pkt)
        3. Packet Information Block ($PIB pib)
        4. System Information ($SYS sys)
        5. TCP/IP Stack Decode for pib Layer Offset Calculations
        6. Example cloudshield.ph Include File
      11. Chapter 19: Descriptor Type and Operations
        1. packetC Descriptor Types
        2. Descriptors
        3. Impacts on Performance
    7. Part III: Developing Applications
      1. Chapter 20: Control Plane and System Interaction
        1. Control Plane Interaction
        2. Alerts and Information Logging
        3. Messages to Control Plane ($MSG_TYPE)
        4. Messages Portion of cloudshield.ph
      2. Chapter 21: packetC Pre-Processor
        1. #define
        2. #include
        3. #ifdef
        4. #ifndef
        5. #endif
        6. #if
        7. #else
        8. #elif
        9. #undef
        10. #error
        11. #line
        12. #file
        13. defined
        14. Comments in Code
        15. Typical packetC Comment Header
      3. Chapter 22: Pragmas and Other Key Compiler Directives
        1. Pragmas
        2. Implementation-Defined Pragmas
        3. Interaction of packetC Pre-Processor with Regular Expressions
      4. Chapter 23: Developing Large Applications in packetC
        1. Planning for Large Projects in packetC
        2. Things to Consider in Large Application Development
      5. Chapter 24: Construction of a packetC Executable
        1. A View into the CloudShield PacketWorks IDE Tools
      6. Chapter 25: packetC Standard Networking Descriptors
        1. Standard Include File protocols.ph Example
      7. Chapter 26: Developing for Performance
        1. Developing for Performance in packetC
        2. Counting Bits Set
        3. Simplest Computation Scenario
        4. Improving the Computational Algorithm
        5. Altering the Algorithm with Memory Use in Exchange of Processing
        6. Metadata Analysis
        7. Netflow Record Generation
        8. DDoS Trend Analysis
        9. VoIP QoS Analysis
        10. Processing Minimization
        11. Whatever You Do … Don’t Involve Other Contexts
      8. Chapter 27: Standard Libraries
        1. Assessment of C Standard Library Functions
        2. packetC Standard Libraries
        3. ascii.ph - Named Values for ASCII Characters
        4. limits.ph - A packetC Replacement For C limits.h Functionality
        5. moreprotocols.ph - Named Values For Network Protocol Field Values
        6. namedoperators.ph - Replacement for iso646.h Named Operators
        7. trojanprotocols.ph - Named Values for Port Numbers Trojan Network Protocol Operate On
    8. Part IV: Industry Reprints
      1. REPRINT 1: packetC Language for High Performance Packet Processing
      2. REPRINT 2: A Paradigm for Processing Network Protocols in Parallel
      3. REPRINT 3: Dynamically Accessing Packet Header Fields at High-speed
      4. REPRINT 4: packetC Language and Parallel Processing of Masked Databases
      5. REPRINT 5: Packet Content Matching with packetC Searchsets
      6. REPRINT 6: References for Run-time Aggregate Selection with Strong Typing
      7. REPRINT 7: Portable Bit Fields in packetC
      8. REPRINT 8: packet Field and Bitfield Allocation Order
      9. REPRINT 9: Managing Heterogeneous Architectures for High-speed Packet Processing
    9. APPENDIX A: Reference Tables
      1. Keywords
      2. ASCII Table with Decimal to Hexadecimal Conversion
      3. Bits and Bytes
      4. TCP/IP and OSI Model Network Stack
      5. Header Formats
      6. Basic Ethernet II Header Format
      7. Ethernet Header with VLAN Tag (802.1Q) Format
      8. Ethernet Header with Stacked VLAN Tags (802.1Q in Q) Format
      9. IPv4 Header
      10. IPv6 Header
      11. TCP Header
      12. UDP Header
      13. ICMP Header
    10. APPENDIX B: Open Systems Vendors for packetC
      1. Software
      2. Hardware
      3. Reference
    11. APPENDIX C: Glossary
      1. PacketC Language Terms
      2. Networking Terms
  9. Index

Product information

  • Title: packetC Programming
  • Author(s): Peder Jungck, Ralph Duncan, Dwight Mulcahy
  • Release date: December 2011
  • Publisher(s): Apress
  • ISBN: 9781430241584