dosdbell.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include "dosdbell.h"

Include dependency graph for dosdbell.c:

Go to the source code of this file.

Functions

 main (int argc, char **argv)
void set_Topology (FILE *filer)
void TCL_Write_Agents (FILE *)
void TCL_Write_Connections (FILE *)
void TCL_Write_DDOS_Agent (FILE *)
void TCL_Write_Final (FILE *)
void TCL_Write_Initial (FILE *)
void TCL_Write_Nodes (FILE *)

Variables

float bn_bw
float bn_delay
double bw
double DDOS_start_time
int diameter
double finish_time
int pack_size
double TCP_start_time
Topology topo


Function Documentation

main int  argc,
char **  argv
 

Definition at line 35 of file dosdbell.c.

References set_Topology(), TCL_Write_Agents(), TCL_Write_Connections(), TCL_Write_DDOS_Agent(), TCL_Write_Final(), TCL_Write_Initial(), and TCL_Write_Nodes().

00035                            {
00036   FILE *filer;
00037  
00038   if(argc !=3){
00039     printf("USAGE: %s parameter_filename tcloutput_filename\n",argv[0]);
00040     exit(0);
00041   }
00042   else{
00043     filer = fopen(argv[1],"r");
00044     set_Topology(filer);
00045     fclose(filer);
00046     filer = fopen(argv[2],"w");
00047     TCL_Write_Initial(filer);
00048     TCL_Write_Nodes(filer);
00049     TCL_Write_Connections(filer);
00050     TCL_Write_Agents(filer);
00051     TCL_Write_DDOS_Agent(filer);
00052     TCL_Write_Final(filer);
00053     fclose(filer);
00054   }  
00055 }

Here is the call graph for this function:

void set_Topology FILE *  filer  ) 
 

Definition at line 59 of file dosdbell.c.

References bn_bw, bn_delay, bw, TCP_Node_Info::delayFrom, diameter, Inet_default_no_hops(), TCP_Nodes::NoNodes, TCP_start_time, TCP_Nodes::TCPNode, Topology::TCPNodes, and topo.

Referenced by main().

00059                               {
00060   double perT, perFTP, perCBR, perV;
00061   int i;
00062   double H;
00063   double rnd;
00064   int attackNo,master;
00065   double DDOSRate;
00066   double hop;  
00067 
00068   fscanf(filer,"%d %f %f\n",&diameter,&bn_bw,&bn_delay);
00069   fscanf(filer,"%d %lf %lf\n",&topo.TCPNodes.NoNodes,&bw,&TCP_start_time);  
00070   topo.TCPNodes.TCPNode = (struct TCP_Node_Info *)malloc(topo.TCPNodes.NoNodes*sizeof(struct TCP_Node_Info));
00071 
00072   for(i=0;i<topo.TCPNodes.NoNodes;i++){
00073     
00074     /* Based on the topology, get the number of hops from the source to destination.
00075        Since a dumbbell has a minimum of three hops, the number of hops returned 
00076        should be greater than 3 
00077     */ 
00078 
00079     do{
00080       topo.TCPNodes.TCPNode[i].delayFrom = (double) Inet_default_no_hops(diameter);
00081     }while(topo.TCPNodes.TCPNode[i].delayFrom<=3);
00082 
00083     /* Calculate the delay in for both the links */
00084     topo.TCPNodes.TCPNode[i].delayTo = ceil(drand48()*(topo.TCPNodes.TCPNode[i].delayFrom-2));
00085     topo.TCPNodes.TCPNode[i].delayFrom -= topo.TCPNodes.TCPNode[i].delayTo;
00086     
00087     // Maximum delay between the start of all sources 
00088     rnd = ((double)(drand48()*TCP_start_time));
00089     topo.TCPNodes.TCPNode[i].startTime = rnd;
00090   }
00091 
00092   fscanf(filer,"%d %lf %d %d %lf\n",&topo.CBRTraffic.NoAttackers,&topo.CBRTraffic.DDOSRate,&pack_size,&master,&DDOS_start_time); 
00093   CBRTrafficInet(diameter,topo.CBRTraffic.NoAttackers, master, topo.CBRTraffic.DDOSRate, &topo.CBRTraffic.DDOSTraffic);
00094   if(master==0)
00095     topo.CBRTraffic.master = NoMaster;
00096   else
00097     topo.CBRTraffic.master = Master;
00098   topo.CBRTraffic.MaxTime = topo.CBRTraffic.DDOSTraffic.Events[topo.CBRTraffic.DDOSTraffic.NoEvents-1].delay;
00099   fscanf(filer,"%lf\n",&finish_time);
00100   printf("Topology Generated Using:\n Diameter=%d BottleNeck: BW=%.3fMbps Delay=%.3fms\n \
00101 Background Traffic: TCP Nodes=%d BW=%.3lfMbps Starttime=%.1lfs\n \
00102 Dos Traffic       : Attacker= %d BW=%.3lfMbps Starttime=%.1lfs\n \
00103 PacketSize=%dB  Master = %d  Finishtime = %.1lfs\n", \
00104      diameter,bn_bw,bn_delay,topo.TCPNodes.NoNodes,bw,TCP_start_time, \
00105      topo.CBRTraffic.NoAttackers, \
00106          topo.CBRTraffic.DDOSRate, DDOS_start_time,pack_size,master,finish_time);
00107 }

