Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8736771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:22:16+00:00 2026-06-13T10:22:16+00:00

I have a file which contains raw IP packets in binary form. The data

  • 0

I have a file which contains raw IP packets in binary form. The data in the file contains a full IP header, TCP\UDP header, and data. I would like to use any language (preferably python) to read this file and dump the data onto the line.

In Linux I know you can write to some devices directly (echo “DATA” > /dev/device_handle). Would using python to do an open on /dev/eth1 achieve the same effect (i.e. could I do echo “DATA” > /dev/eth1)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:22:17+00:00Added an answer on June 13, 2026 at 10:22 am

    Something like:

    #!/usr/bin/env python
    import socket
    s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
    s.bind(("ethX", 0))
    
    blocksize = 100;
    with open('filename.txt') as fh:
        while True:
            block = fh.read(blocksize)
            if block == "": break  #EOF
            s.send(block)
    

    Should work, haven’t tested it however.

    • ethX needs to be changed to your interface (e.g. eth1, eth2, wlan1, etc.)
    • You may want to play around with blocksize. 100 bytes at a time should be fine, you may consider going up but I’d stay below the 1500 byte Ethernet PDU.
    • It’s possible you’ll need root/sudoer permissions for this. I’ve needed them before when reading from a raw socket, never tried simply writing to one.
    • This is provided that you literally have the packet (and only the packet) dumped to file. Not in any sort of encoding (e.g. hex) either. If a byte is 0x30 it should be ‘0’ in your text file, not “0x30”, “30” or anything like that. If this is not the case you’ll need to replace the while loop with some processing, but the send is still the same.
    • Since I just read that you’re trying to send IP packets — In this case, it’s also likely that you need to build the entire packet at once, and then push that to the socket. The simple while loop won’t be sufficient.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large raw data file (up to 1GB) which contains raw samples
I have a large file which contains lots of data, and I'd like to
I have file which contains some data, like this 2011-01-02 100100 1 2011-01-02 100200
I have a file which contains lines of data in the following format: a11
I have a text file which contains data seperated by '|'. I need to
I have a txt file which contains data in the following format: X1 Y1
I have written xml file which contains html tags as element like <component> <input
I have a text file which contains data I need to preload into a
I have file which contains the following data: -------------------[ server10 ]------------------- user1 user2 user99
I have a file which contains values like: CA, PA, NY ND, MO, MI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.