Basic Question in networking – why max data size of ip datagram 65535 BYTES and not 65535 bits?

I recently started computer networks with some understanding of algorithms and discrete mathematics. I am completely new. Kindly elaborate following –

data size of ip datagram = 16bits. So with this $ 2^{16} -1 = 65536$ 16 bit patterns can be generated. My doubt:

  1. Do we say each 16 bit pattern is 1 IP datagram or all those 65536 patterns as 1 IP Datagram?
  2. If i consider all 65536 patterns as max data size, then max ip datagram size $ = 65536$ patterns size$ = 65536*16 $ bits $ = 65536*16/8$ bytes $ = 65536*2$ bytes

Runtime: FATAL EXCEPTION: main Process data parcel size 1245464 bytes error [on hold]

It’s a puzzle game App.two Activity All source codes

public class GameActivity extends AppCompatActivity {     private static final String TAG = "GameActivity";    public static final int SPAN_COUNT = 3;    public static final int BLANK_BRICK = 8;    public static final int[][] GOAL_STATUS = {{0, 1, 2}, {3, 4, 5}, {6, 7, BLANK_BRICK}};    public static final int MAIL_GAME_STARTED = 100;    public static final int MAIL_STEP_MOVED = 101;    public static final int MAIL_GAME_WON = 102;    public static final int REQUEST_CODE_CHOOSE_PICTURE = 100;     private Bitmap mFullBitmap;    private Bitmap[] mBitmapBricks = new Bitmap[SPAN_COUNT * SPAN_COUNT];    private Timer mTimer;    private long mStartTime;    private int mStepCount;     private TextView mTvTime;    private TextView mTvStep;    private Button mBtnChooseAndStart;    @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {         Window window = getWindow();         window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);         window.setEnterTransition(new Explode());         window.setExitTransition(new Explode());     }         setContentView(R.layout.activity_game);      Mailbox.getInstance().atHome(this);      mTvTime = findViewById(;     mTvStep = findViewById(;     mBtnChooseAndStart = findViewById(; }     @Override protected void onDestroy() {     super.onDestroy();     Mailbox.getInstance().leave(this); }  @SuppressLint("RestrictedApi") private void startActivityForNewPicture() {     Intent intent = new Intent(this, ChooseActivity.class);     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {         startActivityForResult(                 intent, REQUEST_CODE_CHOOSE_PICTURE,                 ActivityOptionsCompat.makeSceneTransitionAnimation(                         this,                         findViewById(,                         getString(R.string.bottom_button_trans_name)).toBundle());     } else {         startActivityForResult(intent, REQUEST_CODE_CHOOSE_PICTURE);     } }  @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {     super.onActivityResult(requestCode, resultCode, data);     if (requestCode == REQUEST_CODE_CHOOSE_PICTURE) {         if (resultCode == RESULT_OK) {             handleChooseResult(data.getData());         }     } }  private void handleChooseResult(Uri uri) {     try {         Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));          // Delete the cache file CropImage generated         IOUtils.deleteFile(uri.getPath());          // Scale the bitmap to a proper size, avoiding waste of memory         View container = findViewById(;         assert container != null;         int paddingHorizontal = container.getPaddingLeft() + container.getPaddingRight();         int paddingVertical = container.getPaddingTop() + container.getPaddingBottom();         mFullBitmap = Bitmap.createScaledBitmap(                 bitmap,                 container.getWidth() - paddingHorizontal,                 container.getHeight() - paddingVertical,                 false);          cutBitmapIntoPieces();         mBitmapBricks[SPAN_COUNT * SPAN_COUNT - 1] = BitmapFactory.decodeResource(getResources(), R.drawable.blank_brick);          startNewGame();     } catch (FileNotFoundException e) {         e.printStackTrace();     } }  private void cutBitmapIntoPieces() {     int dividerWidth = (int) getResources().getDimension(R.dimen.brick_divider_width);     int brickWidth = (mFullBitmap.getWidth() - dividerWidth * (SPAN_COUNT - 1)) / SPAN_COUNT;     int brickHeight = (mFullBitmap.getHeight() - dividerWidth * (SPAN_COUNT - 1)) / SPAN_COUNT;     for (int i = 0; i < SPAN_COUNT; i++) {         for (int j = 0; j < SPAN_COUNT; j++) {             mBitmapBricks[i * SPAN_COUNT + j] = Bitmap.createBitmap(                     mFullBitmap,                     j * (brickWidth + dividerWidth),                     i * (brickHeight + dividerWidth),                     brickWidth, brickHeight);         }     } }  private void startNewGame() {     mBtnChooseAndStart.setVisibility(View.GONE);     getSupportFragmentManager()             .beginTransaction()             .replace(, GameFragment.newInstance(mBitmapBricks, GOAL_STATUS))             .commit(); }  @OnMailReceived public void onMailReceived(Mail mail) {     if (mail.from == GameFragment.class) {         switch ((int) mail.content) {             case MAIL_GAME_STARTED:                 L.d(TAG, "Game started");                 onGameStarted();                 break;             case MAIL_STEP_MOVED:                 L.d(TAG, "Moved");                 onStepMoved();                 break;             case MAIL_GAME_WON:                 L.d(TAG, "Game won");                 onGameWon();                 break;         }     } }  @SuppressLint("SetTextI18n") private void onGameStarted() {     mStepCount = 0;     mTvStep.setText(String.valueOf(mStepCount));     mTvTime.setText("00:00");      mStartTime = System.currentTimeMillis();     mTimer = new Timer();     mTimer.schedule(new TimerTask() {         @SuppressLint("SimpleDateFormat")         @Override         public void run() {             runOnUiThread(new Runnable() {                 @Override                 public void run() {                     long nowTime = System.currentTimeMillis();                     Date span = new Date(nowTime - mStartTime);                     SimpleDateFormat format = new SimpleDateFormat("mm:ss");                     mTvTime.setText(format.format(span));                 }             });         }     }, 0, 1000); }  private void onStepMoved() {     mStepCount++;     mTvStep.setText(String.valueOf(mStepCount)); }  private void onGameWon() {     mTimer.cancel();     mTimer.purge();     App.getMainHandler().postDelayed(new Runnable() {         @Override         public void run() {             getSupportFragmentManager()                     .beginTransaction()                     .replace(, WinFragment.newInstance(mFullBitmap))                     .commit();               new AlertDialog.Builder(GameActivity.                     this)                     .setTitle(getString(R.string.result))                     .setMessage(String.format(getString(R.string.win_prompt_format), mTvTime.getText().toString(), mTvStep.getText().toString()))                     .setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {                         @Override                         public void onClick(DialogInterface dialog, int which) {                             startNewGame();                         }                     })                     .show();               /*             UIUtils.toast(                     GameActivity.this,                     String.format(getString(R.string.win_prompt_format), mTvTime.getText().toString(), mTvStep.getText().toString()),                     true);              */          }     }, 500); }  public void changePicture(View view) {     startActivityForNewPicture(); }  public void restart(View view) {     if (mFullBitmap == null) {         // Not started, so cannot restart         UIUtils.toast(this, getString(R.string.not_started));         return;     }      new AlertDialog.Builder(this)             .setTitle(getString(R.string.restart))             .setMessage(getString(R.string.confirm_restart_msg))             .setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {                 @Override                 public void onClick(DialogInterface dialog, int which) {                     startNewGame();                 }             })             .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {                 @Override                 public void onClick(DialogInterface dialog, int which) {                     dialog.dismiss();                 }             })             .show(); }  public void lookUpOriginalPicture(View view) {     if (mFullBitmap == null) {         // Not started, so cannot restart         UIUtils.toast(this, getString(R.string.not_started));         return;     }      View alertView = View.inflate(this, R.layout.dialog_loop_up, null);     ImageView imageView = alertView.findViewById(;     imageView.setImageBitmap(mFullBitmap);     final AlertDialog dialog = new AlertDialog.Builder(this)             .setView(alertView)             .create();     alertView.setOnTouchListener(new View.OnTouchListener() {         @SuppressLint("ClickableViewAccessibility")         @Override         public boolean onTouch(View v, MotionEvent event) {             dialog.dismiss();             return true;         }     });; }  public void chooseAndStart(View view) {     startActivityForNewPicture(); } }

public class ChooseActivity extends AppCompatActivity { private static final int CHOOSER_SPAN_COUNT = 2;  private final int[] mResIds = new int[]{         R.mipmap.pic_1, R.mipmap.pic_2, R.mipmap.pic_3,         R.mipmap.pic_4, R.mipmap.pic_5, R.mipmap.pic_6,         R.mipmap.pic_7, R.mipmap.pic_8 };  private Uri[] mUris = new Uri[mResIds.length];   private static String[] PERMISSIONS_STORAGE = {         Manifest.permission.READ_EXTERNAL_STORAGE,         Manifest.permission.WRITE_EXTERNAL_STORAGE};  private static int REQUEST_PERMISSION_CODE = 1;  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_choose);      for (int i = 0; i < mResIds.length; i++) {         mUris[i] = ResUtils.getUriOfResource(this, mResIds[i]);     }      initView(); }  private void initView() {     RecyclerView recyclerView = findViewById(;     assert recyclerView != null;     CommonRecyclerViewAdapter<Uri> adapter = new CommonRecyclerViewAdapter<Uri>(this, mUris, R.layout.choose_pic_item) {         @Override         public void onItemViewAppear(ViewHolder holder, Uri uri, int position) {             holder.setViewImageResource(, mResIds[position]);         }     };     adapter.setOnItemClickListener(new CommonRecyclerViewAdapter.OnItemClickListener() {         @Override         public void onItemClick(View view, int position) {             returnUri(mUris[position]);         }     });     recyclerView.setAdapter(adapter);     recyclerView.setLayoutManager(new GridLayoutManager(this, CHOOSER_SPAN_COUNT));     recyclerView.addItemDecoration(new SquareGridSpacingItemDecoration(this, R.dimen.brick_divider_width)); }  public void chooseFromGallery(View view) {      if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {         if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {             ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_PERMISSION_CODE);         }     }      Intent intent = new Intent(Intent.ACTION_GET_CONTENT);     intent.setType("image/*");     startActivityForResult(intent, CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE); }  @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {     super.onRequestPermissionsResult(requestCode, permissions, grantResults);     if (requestCode == REQUEST_PERMISSION_CODE) {         for (int i = 0; i < permissions.length; i++) {             Log.i("MainActivity", "perm:" + permissions[i] + ",res:" + grantResults[i]);         }     } }     @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {     super.onActivityResult(requestCode, resultCode, data);     switch (requestCode) {         case CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE: {             if (resultCode == RESULT_OK) {                 CropImage.activity(Objects.requireNonNull(data.getData()))                         .setActivityTitle(getString(R.string.crop))                         .setAspectRatio(1, 1)                         .setFixAspectRatio(true)                         .start(this);             }             break;         }         case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE: {             if (resultCode == RESULT_OK) {                 CropImage.ActivityResult result = CropImage.getActivityResult(data);                 returnUri(result.getUri());             }             break;         }     } }  private void returnUri(Uri uri) {     Intent intent = new Intent();     intent.setData(uri);     setResult(RESULT_OK, intent);     finish(); } } 

How can I modify the source code?

Adding Bytes Using a Hex Editor

Due to incompatibility of root account and sandbox, I need to manually disable sandboxing of MS Office applications (so that it can be activated) by changing the value of from enter image description here to enter image description here. However, this change would lead the addition of a byte, and I can’t find any documentation on how to insert a byte. I’m using hexedit, installed with brew (brew install hexedit).

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

I’ve always wondered how so much functionality and relative luxuries(CMOS Configuration Utilities. See: for an example) included with most popular x86 BIOSes could be packed into such a tight space. According to Wikipedia some early(1971-199x; the EPROM reference table doesn’t have a lot of dates.) EPROMs where quite small in size. I had a hard time finding a good average size in bytes for an x86 CMOS BIOS EPROM chip from the late 80s early 90s but I’m assuming they weren’t measured in MBs but in KBs. This Quora post seems to confirm this.

The author writes: “The Phoenix BIOSes I wrote in 1984-1985 never supported the ROM Basic. The PC was 8k and filled completely. The XT was put into a 16k, but was probably about 10k of code. The AT was probably about 16k for the BIOS and maybe another 8k for the setup, and was normally placed in a 32k ROM.”

32kbs by today’s standards is quite a small amount of storage space. I suppose for a BIOS most of what you’re doing doesn’t need immense layers of abstraction and other storage complications, but I’d think that programming those CMOS Configuration Utility TUIs would be expensive space wasters. Not to mention BIOSes somewhere along the way they began to be written in C/C++ which probably wastes some space surely. Did these early programmers just use a library similar to ncurses but for BIOS programming? How were these text interfaces engineered? As most UI libs’ raw logic(aside from platform specific stuff like windows and rendering), even super simple ones(Buttons, Labels, ect. Bare minimum common widgets.) usually require a decent amount of abstraction/complexity which seems sort of hard in a language like ASM less so if ASM is only used to load the bare minimum before switching to C/C++(which seems to be how it’s done today). Am I overthinking this? Was it easier than I’m imagining?

Using Log4j2, I Want to create a log file every day, even if the log is zero bytes

I’m wanting to get a log file created for every day, even if the log file is 0 bytes/empty

Configuration:   status: INFO   monitorInterval: 30    Properties:     property:       name: log-path       value: $  {sys:catalina.base}/logs/    Appenders:     RollingFile:       name: File_Appender       fileName: $  {log-path}/pixel_qa_corewebapps_tomcat.log       filePattern: $  {log-path}/pixel_qa_corewebapps_tomcat.log.%d{yyyy-MM-dd}       PatternLayout:         pattern: "%d{dd MMM yyyy HH:mm:ss,SSS} [%p] %t %c - %m%n"       TimeBasedTriggeringPolicy:         interval: 1         modulate: true    Loggers:     Root:       level: INFO       AppenderRef:         - ref: File_Appender 

On the weekends the QA server environment doesn’t get used, so no traffic is generated. So on these days no log file is created, which makes us think that there is something is wrong with the logging with a several days gap.

Why are WPA2 passwords longer than 16 bytes more secure than 16 byte passwords?

In this good Information Security StackExchange question, the answers reveal that a long WPA2-PSK password does not degrade performance of the network. The reasoning is that the password itself is never transmitted, and the generated CMAC that is transmitted is always 128 bits (16 bytes).

Why then, are WPA2 passwords longer than 16 bytes more secure than WPA2 passwords of 16 bytes?

What are these semi-arbitrary, seemingly nonsensical TLS hello bytes? [duplicate]

This question already has an answer here:

  • Google Chrome weird random Cipher Suite 1 answer

I’m comparing two different TLS ClientHello packets sent from a single client across two requests to the same remote host. For the most part the data is as expected (no change except for the ClientRandom data). However there are six additional bytes that appear to vary in a semi-arbitrary way, in places where the values don’t seem to make any sense.

For the first packet I have:

    0x16,                             //record type (handshake)     0x03, 0x01,                       //current TLS version (1.0)     0x00, 0xC0,                       //record size     0x01,                             //payload type     0x00, 0x00, 0xBC,                 //payload size     0x03, 0x03,                       //requested TLS version (1.2)     0xC2, 0x7E, [...] 0x2E, 0xE8,     //client random     0x00,                             //session id     0x00, 0x1C,                       //cipher-suite list size     0xCA, 0xCA,                       //nonsense cipher (0xCACA)     0xCC, 0xA9, [...] 0x00, 0x0A,     //supported ciphers     0x01, 0x00,                       //compression (none)     0x00, 0x77,                       //extensions list size     0xDA, 0xDA,                       //nonsense extension 1 (0xDADA)     0x00, 0x00, [...] 0x00, 0x08,     //extensions     0x7A, 0x7A,                       //nonsense extension 2 (0x7A7A)     0x00, 0x1D, [...] 0x01, 0x00      //extensions 

The second packet is similar, but with different ‘nonsense’ values:

    0x16,                             //record type (handshake)     0x03, 0x01,                       //current TLS version (1.0)     0x00, 0xC0,                       //record size     0x01,                             //payload type     0x00, 0x00, 0xBC,                 //payload size     0x03, 0x03,                       //requested TLS version (1.2)     0x0B, 0x84, [...] 0x34, 0xB8,     //client random     0x00,                             //session id     0x00, 0x1C,                       //cipher-suite list size     0x0A, 0x0A,                       //nonsense cipher (0x0A0A)     0xCC, 0xA9, [...] 0x00, 0x0A,     //supported ciphers     0x01, 0x00,                       //compression (none)     0x00, 0x77,                       //extensions list size     0x3A, 0x3A,                       //nonsense extension 1 (0x3A3A)     0x00, 0x00, [...] 0x00, 0x08,     //extensions     0x8A, 0x8A,                       //nonsense extension 2 (0x8A8A)     0x00, 0x1D, [...] 0x01, 0x00      //extensions 

What is the significance of these bytes? And if I’m trying to perform a TLS handshake with the client, is there anything my implementation would need to do to respond to the different values or can they safely be ignored?

Write input bytes to a file directly in Python3

I am using Python 3.6.1. This program simply allows a user to enter some bytes as a “string” and it writes those bytes to a file as actual bytes in the order provided.

import sys   WELCOME_MSG = ("Welcome to Byte Writer. Enter some bytes separated by spaces "             "like 49 A7 9F 4B when prompted. 'exit' or 'quit' to leave") FILE_WRITE_ERROR = "Error writing to file... exiting." INVALID_INPUT_ERROR = ("Improper byte format. Remember to enter "     "2 chars at a time separated by spaces. Hex digits only") INPUT_PROMPT = "Enter bytes: " VALID_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8',             '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f']   def main(argv):     if not validate_args(argv):         return -1     with open(argv[1], "ab") as f:         print(WELCOME_MSG)         while run_loop(argv, f) is True:             pass      print("Have a nice day.")   def run_loop(argv, f):     output_list = []     ui = input(INPUT_PROMPT)     if ui == "exit" or ui == "quit":         return False      list_of_str_bytes = ui.split(' ')     if validate_input_list(list_of_str_bytes) is False:         print(INVALID_INPUT_ERROR)         return False      for b in list_of_str_bytes:         output_list.append( int(b, 16) )      try:         f.write(bytes(output_list))     except:         print(FILE_WRITE_ERROR)         return False     return True   def validate_args(argv):     if len(argv) != 2:         print("USAGE: {} [filename to save to]".format(argv[0]))         return False     return True   def validate_input_list(input_list):     for b in input_list:         if len(b) != 2 or not valid_chars(b):             return False      return True   def valid_chars(chars):     for c in chars:         if c not in VALID_CHARS:             return False          return True if __name__ == '__main__':     main(sys.argv) 

Converter list para bytes python

Estou tendo problemas ao tentar converter uma list para bytes por causa das aspas simples que aparecem no início. Como posso remover esses caracteres para obter a conversão?

<class 'str'> 0, 0, 0, 0, 248, 31, 0, 248, 31, 0, 248, 31, 0, 248, 31, 0, 248, 31, 0, 0, 0 

Quando convertido para list:

<class 'list'> ['0, 0, 0, 0, 248, 31, 0, 248, 31, 0, 248, 31, 0, 248, 31, 0, 248, 31, 0, 0, 0'] 


TypeError: 'str' object cannot be interpreted as an integer