Here is the call graph for this function:

void TCL_Write_Agents FILE *   ) 
 

Definition at line 149 of file dosdbell.c.

References TCP_Nodes::NoNodes, TCP_Node_Info::startTime, TCP_Nodes::TCPNode, Topology::TCPNodes, and topo.

Referenced by main().

00149                                   {
00150   int i;
00151   double time;
00152 
00153   fprintf(filew, "for {set i 0} {$i < %d} {incr i} { \n    \
00154 set TCPSendAg($i) [new Agent/TCP] \n  \
00155 $ns attach-agent $TCPSend($i) $TCPSendAg($i) \n     \
00156 set TCPSendTraffic($i) [new Application/FTP] \n     \
00157 $TCPSendTraffic($i) attach-agent $TCPSendAg($i) \n   \
00158 set TCPRecvAg($i) [new Agent/TCPSink] \n    \
00159 $ns attach-agent $TCPRecv($i) $TCPRecvAg($i) \n   \
00160 $ns connect $TCPSendAg($i) $TCPRecvAg($i) \n  \
00161 $TCPSendAg($i) set class_ 1 \n}\n\n",topo.TCPNodes.NoNodes);
00162 
00163   fprintf(filew,"\n\n\n");
00164 
00165   for(i=0;i<topo.TCPNodes.NoNodes;i++){
00166     fprintf(filew,"$ns at %lf \"$TCPSendTraffic(%d) start\"\n",topo.TCPNodes.TCPNode[i].startTime,i);
00167   }
00168   fprintf(filew,"\n\n");
00169 }

void TCL_Write_Connections FILE *   ) 
 

Definition at line 134 of file dosdbell.c.

References bn_delay, bw, TCP_Node_Info::delayFrom, TCP_Node_Info::delayTo, TCP_Nodes::NoNodes, TCP_Nodes::TCPNode, Topology::TCPNodes, and topo.

Referenced by main().

00134                                        {
00135   int i;
00136   for(i=0;i<topo.TCPNodes.NoNodes;i++){
00137     fprintf(filew,"$ns duplex-link $TCPSend(%d) $BotLeft %.3lfMb %.3lfms DropTail\n",i,bw,topo.TCPNodes.TCPNode[i].delayTo*bn_delay); 
00138     fprintf(filew,"$ns duplex-link $TCPRecv(%d) $BotRight %.3lfMb %.3lfms DropTail\n",i,bw,topo.TCPNodes.TCPNode[i].delayFrom*bn_delay); 
00139   }
00140 
00141    fprintf(filew,"\n\n");
00142    fprintf(filew,"$ns duplex-link $BotLeft $BotRight %.3lfMb %.3lfms DropTail\n",bn_bw,bn_delay); 
00143    fprintf(filew,"$ns duplex-link $BotLeft $DDOSNode %.3lfMb %.3lfms DropTail\n",10*bn_bw,bn_delay);
00144    fprintf(filew,"$ns duplex-link $BotRight $Victim %.3lfMb %.3lfms DropTail\n",10*bn_bw,bn_delay);
00145    fprintf(filew,"\n\n");
00146 }

void TCL_Write_DDOS_Agent FILE *   ) 
 

Definition at line 173 of file dosdbell.c.

References bn_delay, Topology::CBRTraffic, DDOS_start_time, DDOS_Traffic_info::DDOSTraffic, flow_event::delay, DDOS_Traffic::Events, flow_event::NetCBR, DDOS_Traffic::NoEvents, pack_size, and topo.

Referenced by main().

