packetc_programming.pdf

(16056 KB) Pobierz
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
1154794402.015.png 1154794402.016.png 1154794402.017.png 1154794402.001.png 1154794402.002.png 1154794402.003.png 1154794402.004.png 1154794402.005.png
Contents at a Glance
Contents ...................................................................................................................... v
About the Authors.................................................................................................... xvi
Acknowledgments .................................................................................................. xvii
Introduction ............................................................................................................. xix
PART I: packetC Background ...................................................................................... 1
CHAPTER 1: Origins of packetC .............................................................................. 3
CHAPTER 2: Introduction to the packetC Language................................................ 9
CHAPTER 3: Style Guidelines for packetC Program .............................................. 17
CHAPTER 4: Construction of a packetC Program.................................................. 39
CHAPTER 5: Variables: Identifiers, Basic Scalar Data Types, and Literals ........... 53
PART II: Language Reference.................................................................................... 63
CHAPTER 6: Data Initialization and Mathematical Expressions ........................... 65
CHAPTER 7: Functions .......................................................................................... 87
CHAPTER 8: packetC Data Type Fundamentals .................................................... 93
CHAPTER 9: C-Style Data Types.......................................................................... 103
CHAPTER 10: Basic Packet Interaction and Operations ..................................... 119
CHAPTER 11: Selection Statements .................................................................... 125
CHAPTER 12: Loops and Flow Control ................................................................ 129
CHAPTER 13: Exception Handling ....................................................................... 133
CHAPTER 14: packetC Database Types and Operations...................................... 139
CHAPTER 15: packetC Search Set Types and Operations ................................... 151
CHAPTER 16: Reference Type and Operation...................................................... 159
CHAPTER 17: Semaphores in packetC ................................................................ 171
CHAPTER 18: Packet Information Block and System Packet Operations ........... 175
iii
1154794402.006.png 1154794402.007.png 1154794402.008.png 1154794402.009.png 1154794402.010.png 1154794402.011.png
CONTENTS!4!',!.#%
CHAPTER 19: Descriptor Type and Operations ................................................... 205
PART III: Developing Applications .......................................................................... 215
CHAPTER 20: Control Plane and System Interaction .......................................... 217
CHAPTER 21: packetC Pre-Processor ................................................................. 223
CHAPTER 22: Pragmas and Other Key Compiler Directives................................ 233
CHAPTER 23: Developing Large Applications in packetC .................................. 237
CHAPTER 24: Construction of a packetC Executable .......................................... 245
CHAPTER 25: packetC Standard Networking Descriptors ................................. 263
CHAPTER 26: Developing for Performance ......................................................... 281
CHAPTER 27: Standard Libraries ........................................................................ 287
PART IV: Industry Reprints ..................................................................................... 309
REPRINT 1: packetC Language for High Performance Packet Processing ......... 311
REPRINT 2: A Paradigm for Processing Network Protocols in Parallel.............. 319
REPRINT 3: Dynamically Accessing Packet Header Fields at High-speed.......... 329
REPRINT 4: packetC Language and Parallel Processing of Masked Databases . 335
REPRINT 5: Packet Content Matching with packetC Searchsets........................ 345
REPRINT 6: References for Run-time Aggregate Selection with Strong Typing . 355
REPRINT 7: Portable Bit Fields in packetC ......................................................... 363
REPRINT 8: packet Field and Bitfield Allocation Order ....................................... 371
REPRINT 9: Managing Heterogeneous Architectures for High-speed Packet
Processing .............................................................................. 377
APPENDIX A: Reference Tables........................................................................... 383
APPENDIX B: Open Systems Vendors for packetC .............................................. 395
APPENDIX C: Glossary ........................................................................................ 405
INDEX ...................................................................................................................... 419
iv
1154794402.012.png
Introduction
This book covers a vast array of information related to packetC. It is a complete language reference and
contains background information on many unique parts of packetC. As packetC shares much of its
grammar with C, the book focuses on being an instructional language reference and not a general C
programming introduction, since extensive texts exist on that topic. Focusing the unique aspects of
packetC, this book explores many of the use cases that drove the new language features present in
packetC. Throughout this book, you will find sections that will highlight why deviations were made for
security, parallel-processing, or network rationales. While the book is instructional, chapters are
organized in such a way that they can serve as a reference tool well beyond the initial learning of the
language.
Scope
What this book doesn’t cover:
This book is not an introduction to programming or learning basic fundamentals
of C, or even aspects of object orientation. A programmer is expected to have used
C or C++ and be well-versed in general computer science.
The concepts behind networking, network protocols, packets, and the way in
which they work is a presumed skill-set of the reader. These are requisite to an
understanding of the aspects of the language discussed in this book.
The basic concepts around parallel processing and how multi-core processing
systems have evolved is presumed to be at least casually understood by packetC
developers.
This is neither a tutorial on CloudShield systems nor how to use the CloudShield
PacketWorks IDE that integrates the first packetC compiler and debuggers.
While some references to workflow in an IDE are made showing step-by-step how
to create, compile, and load, these are confined to limited chapters focusing on
examples aiding the developer with tool-chain aspects important to packetC. No
specific references to a user manual or specific development environment releases
are provided. In this way, we keep this book focused on the language and not a
specific development environment release.
C99 defines many specific constraints of the C language. We presume that C99 can
be referenced elsewhere and that the user is generally familiar with this modern
variant of C. packetC Programming will address the deviations and stress unique
points that differ between releases, but it will not focus on teaching it.
xix
1154794402.013.png
Zgłoś jeśli naruszono regulamin