Skip to content

Commit

Permalink
Mitigate packet size too long
Browse files Browse the repository at this point in the history
  • Loading branch information
ariary committed Dec 10, 2021
1 parent 59dd5da commit ef41b2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ it uses the icmp protocol.`,

cmdSend.PersistentFlags().StringVarP(&listenAddr, "listen", "l", "0.0.0.0", "address used for listening echo reply")

cmdSend.PersistentFlags().IntVarP(&chunkSize, "size", "s", 65507, "Size of each ICMP data section send by packet")
cmdSend.PersistentFlags().IntVarP(&chunkSize, "size", "s", 65488, "Size of each ICMP data section send by packet")

cmdSend.PersistentFlags().IntVarP(&delay, "delay", "d", 4, "delay between each packet sent")

Expand Down
8 changes: 4 additions & 4 deletions pkg/icmp/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func GetMessageSizeAndSender(listenAddr string) (size int, sender string) {
}
defer c.Close()

packet := make([]byte, 65507)
packet := make([]byte, 65535)
n, peer, err := c.ReadFrom(packet)
if err != nil {
fmt.Println("Error while reading icmp packet:", err)
Expand Down Expand Up @@ -136,7 +136,7 @@ func ServeTemporary(listenAddr string, n int, progressBar bool, delay int) (data

//Get a single packet then add the data to the slice (= chunked data) and remove the index from the indexes
func getPacket(c *icmp.PacketConn, data []string, indexes map[int]int) {
packet := make([]byte, 65507)
packet := make([]byte, 65535)
n, peer, err := c.ReadFrom(packet)
if err != nil {
fmt.Println("Error while reading icmp packet:", err)
Expand All @@ -161,7 +161,7 @@ func getPacket(c *icmp.PacketConn, data []string, indexes map[int]int) {

//Get a single packet then add the data to the slice (= chunked data), remove the index from the indexes & update the crossbar
func getPacketAndBarUpdate(bar *progressbar.ProgressBar, c *icmp.PacketConn, data []string, indexes map[int]int) {
packet := make([]byte, 65507)
packet := make([]byte, 65535)
n, peer, err := c.ReadFrom(packet)
if err != nil {
fmt.Println("Error while reading icmp packet:", err)
Expand Down Expand Up @@ -195,7 +195,7 @@ func IntegrityCheck(hash string) {
defer c.Close()

for {
packet := make([]byte, 65507)
packet := make([]byte, 65535)
n, peer, err := c.ReadFrom(packet)
if err != nil {
fmt.Println("Error while reading icmp packet:", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/icmp/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func IcmpSendAndWaitForReply(listeningReplyAddr string, remoteAddr string, data
}

// Wait for a reply
reply := make([]byte, 65507)
reply := make([]byte, 65535)
err = c.SetReadDeadline(time.Now().Add(10 * time.Second))
if err != nil {
return dst, 0, err
Expand Down

0 comments on commit ef41b2b

Please # to comment.