00173                                       {
00174   int i;
00175 
00176   fprintf(filew,"\n\n");
00177   fprintf(filew,"set DDOSUDP [new Agent/UDP]\n");
00178   fprintf(filew,"$ns attach-agent $DDOSNode $DDOSUDP\n");
00179   fprintf(filew,"set DDOSTraffic [new Application/Traffic/CBR]\n");
00180   fprintf(filew,"$DDOSTraffic attach-agent $DDOSUDP\n");
00181   fprintf(filew,"set VictimAgent [new Agent/Null]\n");
00182   fprintf(filew,"$ns attach-agent $Victim $VictimAgent\n");
00183   fprintf(filew,"$ns connect $DDOSUDP $VictimAgent\n");
00184   fprintf(filew,"$DDOSUDP set class_ 2\n");
00185 
00186 
00187   fprintf(filew,"\n\n\n");
00188 
00189   DDOS_start_time*=1000;
00190   fprintf(filew,"$ns at %lf \"$DDOSTraffic set rate_ %lfMb \"\n",ceil(DDOS_start_time+topo.CBRTraffic.DDOSTraffic.Events[0].delay*bn_delay)/1000, \
00191                                        topo.CBRTraffic.DDOSTraffic.Events[0].NetCBR);
00192   fprintf(filew,"$ns at %lf \"$DDOSTraffic set packet_size_ %d \"\n",\
00193                                        ceil(DDOS_start_time+topo.CBRTraffic.DDOSTraffic.Events[0].delay*bn_delay)/1000,pack_size);
00194   fprintf(filew,"$ns at %lf \"$DDOSTraffic start\"\n",ceil(DDOS_start_time+topo.CBRTraffic.DDOSTraffic.Events[0].delay*bn_delay)/1000);
00195 
00196   for(i=1;i<topo.CBRTraffic.DDOSTraffic.NoEvents;i++){
00197     fprintf(filew,"$ns at %lf \"$DDOSTraffic set rate_ %lfMb\"\n",\
00198                                        ceil(DDOS_start_time+topo.CBRTraffic.DDOSTraffic.Events[i].delay*bn_delay)/1000, 
00199                                        topo.CBRTraffic.DDOSTraffic.Events[i].NetCBR);
00200   }
00201 
00202   fprintf(filew,"\n\n");
00203 
00204 }

void TCL_Write_Final FILE *   ) 
 

Definition at line 207 of file dosdbell.c.

References finish_time.

Referenced by main().

00207                                  {
00208   fprintf(filew,"\n\n");
00209   fprintf(filew,"set outfile [open qtrace.tr w]\n$ns trace-queue $BotLeft $BotRight $outfile\n\n\n");
00210   fprintf(filew,"$ns at %lf \"finish\"\n",finish_time);
00211   fprintf(filew, "$ns run\n");
00212 }

void TCL_Write_Initial FILE *   ) 
 

Definition at line 109 of file dosdbell.c.

Referenced by main().

00109                                    {
00110   fprintf(filew, "set ns [new Simulator]\n\n\n");
00111   /* Incase we need nam support */
00112   //fprintf(filew, "set nf [open out.nam w]\n");
00113   //fprintf(filew, "$ns namtrace-all $nf\n\n\n");
00114   //fprintf(filew, "proc finish {} { \n  global ns nf \n  $ns flush-trace \n  close $nf \n  exec nam out.nam & \n  exit 0 \n  }\n\n\n");
00115   /***till here***/
00116   fprintf(filew, "proc finish {} {\n  exit 0 \n  }\n\n\n");
00117 }

void TCL_Write_Nodes FILE *   ) 
 

Definition at line 120 of file dosdbell.c.

References TCP_Nodes::NoNodes, Topology::TCPNodes, and topo.

Referenced by main().

00120                                  {
00121   fprintf(filew, "for {set i 0} {$i < %d} {incr i} { \n  set TCPSend($i) [$ns node] \n  }\n\n",topo.TCPNodes.NoNodes);
00122   fprintf(filew, "for {set i 0} {$i < %d} {incr i} { \n  set TCPRecv($i) [$ns node] \n  }\n\n",topo.TCPNodes.NoNodes);
00123 
00124   
00125    fprintf(filew,"set BotLeft [$ns node] \n");
00126    fprintf(filew,"set BotRight [$ns node] \n");
00127    fprintf(filew,"set DDOSNode [$ns node] \n");
00128    fprintf(filew,"set Victim [$ns node] \n");
00129 
00130    fprintf(filew,"\n\n");
00131 }


Variable Documentation

float bn_bw
 

Definition at line 33 of file dosdbell.c.

Referenced by set_Topology().

float bn_delay
 

Definition at line 32 of file dosdbell.c.

Referenced by set_Topology(), TCL_Write_Connections(), and TCL_Write_DDOS_Agent().

double bw
 

Definition at line 30 of file dosdbell.c.

Referenced by CBQClass::command(), set_Topology(), and TCL_Write_Connections().

double DDOS_start_time
 

Definition at line 28 of file dosdbell.c.

Referenced by TCL_Write_DDOS_Agent().

int diameter
 

Definition at line 26 of file dosdbell.c.

Referenced by set_Topology().

double finish_time
 

Definition at line 29 of file dosdbell.c.

Referenced by TCL_Write_Final().

int pack_size
 

Definition at line 31 of file dosdbell.c.

Referenced by TCL_Write_DDOS_Agent().

double TCP_start_time
 

Definition at line 27 of file dosdbell.c.

Referenced by set_Topology().

struct Topology topo
 

Definition at line 25 of file dosdbell.c.

Referenced by set_Topology(), TCL_Write_Agents(), TCL_Write_Connections(), TCL_Write_DDOS_Agent(), and TCL_Write_Nodes().


Generated on Tue Mar 6 16:52:10 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6