Buggy code:
public class Search { public static PacketTracer runTest ( Graph g , int numTests , Boolean cacheEnabled , int numAttackers ) { ArrayList < Node > requesters = new ArrayList < Node > ( ) ; ArrayList < Node > custodians = new ArrayList < Node > ( ) ; ArrayList < Node > attackers = new ArrayList < Node > ( ) ; for ( int j = 0 ; j < ( g . size ) ; j ++ ) { Dijkstra . ComputePaths ( g , g . nodes . get ( j ) ) ; if ( ! ( g . localContentCustodians . contains ( g . nodes . get ( j ) ) ) ) { requesters . add ( g . nodes . get ( j ) ) ; } else { custodians . add ( g . nodes . get ( j ) ) ; } } DateFormat dateFormat = new SimpleDateFormat ( "yyyyMMdd_HHmmssSSS" ) ; Date d = new Date ( ) ; String file_name = ( "C:\\temp\\manet\\" + ( dateFormat . format ( d ) ) ) + ".txt" ; PacketTracer test = new PacketTracer ( cacheEnabled ) ; Random rand = new Random ( requesters . size ( ) ) ; for ( int a = 0 ; a < numAttackers ; a ++ ) { int attackerindex = rand . nextInt ( requesters . size ( ) ) ; attackers . add ( requesters . get ( attackerindex ) ) ; requesters . remove ( attackerindex ) ; <START_BUG> Attack . OrderAllContent ( attackers . get ( a ) ) ; <END_BUG> Node target = Attack . FindBestTarget ( attackers . get ( a ) , custodians ) ; } int cachehits = 0 ; int totalHops = 0 ; double percent = 0 ; double averagehops = 0 ; int p = 0 ; double jump = 0 ; double maxtime = 0 ; int cacheSize = g . cacheSize ; int cacheType = g . cacheType ; for ( int x = 0 ; x < numTests ; x ++ ) { jump = maxtime ; p = Poisson . getPoisson ( 0.65 ) ; Content k = g . getZipfContent ( ) ; Node n = g . nodes . get ( requesters . get ( rand . nextInt ( requesters . size ( ) ) ) . nodeID ) ; test . addToTest ( ( jump + p ) , k , n ) ; Packet pack = new Packet ( n , k ) ; pack . cacheEnabled = cacheEnabled ; pack . dest = n . contentCustodians . get ( k ) ; pack . route = Dijkstra . getShortestPath ( pack . src , pack . dest ) ; Packet r = Search . findContent ( pack ) ; if ( r . cachehit ) cachehits ++ ; totalHops += r . hops ; maxtime += p ; } System . out . println ( ( "Maxtime:<seq2seq4repair_space>" + maxtime ) ) ; percent = ( ( ( double ) ( cachehits ) ) // ( ( double ) ( numTests ) ) ) * 100 ; System . out . println ( ( "Number<seq2seq4repair_space>of<seq2seq4repair_space>tests<seq2seq4repair_space>performed:<seq2seq4repair_space>" + numTests ) ) ; System . out . println ( ( "Number<seq2seq4repair_space>of<seq2seq4repair_space>hops<seq2seq4repair_space>in<seq2seq4repair_space>test:<seq2seq4repair_space>" + totalHops ) ) ; System . out . println ( ( "Cache<seq2seq4repair_space>Size:<seq2seq4repair_space>" + cacheSize ) ) ; System . out . println ( ( "Number<seq2seq4repair_space>of<seq2seq4repair_space>cache<seq2seq4repair_space>hits<seq2seq4repair_space>in<seq2seq4repair_space>test:<seq2seq4repair_space>" + cachehits ) ) ; System . out . println ( ( ( "Percentage<seq2seq4repair_space>of<seq2seq4repair_space>cache<seq2seq4repair_space>hits:<seq2seq4repair_space>" + percent ) + "%" ) ) ; averagehops = ( ( double ) ( totalHops ) ) // ( ( double ) ( numTests ) ) ; System . out . println ( ( "Average<seq2seq4repair_space>hops<seq2seq4repair_space>per<seq2seq4repair_space>request:<seq2seq4repair_space>" + averagehops ) ) ; test . setTotals ( cacheType , cacheSize , numTests , totalHops , cachehits , averagehops ) ; return test ; } public static Packet findContent ( Packet p ) { } }

Fix:
ArrayList < Content > orderedContentTarget = Attack . OrderTargetContent ( attackers . get ( a ) ) ;