| Unsigned int gettickcount () {
 Struct TMS
 TM;
 Return
 (Unsigned INT) times (& TM );
 }
 Unsigned int rand_long (){
 
 Unsigned int ip_addr, IP1, ip2, IP3, ip4;
 
 IP1 = rand () % 254 + 1;
 
 Ip2 = rand () % 254 + 1;
 
 IP3 = rand () % 254 + 1;
 
 Ip4 = rand () % 254 + 1;
 Ip_addr =
 (IP1 <24) + (ip2 <16) + (IP3 <8) + ip4;
 Return ip_addr;
 } Create_packet ()Generate a package
 {
 
 Int I = 0;
 
 Int J = 0;
 
 Int K = 0;
 
 Unsigned int currentt;
 
 Int counts = flowcount;
 
 Int numbytes;
 
 Socklen_t socklen = sizeof (servaddr );
 Pkts. HDR. Version =
 Htons (5 );
 Pkts. HDR. Count
 = Htons (counts );
 Currentt =
 Gettickcount ()
 ;
 
 Pkts. HDR. sysuptime = htons (currentt-2000 );
 Pkts. HDR. unix_seconds = htons (currentt/1000 );
 
 Pkts. HDR. unix_nanoseconds = htons (currentt-Pkts. HDR. unix_seconds
 * 1000 );
 
 Pkts. HDR. engine_id = (unsigned char) 11;
 
 Pkts. HDR. engine_type = (unsigned char) 1;
 
 Pkts. HDR. Reserved = (unsigned char) 1;
 For (I = 0; I <counts; I ++)
 
 {
 
 Pkts. Entry [I]. src_ip = htons (rand_long ());
 
 Pkts. Entry [I]. dst_ip = htons (rand_long ());
 
 Pkts. Entry [I]. next_hop_ip = htons (rand_long ());
 Pkts. Entry [I]. input_interface_index = htons (RAND () % 3 + 1 );
 
 Pkts. Entry [I]. output_interface_index = htons (RAND () % 3 + 1 );
 Pkts. Entry [I]. packets = htons (RAND () % 1000 + 5 );
 
 Pkts. Entry [I]. bytes = htons (RAND () % 2048 + 48 );
 Pkts. Entry [I]. start_time = htons (currentt-1500 );
 
 Pkts. Entry [I]. end_time = htons (currentt-100 );
 Pkts. Entry [I]. src_port =
 Htons (RAND () % 65533 + 1 );
 
 Pkts. Entry [I]. dst_port =
 Htons (RAND () % 65533 + 1 );
 Pkts. Entry [I]. Pad = htons (1 );
 
 Pkts. Entry [I]. Flag = htons (RAND () % 8129 );
 If (counts % 2 = 0)
 
 Pkts. Entry [I]. proto = (unsigned char) 1; // LFC
 Changed
 
 Else
 
 If (counts % 3 = 0)
 
 Pkts. Entry [I]. proto = (unsigned char) 6;
 
 Else
 
 Pkts. Entry [I]. proto = (unsigned char) 17;
 Pkts. Entry [I]. TOS = (unsigned char) 1;
 Pkts. Entry [I]. src_as = htons (RAND () % 100 + 1 );
 
 Pkts. Entry [I]. dst_as = htons (RAND () % 100 + 1 );
 Pkts. Entry [I]. src_netmask_len = htons (24 );
 
 Pkts. Entry [I]. dst_netmask_len = htons (24 );
 Pkts. Entry [I]. Padding = htons (0 );
 }
 } |