add -shuffle flag
This commit is contained in:
parent
c4b0185b8d
commit
850380bf6f
13
main.go
13
main.go
|
@ -8,6 +8,7 @@ import (
|
||||||
_ "image/jpeg"
|
_ "image/jpeg"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
|
@ -24,6 +25,7 @@ var image_offsety = flag.Int("yoffset", 0, "Offset of posted image from top bord
|
||||||
var connections = flag.Int("connections", 10, "Number of simultaneous connections/threads. Each Thread posts a subimage")
|
var connections = flag.Int("connections", 10, "Number of simultaneous connections/threads. Each Thread posts a subimage")
|
||||||
var address = flag.String("host", "127.0.0.1:1337", "Server address")
|
var address = flag.String("host", "127.0.0.1:1337", "Server address")
|
||||||
var runtime = flag.String("runtime", "1", "Runtime in Minutes")
|
var runtime = flag.String("runtime", "1", "Runtime in Minutes")
|
||||||
|
var shuffle = flag.Bool("shuffle", false, "pixel send ordering")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -50,6 +52,10 @@ func main() {
|
||||||
|
|
||||||
// Generate and split messages into equal chunks
|
// Generate and split messages into equal chunks
|
||||||
commands := genCommands(readImage(*image_path), *image_offsetx, *image_offsety)
|
commands := genCommands(readImage(*image_path), *image_offsetx, *image_offsety)
|
||||||
|
if *shuffle {
|
||||||
|
shuffleCommands(commands)
|
||||||
|
}
|
||||||
|
|
||||||
commandGroups := chunkCommands(commands, *connections)
|
commandGroups := chunkCommands(commands, *connections)
|
||||||
for _, messages := range commandGroups {
|
for _, messages := range commandGroups {
|
||||||
go bomb(messages)
|
go bomb(messages)
|
||||||
|
@ -138,3 +144,10 @@ func chunkCommands(commands [][]byte, numChunks int) [][][]byte {
|
||||||
}
|
}
|
||||||
return chunks
|
return chunks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shuffleCommands(slice [][]byte) {
|
||||||
|
for i := range slice {
|
||||||
|
j := rand.Intn(i + 1)
|
||||||
|
slice[i], slice[j] = slice[j], slice[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue