TCP for OMNeT++ Roland Bless Mark Doll Institute of Telematics University of Karlsruhe, Germany Bless/Doll WSC 2004 1
Overview Motivation Introduction OMNeT++ & TCP Concept for integration Implementation problems Evaluation results Summary & Outlook www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 2/21
Motivation I Investigation of Network Protocols Different parameter settings Extreme conditions Scaling properties Difficult in testbeds Simulation Expressive simulation results Require good emulation of real world behavior Protocols we design use or modify TCP/IP stack Emulation of network oriented layers Transport (TCP) Internet (IP) Network Access (Ethernet) Need TCP/IP stack implementation for simulation www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 3/21
Motivation II Problem no validated (tested to be compliant to the standard) TCP/IP implementation for OMNeT++ Possible solutions Choose other simulator ns-2 OPNET New implementation Revision of the existing implementation (i. e. from Communications Engineering Institute, Karlsruhe) full featured? validated? Re-use an existing real world implementation Linux FreeBSD www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 4/21
OMNeT++ Discrete event simulator hierarchically nested modules communicate with messages through channels Written in C++ Complete source code publicly available Free for academic use Commercial version OMNEST TM Advantages Very well structured Highly modular Not limited to network protocol simulations (i. e. like ns-2) Disadvantages Relatively young: 1997 first public release Few simulation models www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 5/21
OMNeT++ Hierarchical nested modules system module channels compound module NED NED simple modules C++ C++ C++ input gates output gates system module top level module simple modules C++ NED description of interface: parameters and gates compound modules NED only: parameters, gates and connections unlimited nesting www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 6/21
TCP Transmission Control Protocol Transport layer protocol (layer 4) connection-oriented, reliable, stream-oriented flow control, congestion control Influenced by round trip time, packet loss Most of today s internet traffic via TCP TCP behavior influences behavior of many protocols & applications API: BSD socket interface (socket type: stream) FreeBSD s TCP/IP implementation source code freely available well structured code (not as optimized as Linux) 4.x BSD was starting point for many other implementations MAC OS X essentially is FreeBSD (with additions like Aqua) Network research was and still is based on (Free)BSD Mobile IPv6, Protocol Independent Multicast, www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 7/21
FreeBSD vs. OMNeT++ Function Call One TCP stack per host Multi-tasking, threads, functions are interruptible Messages Many TCP stacks per simulation Messages must be processed in one pass www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 8/21
Protocol stack of FreeBSD Application Layer application Transport Layer rcv_buff tcp_input() snd_buff tcp_output() Network Layer swi_net() ip_input() ip_forward() ip_output() Network Access Layer ether_input() device driver ether_output() device driver TX interrupt RX interrupt www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 9/21
chost concept I Gates to Applications (cappl) Multiplexer In/Out Gate SimpleModule Gates to LANs or other Hosts (cmedium or chost) www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 10/21
chost concept II Applikation rcv_buff snd_buff swi_net() tcp_input() ip_input() ip_forward() tcp_output() ip_output() Multiplexer + =? ether_input() ether_output() Gerätetreiber RX-Interrupt Gerätetreiber TX-Interrupt www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 11/21
chost concept III Multiplexer Applikation rcv_buff snd_buff tcp_input() tcp_output() ip_input() ip_forward() ip_output() swi_net() ether_input() Gerätetreiber RX-Interrupt ether_output() Gerätetreiber TX-Interrupt In/Out Gate SimpleModule www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 12/21
OMNeT++ classes chost Simulated host with TCP/IP cmedium Emulates broadcast medium (Ethernet LAN) Allows for chost address autoconfiguration cappl Source/sink (sample application) croute Generates routing tables www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 13/21
cappl cappl & croute Uses socket interface to chost Demonstrates usage of message based socket interface Can accept and initiate connections Full duplex croute Manual routing table set up Time consuming Configuration Errors Often routing table details unimportant Use croute class to generate routing tables for FreeBSD Utilizes standard OMNeT++ class ctopology Computes shortest path (Dijkstra) www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 14/21
chost <-> FreeBSD I TCP stacks must be independent No global and static variables possible Access via C macro #define D ( (struct private_data*)bsd_data) Usage: replace xyz with D->xyz FreeBSD: same identifier for types and variables i. e. ifnet Simple substitution of xyz with macro impossible However changes to FreeBSD source minimal Avoid bugs Allow for easier re-porting of future FreeBSD releases www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 15/21
chost <-> FreeBSD II Switch to BSD via C macro (simplified) #define ENTER_BSD() { \ } bsd_data=data; \ host_class=this; \ host_id=id(); \ Calling BSD functions from OMNeT++ Enclose call by ENTER_BSD and LEAVE_BSD Calling OMNeT++ functions from BSD OMNeT++ function exported with C calling conventions Function then uses host_class to access instance data www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 16/21
Technical Problems Include files FreeBSD and OMNeT++ (host OS) need their own include files i. e. struct sockaddr and struct sockaddr_in Socket interface Function calls replaced by OMNeT++ messages read(), write(), listen(), connect(),... Blocking functions emulated by non-blocking + self message Memory (shared) Differences between libc of FreeBSD and host OS running OMNeT++ mbufs & mclusters mapped on malloc Timers Access to BSD ticks variable redirected to gettick_toomnet() which uses OMNeT++ s simtime() startup added individually per chost to prevent synchronization One timer for all hosts where appropriate, i. e. ip_slowtimo www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 17/21
Evaluation Memory usage per Host FreeBSD: 19 KiB + chost class + Receive-/Send buffer 64 KiB (default) per connection Run time in seconds for 1 hour of simulated time Hosts/Conn. 0 1 2 10 0.467 2.199 4.196 100 3.361 30.575 59.638 1000 64.233 434.724 823.019 Time consuming insertion/removal of timer events in OMNeT++ s event queue (heap) www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 18/21
Summary First validated and complete TCP implementation for OMNeT++ Realized by adapting FreeBSD s TCP/IP stack Message-based implementation of the BSD socket interface Routing module automates routing table setup www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 19/21
Outlook Performance hide certain messages in OMNeT++ dedicated timer module for OMNeT++ Improve adaption process Perl script/parser for (semi)automatic global variable replacement Support further protocols IPv6 System call interface for routing deamons Mobile IPv6 patches www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 20/21
Thanks to Jérôme Freilinger (diploma student) Thank You for your attention! www.tm.uka.de Bless/Doll WSC 2004 TCP for OMNeT++ 21/21